changeset 39559:0bd60e219fd0

Merge
author prr
date Fri, 08 Jul 2016 10:41:12 -0700
parents a632fc3f7c3a b0c063e32440
children e6ec33bddfcc 4da8463b3d33 9b585e2c52de
files jdk/test/sun/security/mscapi/SignUsingNONEwithRSA.sh
diffstat 5 files changed, 97 insertions(+), 102 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/src/java.security.jgss/share/classes/sun/security/krb5/Config.java	Fri Jul 08 09:30:13 2016 -0700
+++ b/jdk/src/java.security.jgss/share/classes/sun/security/krb5/Config.java	Fri Jul 08 10:41:12 2016 -0700
@@ -562,7 +562,7 @@
         boolean inDirectives = true;
         for (String line: lines) {
             line = line.trim();
-            if (line.isEmpty() || line.startsWith("#")) {
+            if (line.isEmpty() || line.startsWith("#") || line.startsWith(";")) {
                 continue;
             }
             if (inDirectives) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/krb5/config/Semicolon.java	Fri Jul 08 10:41:12 2016 -0700
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8160518
+ * @summary Semicolon is not recognized as comment starting character
+ * @modules java.security.jgss/sun.security.krb5
+ * @run main/othervm Semicolon
+ */
+
+import sun.security.krb5.Config;
+
+public class Semicolon {
+    public static void main(String[] args) throws Throwable {
+        System.setProperty("java.security.krb5.conf",
+                System.getProperty("test.src", ".") + "/comments.conf");
+        Config config = Config.getInstance();
+        config.getBooleanObject("section", "value");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/krb5/config/comments.conf	Fri Jul 08 10:41:12 2016 -0700
@@ -0,0 +1,12 @@
+[section]
+
+#           comment
+ #          comment
+	 #  comment
+ 	#   comment
+;           comment
+ ;          comment
+	 ;  comment
+ 	;   comment
+
+value = true
--- a/jdk/test/sun/security/mscapi/SignUsingNONEwithRSA.java	Fri Jul 08 09:30:13 2016 -0700
+++ b/jdk/test/sun/security/mscapi/SignUsingNONEwithRSA.java	Fri Jul 08 10:41:12 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. 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
@@ -21,12 +21,21 @@
  * questions.
  */
 
-/**
- * @see SignUsingNONEwithRSA.sh
+ /*
+ * @test
+ * @bug 6578658
+ * @modules java.base/sun.security.x509
+ *          java.base/sun.security.tools.keytool
+ * @requires os.family == "windows"
+ * @summary Sign using the NONEwithRSA signature algorithm from SunMSCAPI
  */
 
 import java.security.*;
+import java.security.cert.X509Certificate;
+import java.security.interfaces.RSAPrivateCrtKey;
 import java.util.*;
+import sun.security.tools.keytool.CertAndKeyGen;
+import sun.security.x509.X500Name;
 
 public class SignUsingNONEwithRSA {
 
@@ -92,24 +101,42 @@
                 System.out.println("    " + provider.getName());
             }
         }
-        System.out.println("-------------------------------------------------");
+        System.out.println(
+                "Creating a temporary RSA keypair in the Windows-My store");
+        KeyStore ks = KeyStore.getInstance("Windows-MY");
+        ks.load(null, null);
+        CertAndKeyGen ckg = new CertAndKeyGen("RSA", "SHA1withRSA");
+        ckg.generate(1024);
+        RSAPrivateCrtKey k = (RSAPrivateCrtKey) ckg.getPrivateKey();
+        ks.setKeyEntry("6578658", k, null, new X509Certificate[]{
+                    ckg.getSelfCertificate(new X500Name("cn=6578658,c=US"), 1000)
+                });
+        ks.store(null, null);
 
-        KeyPair keys = getKeysFromKeyStore();
-        signAllUsing("SunMSCAPI", keys.getPrivate());
-        System.out.println("-------------------------------------------------");
+        System.out.println("---------------------------------------------");
 
-        verifyAllUsing("SunMSCAPI", keys.getPublic());
-        System.out.println("-------------------------------------------------");
+        try {
+            KeyPair keys = getKeysFromKeyStore();
+            signAllUsing("SunMSCAPI", keys.getPrivate());
+            System.out.println("---------------------------------------------");
 
-        verifyAllUsing("SunJCE", keys.getPublic());
-        System.out.println("-------------------------------------------------");
+            verifyAllUsing("SunMSCAPI", keys.getPublic());
+            System.out.println("---------------------------------------------");
 
-        keys = generateKeys();
-        signAllUsing("SunJCE", keys.getPrivate());
-        System.out.println("-------------------------------------------------");
+            verifyAllUsing("SunJCE", keys.getPublic());
+            System.out.println("---------------------------------------------");
 
-        verifyAllUsing("SunMSCAPI", keys.getPublic());
-        System.out.println("-------------------------------------------------");
+            keys = generateKeys();
+            signAllUsing("SunJCE", keys.getPrivate());
+            System.out.println("---------------------------------------------");
+
+            verifyAllUsing("SunMSCAPI", keys.getPublic());
+            System.out.println("---------------------------------------------");
+        } finally {
+            System.out.println(
+                    "Deleting temporary RSA keypair from Windows-My store");
+            ks.deleteEntry("6578658");
+        }
 
     }
 
--- a/jdk/test/sun/security/mscapi/SignUsingNONEwithRSA.sh	Fri Jul 08 09:30:13 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,85 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2011, 2015, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-
-# @test
-# @bug 6578658
-# @requires os.family == "windows"
-# @run shell SignUsingNONEwithRSA.sh
-# @summary Sign using the NONEwithRSA signature algorithm from SunMSCAPI
-# @key intermittent
-
-# 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
-
-OS=`uname -s`
-case "$OS" in
-    Windows* | CYGWIN* )
-
-        echo "Creating a temporary RSA keypair in the Windows-My store..."
-        ${TESTJAVA}/bin/keytool ${TESTTOOLVMOPTS} \
-	    -genkeypair \
-	    -storetype Windows-My \
-	    -keyalg RSA \
-	    -alias 6578658 \
-	    -dname "cn=6578658,c=US" \
-	    -noprompt
-
-        echo
-	echo "Running the test..."
-        ${TESTJAVA}/bin/javac ${TESTTOOLVMOPTS} ${TESTJAVACOPTS} -d . ${TESTSRC}\\SignUsingNONEwithRSA.java
-        ${TESTJAVA}/bin/java ${TESTVMOPTS} SignUsingNONEwithRSA
-
-        rc=$?
-
-        echo
-        echo "Removing the temporary RSA keypair from the Windows-My store..."
-        ${TESTJAVA}/bin/keytool ${TESTTOOLVMOPTS} \
-	    -delete \
-	    -storetype Windows-My \
-	    -alias 6578658
-
-	echo done.
-        exit $rc
-        ;;
-
-    * )
-        echo "This test is not intended for '$OS' - passing test"
-        exit 0
-        ;;
-esac