Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/security/tools/keytool/AltProviderPath.sh
38853 views
#1# Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.2# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3#4# This code is free software; you can redistribute it and/or modify it5# under the terms of the GNU General Public License version 2 only, as6# published by the Free Software Foundation.7#8# This code is distributed in the hope that it will be useful, but WITHOUT9# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11# version 2 for more details (a copy is included in the LICENSE file that12# accompanied this code).13#14# You should have received a copy of the GNU General Public License version15# 2 along with this work; if not, write to the Free Software Foundation,16# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17#18# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19# or visit www.oracle.com if you need additional information or have any20# questions.21#2223# @test24# @bug 490694025# @summary Add -providerPath option for keytool allowing one to specify26# an additional classpath to search for providers.27# @author Andrew Fan28#29# @run build DummyProvider30# @run shell AltProviderPath.sh31# set a few environment variables so that the shell-script can run stand-alone32# in the source directory33if [ "${TESTSRC}" = "" ] ; then34TESTSRC="."35fi36if [ "${TESTCLASSES}" = "" ] ; then37TESTCLASSES="."38fi39if [ "${TESTJAVA}" = "" ] ; then40echo "TESTJAVA not set. Test cannot execute."41echo "FAILED!!!"42exit 143fi4445# set platform-dependent variables46OS=`uname -s`47case "$OS" in48SunOS | Linux | Darwin | AIX )49NULL=/dev/null50PS=":"51FS="/"52;;53CYGWIN* )54NULL=/dev/null55PS=";"56FS="/"57;;58Windows_* )59NULL=NUL60PS=";"61FS="\\"62;;63* )64echo "Unrecognized operating system!"65exit 1;66;;67esac6869# the test code70#genkey71${TESTJAVA}${FS}bin${FS}keytool -genkey -v -alias dummyTestCA \72-keyalg "RSA" -keysize 1024 -sigalg "ShA1WithRSA" \73-dname "cn=Dummy Test CA, ou=JSN, o=JavaSoft, c=US" -validity 3650 \74-keypass storepass -keystore keystoreCA.dks -storepass storepass \75-storetype "dummyks" -provider "org.test.dummy.DummyProvider" \76-providerPath ${TESTCLASSES}7778if [ $? -ne 0 ]; then79exit 180fi8182#Change keystore password83${TESTJAVA}${FS}bin${FS}keytool -storepasswd -new storepass2 \84-keystore keystoreCA.dks -storetype "dummyks" -storepass storepass \85-provider "org.test.dummy.DummyProvider" -providerPath ${TESTCLASSES}8687if [ $? -ne 0 ]; then88exit 189fi909192#Change keystore key password93${TESTJAVA}${FS}bin${FS}keytool -keypasswd -alias "dummyTestCA" \94-keypass storepass -new keypass -keystore keystoreCA.dks \95-storetype "dummyks" -storepass storepass2 \96-provider "org.test.dummy.DummyProvider" -providerPath ${TESTCLASSES}9798if [ $? -ne 0 ]; then99exit 1100fi101102#Export certificate103${TESTJAVA}${FS}bin${FS}keytool -v -export -rfc -alias "dummyTestCA" \104-file "dummyTestCA.der" -keystore keystoreCA.dks -storetype "dummyks" \105-storepass storepass2 -provider "org.test.dummy.DummyProvider" \106-providerPath ${TESTCLASSES}107108if [ $? -ne 0 ]; then109exit 1110fi111112#list keystore113${TESTJAVA}${FS}bin${FS}keytool -v -list -keystore keystoreCA.dks \114-storetype "dummyks" -storepass storepass2 \115-provider "org.test.dummy.DummyProvider" -providerPath ${TESTCLASSES}116117if [ $? -ne 0 ]; then118exit 1119fi120121exit 0122123124