AltProviderPath.sh 3.4 KB
Newer Older
D
duke 已提交
1
#
2
# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
D
duke 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
19 20 21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
D
duke 已提交
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
#

# @test
# @bug 4906940
# @summary Add -providerPath option for keytool allowing one to specify
#          an additional classpath to search for providers.
# @author Andrew Fan
#
# @run build DummyProvider
# @run shell AltProviderPath.sh
# set a few environment variables so that the shell-script can run stand-alone
# in the source directory
if [ "${TESTSRC}" = "" ] ; then
  TESTSRC="."
fi
if [ "${TESTCLASSES}" = "" ] ; then
  TESTCLASSES="."
fi
if [ "${TESTJAVA}" = "" ] ; then
  echo "TESTJAVA not set.  Test cannot execute."
  echo "FAILED!!!"
  exit 1
fi

# set platform-dependent variables
OS=`uname -s`
case "$OS" in
49
  SunOS | Linux | Darwin | AIX )
D
duke 已提交
50 51 52 53
    NULL=/dev/null
    PS=":"
    FS="/"
    ;;
54 55 56 57 58
  CYGWIN* )
    NULL=/dev/null
    PS=";"
    FS="/"
    ;;
D
duke 已提交
59 60 61 62 63 64 65 66 67 68 69 70 71
  Windows_* )
    NULL=NUL
    PS=";"
    FS="\\"
    ;;
  * )
    echo "Unrecognized operating system!"
    exit 1;
    ;;
esac

# the test code
#genkey
72 73 74 75
${TESTJAVA}${FS}bin${FS}keytool -genkey -v -alias dummyTestCA \
    -keyalg "RSA" -keysize 1024 -sigalg "ShA1WithRSA" \
    -dname "cn=Dummy Test CA, ou=JSN, o=JavaSoft, c=US" -validity 3650 \
    -keypass storepass -keystore keystoreCA.dks -storepass storepass \
76
    -storetype "dummyks" -provider "org.test.dummy.DummyProvider" \
77
    -providerPath ${TESTCLASSES}
D
duke 已提交
78

79
if [ $? -ne 0 ]; then
D
duke 已提交
80 81 82 83
    exit 1
fi

#Change keystore password
84
${TESTJAVA}${FS}bin${FS}keytool -storepasswd -new storepass2 \
85
    -keystore keystoreCA.dks -storetype "dummyks" -storepass storepass \
86
    -provider "org.test.dummy.DummyProvider" -providerPath ${TESTCLASSES}
D
duke 已提交
87

88
if [ $? -ne 0 ]; then
D
duke 已提交
89 90 91 92 93
    exit 1
fi


#Change keystore key password
94 95
${TESTJAVA}${FS}bin${FS}keytool -keypasswd -alias "dummyTestCA" \
    -keypass storepass -new keypass -keystore keystoreCA.dks \
96
    -storetype "dummyks" -storepass storepass2 \
97
    -provider "org.test.dummy.DummyProvider" -providerPath ${TESTCLASSES}
D
duke 已提交
98

99
if [ $? -ne 0 ]; then
D
duke 已提交
100 101 102 103
    exit 1
fi

#Export certificate
104
${TESTJAVA}${FS}bin${FS}keytool -v -export -rfc -alias "dummyTestCA" \
105
    -file "dummyTestCA.der" -keystore keystoreCA.dks -storetype "dummyks" \
106 107
    -storepass storepass2 -provider "org.test.dummy.DummyProvider" \
    -providerPath ${TESTCLASSES}
D
duke 已提交
108

109
if [ $? -ne 0 ]; then
D
duke 已提交
110 111 112 113
    exit 1
fi

#list keystore
114
${TESTJAVA}${FS}bin${FS}keytool -v -list -keystore keystoreCA.dks \
115
    -storetype "dummyks" -storepass storepass2 \
116
    -provider "org.test.dummy.DummyProvider" -providerPath ${TESTCLASSES}
D
duke 已提交
117

118
if [ $? -ne 0 ]; then
D
duke 已提交
119 120 121 122
    exit 1
fi

exit 0