jdk/test/sun/security/pkcs11/Secmod/TrustAnchors.java
changeset 35379 1e8e336ef66b
parent 26958 cb5cbde6e7a4
child 40975 680639c9b307
--- a/jdk/test/sun/security/pkcs11/Secmod/TrustAnchors.java	Tue Jan 26 09:25:53 2016 +0000
+++ b/jdk/test/sun/security/pkcs11/Secmod/TrustAnchors.java	Tue Jan 26 13:32:07 2016 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -28,13 +28,17 @@
  * @author Andreas Sterbenz
  * @library ..
  * @run main/othervm TrustAnchors
+ * @run main/othervm TrustAnchors sm policy
  */
 
-import java.util.*;
-
-import java.security.*;
-import java.security.KeyStore.*;
-import java.security.cert.*;
+import java.io.File;
+import java.security.KeyStore;
+import java.security.Provider;
+import java.security.Security;
+import java.security.cert.X509Certificate;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.TreeSet;
 
 public class TrustAnchors extends SecmodTest {
 
@@ -57,9 +61,16 @@
 
         System.out.println(p);
         Security.addProvider(p);
+
+        if (args.length > 1 && "sm".equals(args[0])) {
+            System.setProperty("java.security.policy",
+                    BASE + File.separator + args[1]);
+            System.setSecurityManager(new SecurityManager());
+        }
+
         KeyStore ks = KeyStore.getInstance("PKCS11", p);
         ks.load(null, null);
-        Collection<String> aliases = new TreeSet<String>(Collections.list(ks.aliases()));
+        Collection<String> aliases = new TreeSet<>(Collections.list(ks.aliases()));
         System.out.println("entries: " + aliases.size());
         System.out.println(aliases);