jdk/test/sun/security/tools/keytool/ListKeychainStore.sh
changeset 26957 663b14c9b66f
parent 24116 9f9b4ba34aad
child 27291 42769f9ca831
equal deleted inserted replaced
26904:9618201c5df2 26957:663b14c9b66f
     1 #
     1 #
     2 # Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
     2 # Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
     3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4 #
     4 #
     5 # This code is free software; you can redistribute it and/or modify it
     5 # This code is free software; you can redistribute it and/or modify it
     6 # under the terms of the GNU General Public License version 2 only, as
     6 # under the terms of the GNU General Public License version 2 only, as
     7 # published by the Free Software Foundation.
     7 # published by the Free Software Foundation.
    20 # or visit www.oracle.com if you need additional information or have any
    20 # or visit www.oracle.com if you need additional information or have any
    21 # questions.
    21 # questions.
    22 #
    22 #
    23 
    23 
    24 # @test
    24 # @test
    25 # @bug 7133495
    25 # @bug 7133495 8041740
    26 # @summary [macosx] KeyChain KeyStore implementation retrieves only one private key entry
    26 # @summary [macosx] KeyChain KeyStore implementation retrieves only one private key entry
    27 
    27 
    28 if [ "${TESTJAVA}" = "" ] ; then
    28 if [ "${TESTJAVA}" = "" ] ; then
    29     JAVAC_CMD=`which javac`
    29     JAVAC_CMD=`which javac`
    30     TESTJAVA=`dirname $JAVAC_CMD`/..
    30     TESTJAVA=`dirname $JAVAC_CMD`/..
    47 
    47 
    48 PWD="xxxxxx"
    48 PWD="xxxxxx"
    49 KEYTOOL="${TESTJAVA}/bin/keytool ${TESTTOOLVMOPTS} -storetype KeychainStore -keystore NONE -storepass $PWD"
    49 KEYTOOL="${TESTJAVA}/bin/keytool ${TESTTOOLVMOPTS} -storetype KeychainStore -keystore NONE -storepass $PWD"
    50 TEMPORARY_P12="$TESTCLASSES/7133495.p12"
    50 TEMPORARY_P12="$TESTCLASSES/7133495.p12"
    51 TEMPORARY_KC="$TESTCLASSES/7133495.keychain"
    51 TEMPORARY_KC="$TESTCLASSES/7133495.keychain"
       
    52 TEMPORARY_LIST="$TESTCLASSES/7133495.tmp"
    52 CLEANUP_P12="rm -f $TEMPORARY_P12"
    53 CLEANUP_P12="rm -f $TEMPORARY_P12"
    53 CLEANUP_KC="security delete-keychain $TEMPORARY_KC"
    54 CLEANUP_KC="security delete-keychain $TEMPORARY_KC"
       
    55 CLEANUP_LIST="rm -f $TEMPORARY_LIST"
    54 
    56 
    55 # Count the number of private key entries in the Keychain keystores
    57 # Count the number of private key entries in the Keychain keystores
    56 
    58 
    57 COUNT=`$KEYTOOL -list | grep PrivateKeyEntry | wc -l`
    59 COUNT=`$KEYTOOL -list | grep PrivateKeyEntry | wc -l`
    58 echo "Found $COUNT private key entries in the Keychain keystores"
    60 echo "Found $COUNT private key entries in the Keychain keystores"
   113     RESULT=`$CLEANUP_KC`
   115     RESULT=`$CLEANUP_KC`
   114     exit 4
   116     exit 4
   115 fi
   117 fi
   116 echo "Imported keypairs from PKCS12 keystore into the keychain"
   118 echo "Imported keypairs from PKCS12 keystore into the keychain"
   117 
   119 
       
   120 # Adjust the keychain search order
       
   121 
       
   122 echo "\"$TEMPORARY_KC\"" > $TEMPORARY_LIST
       
   123 security list-keychains >> $TEMPORARY_LIST
       
   124 security list-keychains -s `xargs < ${TEMPORARY_LIST}`
       
   125 `$CLEANUP_LIST`
       
   126 echo "Temporary keychain search order:"
       
   127 security list-keychains
       
   128 
   118 # Recount the number of private key entries in the Keychain keystores
   129 # Recount the number of private key entries in the Keychain keystores
   119 
   130 
   120 COUNT=`$KEYTOOL -list | grep PrivateKeyEntry | wc -l`
   131 COUNT=`$KEYTOOL -list | grep PrivateKeyEntry | wc -l`
   121 echo "Found $COUNT private key entries in the Keychain keystore"
   132 echo "Found $COUNT private key entries in the Keychain keystore"
   122 if [ $COUNT -lt 3 ]; then
   133 if [ $COUNT -lt 3 ]; then