Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/security/mscapi/KeytoolChangeAlias.sh
38841 views
1
#!/bin/sh
2
3
#
4
# Copyright (c) 2006, 2015, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
# or visit www.oracle.com if you need additional information or have any
23
# questions.
24
#
25
26
27
# @test
28
# @bug 6415696 6931562
29
# @requires os.family == "windows"
30
# @run shell KeytoolChangeAlias.sh
31
# @summary Test "keytool -changealias" using the Microsoft CryptoAPI provider.
32
33
# set a few environment variables so that the shell-script can run stand-alone
34
# in the source directory
35
if [ "${TESTSRC}" = "" ] ; then
36
TESTSRC="."
37
fi
38
39
if [ "${TESTCLASSES}" = "" ] ; then
40
TESTCLASSES="."
41
fi
42
43
if [ "${TESTJAVA}" = "" ] ; then
44
echo "TESTJAVA not set. Test cannot execute."
45
echo "FAILED!!!"
46
exit 1
47
fi
48
49
OS=`uname -s`
50
case "$OS" in
51
Windows* | CYGWIN* )
52
53
# 'uname -m' does not give us enough information -
54
# should rely on $PROCESSOR_IDENTIFIER (as is done in Defs-windows.gmk),
55
# but JTREG does not pass this env variable when executing a shell script.
56
#
57
# execute test program - rely on it to exit if platform unsupported
58
59
echo "Creating the alias '246810' in the Windows-My store..."
60
${TESTJAVA}/bin/keytool \
61
-import \
62
-storetype Windows-My \
63
-file ${TESTSRC}/246810.cer \
64
-alias 246810 \
65
-noprompt
66
67
if [ $? -ne 0 ] ; then
68
exit $?
69
fi
70
71
echo "Removing the alias '13579', if it is already present..."
72
${TESTJAVA}/bin/keytool \
73
-list \
74
-storetype Windows-My \
75
-alias 13579 > /dev/null 2>&1
76
77
if [ $? ] ; then
78
${TESTJAVA}/bin/keytool \
79
-delete \
80
-storetype Windows-My \
81
-alias 13579 \
82
-noprompt
83
fi
84
85
echo "Counting the entries in the store..."
86
count=`${TESTJAVA}/bin/keytool -list -storetype Windows-My | wc -l`
87
before=$count
88
89
echo "Changing the alias name from '246810' to '13579'..."
90
91
${TESTJAVA}/bin/keytool \
92
-changealias \
93
-storetype Windows-My \
94
-alias 246810 \
95
-destalias 13579
96
97
if [ $? -ne 0 ] ; then
98
exit $?
99
fi
100
101
echo "Re-counting the entries in the store..."
102
count=`${TESTJAVA}/bin/keytool -list -storetype Windows-My | wc -l`
103
after=$count
104
105
if [ ! $before = $after ]; then
106
echo "error: unexpected number of entries in the Windows-MY store"
107
exit 101
108
fi
109
110
echo "Confirming that the new alias is present..."
111
${TESTJAVA}/bin/keytool \
112
-list \
113
-storetype Windows-My \
114
-alias 13579 > /dev/null 2>&1
115
116
if [ $? -ne 0 ] ; then
117
echo "error: cannot find the new alias name in the Windows-MY store"
118
exit 102
119
fi
120
121
echo "Removing the new alias '13579'..."
122
${TESTJAVA}/bin/keytool \
123
-delete \
124
-storetype Windows-My \
125
-alias 13579 > /dev/null 2>&1
126
127
echo done.
128
exit 0
129
;;
130
131
* )
132
echo "This test is not intended for '$OS' - passing test"
133
exit 0
134
;;
135
esac
136
137
138
139
140