jdk/test/sun/security/mscapi/KeytoolChangeAlias.sh
author vinnie
Fri, 29 Apr 2011 00:21:54 +0100
changeset 9533 13cc5e8eb9f1
parent 9519 a371830a963b
child 24116 9f9b4ba34aad
permissions -rw-r--r--
6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI Reviewed-by: wetmore
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
#!/bin/sh
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
#
9519
a371830a963b 6931562: Support SunMSCAPI Security Provider in Windows 64-bit releases of JVM
vinnie
parents: 5506
diff changeset
     4
# Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
# This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
# under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
# published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
# This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
# version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
# accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
# You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
# 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
#
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
# or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
# questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
# @test
9519
a371830a963b 6931562: Support SunMSCAPI Security Provider in Windows 64-bit releases of JVM
vinnie
parents: 5506
diff changeset
    28
# @bug 6415696 6931562
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
# @run shell KeytoolChangeAlias.sh
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
# @summary Test "keytool -changealias" using the Microsoft CryptoAPI provider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
# set a few environment variables so that the shell-script can run stand-alone
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
# in the source directory
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
if [ "${TESTSRC}" = "" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
   TESTSRC="."
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
if [ "${TESTCLASSES}" = "" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
   TESTCLASSES="."
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
if [ "${TESTJAVA}" = "" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
   echo "TESTJAVA not set.  Test cannot execute."
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
   echo "FAILED!!!"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
   exit 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
OS=`uname -s`
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
case "$OS" in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    Windows* | CYGWIN* )
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    # 'uname -m' does not give us enough information -
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    #  should rely on $PROCESSOR_IDENTIFIER (as is done in Defs-windows.gmk),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    #  but JTREG does not pass this env variable when executing a shell script.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    #
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    #  execute test program - rely on it to exit if platform unsupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        echo "Creating the alias '246810' in the Windows-My store..."
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        ${TESTJAVA}/bin/keytool \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
	    -import \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
	    -storetype Windows-My \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
	    -file ${TESTSRC}/246810.cer \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
	    -alias 246810 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
	    -noprompt
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
	if [ $? -ne 0 ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
            exit $?
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
	fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
	echo "Removing the alias '13579', if it is already present..."
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        ${TESTJAVA}/bin/keytool \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
	    -list \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
            -storetype Windows-My \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
	    -alias 13579 > /dev/null 2>&1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
	if [ $? ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
            ${TESTJAVA}/bin/keytool \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
		-delete \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
		-storetype Windows-My \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
		-alias 13579 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
		-noprompt
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
	fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
	echo "Counting the entries in the store..."
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
	count=`${TESTJAVA}/bin/keytool -list -storetype Windows-My | wc -l`
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
	before=$count
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
	echo "Changing the alias name from '246810' to '13579'..."
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        ${TESTJAVA}/bin/keytool \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
	    -changealias \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
	    -storetype Windows-My \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
	    -alias 246810 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
	    -destalias 13579
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
	if [ $? -ne 0 ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
            exit $?
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
	fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
	echo "Re-counting the entries in the store..."
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
	count=`${TESTJAVA}/bin/keytool -list -storetype Windows-My | wc -l`
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
	after=$count
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
	if [ ! $before = $after ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
	    echo "error: unexpected number of entries in the Windows-MY store"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
	    exit 101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
	fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
	echo "Confirming that the new alias is present..."
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        ${TESTJAVA}/bin/keytool \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
	    -list \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            -storetype Windows-My \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
	    -alias 13579 > /dev/null 2>&1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
	if [ $? -ne 0 ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
	    echo "error: cannot find the new alias name in the Windows-MY store"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
	    exit 102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
	fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
	echo "Removing the new alias '13579'..."
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        ${TESTJAVA}/bin/keytool \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
	    -delete \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
            -storetype Windows-My \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
	    -alias 13579 > /dev/null 2>&1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
	echo done.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        exit 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        ;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    * )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        echo "This test is not intended for '$OS' - passing test"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        exit 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        ;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
esac
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137