8133085: Avoid creating instances of security providers when possible
authorbgopularam
Wed, 20 Jan 2016 09:21:57 -0800
changeset 35301 12dabfdd1997
parent 35300 30eaec7fded0
child 35302 e4d2275861c3
8133085: Avoid creating instances of security providers when possible Reviewed-by: mullan
jdk/test/com/sun/crypto/provider/Cipher/DES/PerformanceTest.java
jdk/test/javax/net/ssl/TLS/TestJSSE.java
jdk/test/sun/security/pkcs11/fips/ImportKeyStore.java
--- a/jdk/test/com/sun/crypto/provider/Cipher/DES/PerformanceTest.java	Wed Jan 20 08:33:40 2016 -0800
+++ b/jdk/test/com/sun/crypto/provider/Cipher/DES/PerformanceTest.java	Wed Jan 20 09:21:57 2016 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -33,7 +33,6 @@
 import java.io.*;
 import javax.crypto.*;
 import javax.crypto.spec.*;
-import com.sun.crypto.provider.*;
 
 public class PerformanceTest {
 
@@ -81,8 +80,6 @@
 
         byte[] in;
 
-        SunJCE jce = new SunJCE();
-        Security.addProvider(jce);
         col = new StringBuffer();
 
         printHeadings();
--- a/jdk/test/javax/net/ssl/TLS/TestJSSE.java	Wed Jan 20 08:33:40 2016 -0800
+++ b/jdk/test/javax/net/ssl/TLS/TestJSSE.java	Wed Jan 20 09:21:57 2016 -0800
@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -111,8 +111,6 @@
         out.println(" Testing - https://" + LOCAL_IP + ":" + testPort);
         out.println(" Testing - Protocol : " + testProtocols);
         out.println(" Testing - Cipher : " + testCipher);
-        Provider p = new sun.security.ec.SunEC();
-        Security.insertProviderAt(p, 1);
         try {
             CipherTestUtils.main(new JSSEFactory(LOCAL_IP,
                     testPort, testProtocols,
@@ -132,8 +130,6 @@
         out.println(" Testing Protocol: " + testProtocol);
         out.println(" Testing Cipher: " + testCipher);
         out.println(" Testing Port: " + testPort);
-        Provider p = new sun.security.ec.SunEC();
-        Security.insertProviderAt(p, 1);
         try {
             CipherTestUtils.main(new JSSEFactory(null, testPort,
                     testProtocol, testCipher, "Server JSSE"),
--- a/jdk/test/sun/security/pkcs11/fips/ImportKeyStore.java	Wed Jan 20 08:33:40 2016 -0800
+++ b/jdk/test/sun/security/pkcs11/fips/ImportKeyStore.java	Wed Jan 20 09:21:57 2016 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -48,7 +48,8 @@
     public static void main(String[] args) throws Exception {
         String nssCfg = "--name=NSS\nnssSecmodDirectory=.\n ";
 //          "attributes(*,CKO_PRIVATE_KEY,CKK_DSA) = { CKA_NETSCAPE_DB = 0h00 }";
-        Provider p = new sun.security.pkcs11.SunPKCS11(nssCfg);
+        Provider p = Security.getProvider("SunPKCS11");
+        p.configure(nssCfg);
 
         KeyStore ks = KeyStore.getInstance("PKCS11", p);
         ks.load(null, "test12".toCharArray());