--- a/jdk/test/sun/security/pkcs11/sslecc/CipherTest.java Tue Jan 26 09:25:53 2016 +0000
+++ b/jdk/test/sun/security/pkcs11/sslecc/CipherTest.java Tue Jan 26 13:32:07 2016 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -47,7 +47,8 @@
// use any available port for the server socket
static volatile int serverPort = 0;
- final int THREADS;
+ static final int THREADS = Integer.getInteger("numThreads", 4);
+ static final String TEST_SRC = System.getProperty("test.src", ".");
// assume that if we do not read anything for 20 seconds, something
// has gone wrong
@@ -68,6 +69,7 @@
this.cipherTest = cipherTest;
}
+ @Override
public abstract void run();
void handleRequest(InputStream in, OutputStream out) throws IOException {
@@ -117,6 +119,7 @@
return TLSCipherStatus.isEnabled(cipherSuite, protocol);
}
+ @Override
public String toString() {
String s = cipherSuite + " in " + protocol + " mode";
if (clientAuth != null) {
@@ -260,7 +263,6 @@
private boolean failed;
private CipherTest(PeerFactory peerFactory) throws IOException {
- THREADS = Integer.parseInt(System.getProperty("numThreads", "4"));
factory = (SSLSocketFactory)SSLSocketFactory.getDefault();
SSLSocket socket = (SSLSocket)factory.createSocket();
String[] cipherSuites = socket.getSupportedCipherSuites();
@@ -350,6 +352,7 @@
this.cipherTest = cipherTest;
}
+ @Override
public final void run() {
while (true) {
TestParameters params = cipherTest.getTest();
@@ -405,10 +408,11 @@
private static KeyStore readKeyStore(String name) throws Exception {
File file = new File(PATH, name);
- InputStream in = new FileInputStream(file);
- KeyStore ks = KeyStore.getInstance("JKS");
- ks.load(in, passwd);
- in.close();
+ KeyStore ks;
+ try (InputStream in = new FileInputStream(file)) {
+ ks = KeyStore.getInstance("JKS");
+ ks.load(in, passwd);
+ }
return ks;
}
@@ -421,7 +425,7 @@
} else {
relPath = pathToStores;
}
- PATH = new File(System.getProperty("test.src", "."), relPath);
+ PATH = new File(TEST_SRC, relPath);
CipherTest.peerFactory = peerFactory;
System.out.print(
"Initializing test '" + peerFactory.getName() + "'...");
@@ -494,16 +498,19 @@
}
+ @Override
public void checkClientTrusted(X509Certificate[] chain, String authType)
throws CertificateException {
// empty
}
+ @Override
public void checkServerTrusted(X509Certificate[] chain, String authType)
throws CertificateException {
// empty
}
+ @Override
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[0];
}
@@ -522,6 +529,7 @@
this.authType = "ECDSA".equals(authType) ? "EC" : authType;
}
+ @Override
public String[] getClientAliases(String keyType, Principal[] issuers) {
if (authType == null) {
return null;
@@ -529,6 +537,7 @@
return keyManager.getClientAliases(authType, issuers);
}
+ @Override
public String chooseClientAlias(String[] keyType, Principal[] issuers,
Socket socket) {
if (authType == null) {
@@ -538,6 +547,7 @@
issuers, socket);
}
+ @Override
public String chooseEngineClientAlias(String[] keyType,
Principal[] issuers, SSLEngine engine) {
if (authType == null) {
@@ -547,24 +557,29 @@
issuers, engine);
}
+ @Override
public String[] getServerAliases(String keyType, Principal[] issuers) {
throw new UnsupportedOperationException("Servers not supported");
}
+ @Override
public String chooseServerAlias(String keyType, Principal[] issuers,
Socket socket) {
throw new UnsupportedOperationException("Servers not supported");
}
+ @Override
public String chooseEngineServerAlias(String keyType, Principal[] issuers,
SSLEngine engine) {
throw new UnsupportedOperationException("Servers not supported");
}
+ @Override
public X509Certificate[] getCertificateChain(String alias) {
return keyManager.getCertificateChain(alias);
}
+ @Override
public PrivateKey getPrivateKey(String alias) {
return keyManager.getPrivateKey(alias);
}
@@ -577,6 +592,7 @@
private final static ThreadFactory DEFAULT = Executors.defaultThreadFactory();
+ @Override
public Thread newThread(Runnable r) {
Thread t = DEFAULT.newThread(r);
t.setDaemon(true);