7196009: SunPkcs11 provider fails to parse config path containing parenthesis
Summary: Enhanced to allow quoted string as library path values.
Reviewed-by: weijun
--- a/jdk/src/share/classes/sun/security/pkcs11/Config.java Tue May 07 14:04:53 2013 -0700
+++ b/jdk/src/share/classes/sun/security/pkcs11/Config.java Tue May 07 14:06:19 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, 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
@@ -643,9 +643,7 @@
//
private String parseLibrary(String keyword) throws IOException {
- checkDup(keyword);
- parseEquals();
- String lib = parseLine();
+ String lib = parseStringEntry(keyword);
lib = expand(lib);
int i = lib.indexOf("/$ISA/");
if (i != -1) {
--- a/jdk/test/sun/security/pkcs11/Provider/ConfigShortPath.java Tue May 07 14:04:53 2013 -0700
+++ b/jdk/test/sun/security/pkcs11/Provider/ConfigShortPath.java Tue May 07 14:06:19 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2013, 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
@@ -22,8 +22,8 @@
*/
/**
* @test
- * @bug 6581254 6986789
- * @summary Allow '~' and '+' in config file
+ * @bug 6581254 6986789 7196009
+ * @summary Allow '~', '+' and quoted paths in config file
* @author Valerie Peng
*/
@@ -33,7 +33,9 @@
public class ConfigShortPath {
- private static final String[] configNames = { "csp.cfg", "cspPlus.cfg" };
+ private static final String[] configNames = {
+ "csp.cfg", "cspPlus.cfg", "cspQuotedPath.cfg"
+ };
public static void main(String[] args) throws Exception {
Constructor cons = null;
@@ -53,12 +55,22 @@
Object obj = cons.newInstance(configFile);
} catch (InvocationTargetException ite) {
Throwable cause = ite.getCause();
+ System.out.println(cause);
if (cause instanceof ProviderException) {
- String causeMsg = cause.getCause().getMessage();
- // Indicate failure if due to parsing config
- if (causeMsg.indexOf("Unexpected token") != -1) {
- throw (ProviderException) cause;
+ while ((cause = cause.getCause()) != null) {
+ System.out.println(cause);
+ String causeMsg = cause.getMessage();
+ // Indicate failure if due to parsing config
+ if (causeMsg.indexOf("Unexpected") != -1) {
+ throw (ProviderException) cause;
+ }
}
+ // Consider the test passes if the exception is
+ // thrown after parsing, i.e. due to the absolute
+ // path requirement or the non-existent path.
+ } else {
+ // unexpected exception
+ throw new RuntimeException("Unexpected Exception", cause);
}
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/pkcs11/Provider/cspQuotedPath.cfg Tue May 07 14:06:19 2013 -0700
@@ -0,0 +1,6 @@
+showInfo = false
+name=GemPlusPKCS11
+library="C:\\Program Files (x86)\\Gemalto\\Classic Client\\BIN\\gclib.dll"
+attributes(*,CKO_PRIVATE_KEY,*) = {
+ CKA_SIGN = true
+}