Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/security/mscapi/KeytoolChangeAlias.sh
38841 views
#!/bin/sh12#3# Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.4# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.5#6# This code is free software; you can redistribute it and/or modify it7# under the terms of the GNU General Public License version 2 only, as8# published by the Free Software Foundation.9#10# This code is distributed in the hope that it will be useful, but WITHOUT11# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13# version 2 for more details (a copy is included in the LICENSE file that14# accompanied this code).15#16# You should have received a copy of the GNU General Public License version17# 2 along with this work; if not, write to the Free Software Foundation,18# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19#20# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21# or visit www.oracle.com if you need additional information or have any22# questions.23#242526# @test27# @bug 6415696 693156228# @requires os.family == "windows"29# @run shell KeytoolChangeAlias.sh30# @summary Test "keytool -changealias" using the Microsoft CryptoAPI provider.3132# set a few environment variables so that the shell-script can run stand-alone33# in the source directory34if [ "${TESTSRC}" = "" ] ; then35TESTSRC="."36fi3738if [ "${TESTCLASSES}" = "" ] ; then39TESTCLASSES="."40fi4142if [ "${TESTJAVA}" = "" ] ; then43echo "TESTJAVA not set. Test cannot execute."44echo "FAILED!!!"45exit 146fi4748OS=`uname -s`49case "$OS" in50Windows* | CYGWIN* )5152# 'uname -m' does not give us enough information -53# should rely on $PROCESSOR_IDENTIFIER (as is done in Defs-windows.gmk),54# but JTREG does not pass this env variable when executing a shell script.55#56# execute test program - rely on it to exit if platform unsupported5758echo "Creating the alias '246810' in the Windows-My store..."59${TESTJAVA}/bin/keytool \60-import \61-storetype Windows-My \62-file ${TESTSRC}/246810.cer \63-alias 246810 \64-noprompt6566if [ $? -ne 0 ] ; then67exit $?68fi6970echo "Removing the alias '13579', if it is already present..."71${TESTJAVA}/bin/keytool \72-list \73-storetype Windows-My \74-alias 13579 > /dev/null 2>&17576if [ $? ] ; then77${TESTJAVA}/bin/keytool \78-delete \79-storetype Windows-My \80-alias 13579 \81-noprompt82fi8384echo "Counting the entries in the store..."85count=`${TESTJAVA}/bin/keytool -list -storetype Windows-My | wc -l`86before=$count8788echo "Changing the alias name from '246810' to '13579'..."8990${TESTJAVA}/bin/keytool \91-changealias \92-storetype Windows-My \93-alias 246810 \94-destalias 135799596if [ $? -ne 0 ] ; then97exit $?98fi99100echo "Re-counting the entries in the store..."101count=`${TESTJAVA}/bin/keytool -list -storetype Windows-My | wc -l`102after=$count103104if [ ! $before = $after ]; then105echo "error: unexpected number of entries in the Windows-MY store"106exit 101107fi108109echo "Confirming that the new alias is present..."110${TESTJAVA}/bin/keytool \111-list \112-storetype Windows-My \113-alias 13579 > /dev/null 2>&1114115if [ $? -ne 0 ] ; then116echo "error: cannot find the new alias name in the Windows-MY store"117exit 102118fi119120echo "Removing the new alias '13579'..."121${TESTJAVA}/bin/keytool \122-delete \123-storetype Windows-My \124-alias 13579 > /dev/null 2>&1125126echo done.127exit 0128;;129130* )131echo "This test is not intended for '$OS' - passing test"132exit 0133;;134esac135136137138139140