jdk/test/sun/security/tools/jarsigner/passtype.sh
author vinnie
Tue, 23 Dec 2014 16:30:57 +0000
changeset 28243 47080f9ae750
parent 24116 9f9b4ba34aad
permissions -rw-r--r--
8044445: JEP 229: Create PKCS12 Keystores by Default Reviewed-by: mullan, weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3951
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
     1
#
28243
47080f9ae750 8044445: JEP 229: Create PKCS12 Keystores by Default
vinnie
parents: 24116
diff changeset
     2
# Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
3951
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
     3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
     4
#
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
     5
# This code is free software; you can redistribute it and/or modify it
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
     6
# under the terms of the GNU General Public License version 2 only, as
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
     7
# published by the Free Software Foundation.
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
     8
#
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
     9
# This code is distributed in the hope that it will be useful, but WITHOUT
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    10
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    11
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    12
# version 2 for more details (a copy is included in the LICENSE file that
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    13
# accompanied this code).
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    14
#
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    15
# You should have received a copy of the GNU General Public License version
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    16
# 2 along with this work; if not, write to the Free Software Foundation,
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    17
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    18
#
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3951
diff changeset
    19
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3951
diff changeset
    20
# or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3951
diff changeset
    21
# questions.
3951
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    22
#
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    23
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    24
# @test
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    25
# @bug 6868579
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    26
# @summary RFE: jarsigner to support reading password from environment variable
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    27
#
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    28
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    29
if [ "${TESTJAVA}" = "" ] ; then
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    30
  JAVAC_CMD=`which javac`
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    31
  TESTJAVA=`dirname $JAVAC_CMD`/..
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    32
fi
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    33
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    34
# set platform-dependent variables
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    35
OS=`uname -s`
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    36
case "$OS" in
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    37
  Windows_* )
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    38
    FS="\\"
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    39
    ;;
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    40
  * )
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    41
    FS="/"
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    42
    ;;
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    43
esac
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    44
28243
47080f9ae750 8044445: JEP 229: Create PKCS12 Keystores by Default
vinnie
parents: 24116
diff changeset
    45
KS=pt.ks
3951
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    46
JFILE=pt.jar
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    47
24116
9f9b4ba34aad 8040321: keytool and jarsigner tests doesn't pass though VM tools to tools
weijun
parents: 23010
diff changeset
    48
KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -keystore $KS -validity 300 -keyalg rsa"
9f9b4ba34aad 8040321: keytool and jarsigner tests doesn't pass though VM tools to tools
weijun
parents: 23010
diff changeset
    49
JAR="$TESTJAVA${FS}bin${FS}jar ${TESTTOOLVMOPTS}"
9f9b4ba34aad 8040321: keytool and jarsigner tests doesn't pass though VM tools to tools
weijun
parents: 23010
diff changeset
    50
JARSIGNER="$TESTJAVA${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS}"
3951
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    51
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    52
rm $KS $JFILE
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    53
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    54
$KT -alias a -dname CN=a -keyalg rsa -genkey \
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    55
        -storepass test12 -keypass test12 || exit 1
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    56
PASSENV=test12 $KT -alias b -dname CN=b -keyalg rsa -genkey \
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    57
        -storepass:env PASSENV -keypass:env PASSENV || exit 2
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    58
echo test12 > passfile
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    59
$KT -alias c -dname CN=c -keyalg rsa -genkey \
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    60
        -storepass:file passfile -keypass:file passfile || exit 3
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    61
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    62
echo A > A
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    63
$JAR cvf $JFILE A
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    64
28243
47080f9ae750 8044445: JEP 229: Create PKCS12 Keystores by Default
vinnie
parents: 24116
diff changeset
    65
# Sign
3951
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    66
$JARSIGNER -keystore $KS -storepass test12 $JFILE a || exit 4
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    67
PASSENV=test12 $JARSIGNER -keystore $KS -storepass:env PASSENV $JFILE b || exit 5
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    68
$JARSIGNER -keystore $KS -storepass:file passfile $JFILE b || exit 6
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    69
28243
47080f9ae750 8044445: JEP 229: Create PKCS12 Keystores by Default
vinnie
parents: 24116
diff changeset
    70
# Verify
47080f9ae750 8044445: JEP 229: Create PKCS12 Keystores by Default
vinnie
parents: 24116
diff changeset
    71
$JARSIGNER -keystore $KS -storepass test12 -verify -debug -strict $JFILE || exit 7
47080f9ae750 8044445: JEP 229: Create PKCS12 Keystores by Default
vinnie
parents: 24116
diff changeset
    72
PASSENV=test12 $JARSIGNER -keystore $KS -storepass:env PASSENV -verify -debug -strict $JFILE || exit 8
47080f9ae750 8044445: JEP 229: Create PKCS12 Keystores by Default
vinnie
parents: 24116
diff changeset
    73
$JARSIGNER -keystore $KS -storepass:file passfile -verify -debug -strict $JFILE || exit 9
3951
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    74
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    75
exit 0
e821908c953e 6868579: RFE: jarsigner to support reading password from environment variable
weijun
parents:
diff changeset
    76