jdk/test/sun/security/mscapi/KeytoolChangeAlias.sh
changeset 24116 9f9b4ba34aad
parent 9519 a371830a963b
child 32427 c22b7e41adf3
equal deleted inserted replaced
24077:0809c9a4d36e 24116:9f9b4ba34aad
    54     #  but JTREG does not pass this env variable when executing a shell script.
    54     #  but JTREG does not pass this env variable when executing a shell script.
    55     #
    55     #
    56     #  execute test program - rely on it to exit if platform unsupported
    56     #  execute test program - rely on it to exit if platform unsupported
    57 
    57 
    58         echo "Creating the alias '246810' in the Windows-My store..."
    58         echo "Creating the alias '246810' in the Windows-My store..."
    59         ${TESTJAVA}/bin/keytool \
    59         ${TESTJAVA}/bin/keytool ${TESTTOOLVMOPTS} \
    60 	    -import \
    60 	    -import \
    61 	    -storetype Windows-My \
    61 	    -storetype Windows-My \
    62 	    -file ${TESTSRC}/246810.cer \
    62 	    -file ${TESTSRC}/246810.cer \
    63 	    -alias 246810 \
    63 	    -alias 246810 \
    64 	    -noprompt
    64 	    -noprompt
    66 	if [ $? -ne 0 ] ; then
    66 	if [ $? -ne 0 ] ; then
    67             exit $?
    67             exit $?
    68 	fi
    68 	fi
    69 
    69 
    70 	echo "Removing the alias '13579', if it is already present..."
    70 	echo "Removing the alias '13579', if it is already present..."
    71         ${TESTJAVA}/bin/keytool \
    71         ${TESTJAVA}/bin/keytool ${TESTTOOLVMOPTS} \
    72 	    -list \
    72 	    -list \
    73             -storetype Windows-My \
    73             -storetype Windows-My \
    74 	    -alias 13579 > /dev/null 2>&1
    74 	    -alias 13579 > /dev/null 2>&1
    75 
    75 
    76 	if [ $? ] ; then
    76 	if [ $? ] ; then
    77             ${TESTJAVA}/bin/keytool \
    77             ${TESTJAVA}/bin/keytool ${TESTTOOLVMOPTS} \
    78 		-delete \
    78 		-delete \
    79 		-storetype Windows-My \
    79 		-storetype Windows-My \
    80 		-alias 13579 \
    80 		-alias 13579 \
    81 		-noprompt
    81 		-noprompt
    82 	fi
    82 	fi
    83 
    83 
    84 	echo "Counting the entries in the store..."
    84 	echo "Counting the entries in the store..."
    85 	count=`${TESTJAVA}/bin/keytool -list -storetype Windows-My | wc -l`
    85 	count=`${TESTJAVA}/bin/keytool ${TESTTOOLVMOPTS} -list -storetype Windows-My | wc -l`
    86 	before=$count
    86 	before=$count
    87 
    87 
    88 	echo "Changing the alias name from '246810' to '13579'..."
    88 	echo "Changing the alias name from '246810' to '13579'..."
    89 
    89 
    90         ${TESTJAVA}/bin/keytool \
    90         ${TESTJAVA}/bin/keytool ${TESTTOOLVMOPTS} \
    91 	    -changealias \
    91 	    -changealias \
    92 	    -storetype Windows-My \
    92 	    -storetype Windows-My \
    93 	    -alias 246810 \
    93 	    -alias 246810 \
    94 	    -destalias 13579
    94 	    -destalias 13579
    95 
    95 
    96 	if [ $? -ne 0 ] ; then
    96 	if [ $? -ne 0 ] ; then
    97             exit $?
    97             exit $?
    98 	fi
    98 	fi
    99 
    99 
   100 	echo "Re-counting the entries in the store..."
   100 	echo "Re-counting the entries in the store..."
   101 	count=`${TESTJAVA}/bin/keytool -list -storetype Windows-My | wc -l`
   101 	count=`${TESTJAVA}/bin/keytool ${TESTTOOLVMOPTS} -list -storetype Windows-My | wc -l`
   102 	after=$count
   102 	after=$count
   103 
   103 
   104 	if [ ! $before = $after ]; then
   104 	if [ ! $before = $after ]; then
   105 	    echo "error: unexpected number of entries in the Windows-MY store"
   105 	    echo "error: unexpected number of entries in the Windows-MY store"
   106 	    exit 101
   106 	    exit 101
   107 	fi
   107 	fi
   108 
   108 
   109 	echo "Confirming that the new alias is present..."
   109 	echo "Confirming that the new alias is present..."
   110         ${TESTJAVA}/bin/keytool \
   110         ${TESTJAVA}/bin/keytool ${TESTTOOLVMOPTS} \
   111 	    -list \
   111 	    -list \
   112             -storetype Windows-My \
   112             -storetype Windows-My \
   113 	    -alias 13579 > /dev/null 2>&1
   113 	    -alias 13579 > /dev/null 2>&1
   114 
   114 
   115 	if [ $? -ne 0 ] ; then
   115 	if [ $? -ne 0 ] ; then
   116 	    echo "error: cannot find the new alias name in the Windows-MY store"
   116 	    echo "error: cannot find the new alias name in the Windows-MY store"
   117 	    exit 102
   117 	    exit 102
   118 	fi
   118 	fi
   119 
   119 
   120 	echo "Removing the new alias '13579'..."
   120 	echo "Removing the new alias '13579'..."
   121         ${TESTJAVA}/bin/keytool \
   121         ${TESTJAVA}/bin/keytool ${TESTTOOLVMOPTS} \
   122 	    -delete \
   122 	    -delete \
   123             -storetype Windows-My \
   123             -storetype Windows-My \
   124 	    -alias 13579 > /dev/null 2>&1
   124 	    -alias 13579 > /dev/null 2>&1
   125 
   125 
   126 	echo done.
   126 	echo done.