From 298315e8f8d4d5f219df4f7d22ce8c90c5f8a9de Mon Sep 17 00:00:00 2001 From: Bhanu Prakash Gopularam Date: Wed, 20 Jan 2016 09:21:57 -0800 Subject: [PATCH] 8133085: Avoid creating instances of security providers when possible Reviewed-by: mullan --- .../com/sun/crypto/provider/Cipher/DES/PerformanceTest.java | 5 +---- jdk/test/javax/net/ssl/TLS/TestJSSE.java | 6 +----- jdk/test/sun/security/pkcs11/fips/ImportKeyStore.java | 5 +++-- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/jdk/test/com/sun/crypto/provider/Cipher/DES/PerformanceTest.java b/jdk/test/com/sun/crypto/provider/Cipher/DES/PerformanceTest.java index 7e3d860d28a..03468133ff1 100644 --- a/jdk/test/com/sun/crypto/provider/Cipher/DES/PerformanceTest.java +++ b/jdk/test/com/sun/crypto/provider/Cipher/DES/PerformanceTest.java @@ -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.security.spec.*; import java.io.*; import javax.crypto.*; import javax.crypto.spec.*; -import com.sun.crypto.provider.*; public class PerformanceTest { @@ -81,8 +80,6 @@ public class PerformanceTest { byte[] in; - SunJCE jce = new SunJCE(); - Security.addProvider(jce); col = new StringBuffer(); printHeadings(); diff --git a/jdk/test/javax/net/ssl/TLS/TestJSSE.java b/jdk/test/javax/net/ssl/TLS/TestJSSE.java index b7a439f8820..d4c41480c0b 100644 --- a/jdk/test/javax/net/ssl/TLS/TestJSSE.java +++ b/jdk/test/javax/net/ssl/TLS/TestJSSE.java @@ -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 @@ public class TestJSSE { 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 @@ public class TestJSSE { 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"), diff --git a/jdk/test/sun/security/pkcs11/fips/ImportKeyStore.java b/jdk/test/sun/security/pkcs11/fips/ImportKeyStore.java index 774db222eb9..302df9280e6 100644 --- a/jdk/test/sun/security/pkcs11/fips/ImportKeyStore.java +++ b/jdk/test/sun/security/pkcs11/fips/ImportKeyStore.java @@ -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 class ImportKeyStore { 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());