AltProviderPath.sh 3.4 KB
Newer Older
D
duke 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 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 49 50 51 52 53 54
#
# Copyright 2004-2005 Sun Microsystems, Inc.  All Rights Reserved.
# 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.
#
# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
#

# @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
  SunOS | Linux )
    NULL=/dev/null
    PS=":"
    FS="/"
    TMP=/tmp
    ;;
55 56 57 58 59 60
  CYGWIN* )
    NULL=/dev/null
    PS=";"
    FS="/"
    TMP=/tmp
    ;;
D
duke 已提交
61 62 63 64 65 66 67 68 69 70 71 72 73 74
  Windows_* )
    NULL=NUL
    PS=";"
    FS="\\"
    TMP="c:/temp"
    ;;
  * )
    echo "Unrecognized operating system!"
    exit 1;
    ;;
esac

# the test code
#genkey
75 76 77 78 79 80
${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 \
    -storetype "dks" -provider "org.test.dummy.DummyProvider" \
    -providerPath ${TESTCLASSES}
D
duke 已提交
81 82 83 84 85 86

if [ $? -ne 0 ]; then 
    exit 1
fi

#Change keystore password
87 88 89
${TESTJAVA}${FS}bin${FS}keytool -storepasswd -new storepass2 \
    -keystore keystoreCA.dks -storetype "dks" -storepass storepass \
    -provider "org.test.dummy.DummyProvider" -providerPath ${TESTCLASSES}
D
duke 已提交
90 91 92 93 94 95 96

if [ $? -ne 0 ]; then 
    exit 1
fi


#Change keystore key password
97 98 99 100
${TESTJAVA}${FS}bin${FS}keytool -keypasswd -alias "dummyTestCA" \
    -keypass storepass -new keypass -keystore keystoreCA.dks \
    -storetype "dks" -storepass storepass2 \
    -provider "org.test.dummy.DummyProvider" -providerPath ${TESTCLASSES}
D
duke 已提交
101 102 103 104 105 106

if [ $? -ne 0 ]; then 
    exit 1
fi

#Export certificate
107 108 109 110
${TESTJAVA}${FS}bin${FS}keytool -v -export -rfc -alias "dummyTestCA" \
    -file "dummyTestCA.der" -keystore keystoreCA.dks -storetype "dks" \
    -storepass storepass2 -provider "org.test.dummy.DummyProvider" \
    -providerPath ${TESTCLASSES}
D
duke 已提交
111 112 113 114 115 116

if [ $? -ne 0 ]; then 
    exit 1
fi

#list keystore
117 118 119
${TESTJAVA}${FS}bin${FS}keytool -v -list -keystore keystoreCA.dks \
    -storetype "dks" -storepass storepass2 \
    -provider "org.test.dummy.DummyProvider" -providerPath ${TESTCLASSES}
D
duke 已提交
120 121 122 123 124 125

if [ $? -ne 0 ]; then 
    exit 1
fi

exit 0