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