8133085: Avoid creating instances of security providers when possible

Reviewed-by: mullan
This commit is contained in:
Bhanu Prakash Gopularam 2016-01-20 09:21:57 -08:00
parent 186957fd7f
commit 298315e8f8
3 changed files with 5 additions and 11 deletions

View File

@ -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();

View File

@ -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"),

View File

@ -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());