Author: rjung
Date: Sun Aug 13 10:51:06 2017
New Revision: 1804890
URL: http://svn.apache.org/viewvc?rev=1804890&view=rev
Log:
- Use constants for test certificate file paths,
aliases and passwords.
- Change TesterSupport.initSsl() to use full
path names.
Modified:
tomcat/trunk/test/org/apache/tomcat/util/net/TestCustomSsl.java
tomcat/trunk/test/org/apache/tomcat/util/net/TestSsl.java
tomcat/trunk/test/org/apache/tomcat/util/net/TesterSupport.java
tomcat/trunk/test/org/apache/tomcat/websocket/TestWebSocketFrameClientSSL.java
tomcat/trunk/test/org/apache/tomcat/websocket/TestWsWebSocketContainer.java
Modified: tomcat/trunk/test/org/apache/tomcat/util/net/TestCustomSsl.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/tomcat/util/net/TestCustomSsl.java?rev=1804890&r1=1804889&r2=1804890&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/tomcat/util/net/TestCustomSsl.java (original)
+++ tomcat/trunk/test/org/apache/tomcat/util/net/TestCustomSsl.java Sun Aug 13
10:51:06 2017
@@ -67,7 +67,7 @@ public class TestCustomSsl extends Tomca
connector.setProperty("sslProtocol", "tls");
File keystoreFile =
- new File("test/org/apache/tomcat/util/net/localhost.jks");
+ new File(TesterSupport.LOCALHOST_JKS);
connector.setAttribute(
"keystoreFile", keystoreFile.getAbsolutePath());
Modified: tomcat/trunk/test/org/apache/tomcat/util/net/TestSsl.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/tomcat/util/net/TestSsl.java?rev=1804890&r1=1804889&r2=1804890&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/tomcat/util/net/TestSsl.java (original)
+++ tomcat/trunk/test/org/apache/tomcat/util/net/TestSsl.java Sun Aug 13
10:51:06 2017
@@ -80,8 +80,8 @@ public class TestSsl extends TomcatBaseT
null, "/examples", appDir.getAbsolutePath());
ctxt.addApplicationListener(WsContextListener.class.getName());
- TesterSupport.initSsl(tomcat, "localhost-copy1.jks", "changeit",
- "tomcatpass");
+ TesterSupport.initSsl(tomcat, TesterSupport.LOCALHOST_KEYPASS_JKS,
+ TesterSupport.JKS_PASS, TesterSupport.JKS_KEY_PASS);
tomcat.start();
ByteChunk res = getUrl("https://localhost:" + getPort() +
Modified: tomcat/trunk/test/org/apache/tomcat/util/net/TesterSupport.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/tomcat/util/net/TesterSupport.java?rev=1804890&r1=1804889&r2=1804890&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/tomcat/util/net/TesterSupport.java (original)
+++ tomcat/trunk/test/org/apache/tomcat/util/net/TesterSupport.java Sun Aug 13
10:51:06 2017
@@ -48,10 +48,22 @@ import org.apache.tomcat.util.descriptor
public final class TesterSupport {
+ public static final String SSL_DIR = "test/org/apache/tomcat/util/net/";
+ public static final String CA_ALIAS = "ca";
+ public static final String CA_JKS = SSL_DIR + CA_ALIAS + ".jks";
+ public static final String CLIENT_ALIAS = "user1";
+ public static final String CLIENT_JKS = SSL_DIR + CLIENT_ALIAS + ".jks";
+ public static final String LOCALHOST_JKS = SSL_DIR + "localhost.jks";
+ public static final String LOCALHOST_KEYPASS_JKS = SSL_DIR +
"localhost-copy1.jks";
+ public static final String JKS_PASS = "changeit";
+ public static final String JKS_KEY_PASS = "tomcatpass";
+ public static final String LOCALHOST_CERT_PEM = SSL_DIR +
"localhost-cert.pem";
+ public static final String LOCALHOST_KEY_PEM = SSL_DIR +
"localhost-key.pem";
+
public static final String ROLE = "testrole";
public static void initSsl(Tomcat tomcat) {
- initSsl(tomcat, "localhost.jks", null, null);
+ initSsl(tomcat, LOCALHOST_JKS, null, null);
}
protected static void initSsl(Tomcat tomcat, String keystore,
@@ -70,11 +82,10 @@ public final class TesterSupport {
}
connector.setProperty("sslProtocol", "tls");
File keystoreFile =
- new File("test/org/apache/tomcat/util/net/" + keystore);
+ new File(keystore);
connector.setAttribute("keystoreFile",
keystoreFile.getAbsolutePath());
- File truststoreFile = new File(
- "test/org/apache/tomcat/util/net/ca.jks");
+ File truststoreFile = new File(CA_JKS);
connector.setAttribute("truststoreFile",
truststoreFile.getAbsolutePath());
if (keystorePass != null) {
@@ -85,11 +96,11 @@ public final class TesterSupport {
}
} else {
File keystoreFile = new File(
- "test/org/apache/tomcat/util/net/localhost-cert.pem");
+ LOCALHOST_CERT_PEM);
tomcat.getConnector().setAttribute("SSLCertificateFile",
keystoreFile.getAbsolutePath());
keystoreFile = new File(
- "test/org/apache/tomcat/util/net/localhost-key.pem");
+ LOCALHOST_KEY_PEM);
tomcat.getConnector().setAttribute("SSLCertificateKeyFile",
keystoreFile.getAbsolutePath());
}
@@ -100,15 +111,14 @@ public final class TesterSupport {
protected static KeyManager[] getUser1KeyManagers() throws Exception {
KeyManagerFactory kmf = KeyManagerFactory.getInstance(
KeyManagerFactory.getDefaultAlgorithm());
- kmf.init(getKeyStore("test/org/apache/tomcat/util/net/user1.jks"),
- "changeit".toCharArray());
+ kmf.init(getKeyStore(CLIENT_JKS), JKS_PASS.toCharArray());
return kmf.getKeyManagers();
}
protected static TrustManager[] getTrustManagers() throws Exception {
TrustManagerFactory tmf = TrustManagerFactory.getInstance(
TrustManagerFactory.getDefaultAlgorithm());
- tmf.init(getKeyStore("test/org/apache/tomcat/util/net/ca.jks"));
+ tmf.init(getKeyStore(CA_JKS));
return tmf.getTrustManagers();
}
@@ -129,7 +139,7 @@ public final class TesterSupport {
File keystoreFile = new File(keystore);
KeyStore ks = KeyStore.getInstance("JKS");
try (InputStream is = new FileInputStream(keystoreFile)) {
- ks.load(is, "changeit".toCharArray());
+ ks.load(is, JKS_PASS.toCharArray());
}
return ks;
}
Modified:
tomcat/trunk/test/org/apache/tomcat/websocket/TestWebSocketFrameClientSSL.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/tomcat/websocket/TestWebSocketFrameClientSSL.java?rev=1804890&r1=1804889&r2=1804890&view=diff
==============================================================================
---
tomcat/trunk/test/org/apache/tomcat/websocket/TestWebSocketFrameClientSSL.java
(original)
+++
tomcat/trunk/test/org/apache/tomcat/websocket/TestWebSocketFrameClientSSL.java
Sun Aug 13 10:51:06 2017
@@ -59,7 +59,7 @@ public class TestWebSocketFrameClientSSL
ClientEndpointConfig.Builder.create().build();
clientEndpointConfig.getUserProperties().put(
Constants.SSL_TRUSTSTORE_PROPERTY,
- "test/org/apache/tomcat/util/net/ca.jks");
+ TesterSupport.CA_JKS);
Session wsSession = wsContainer.connectToServer(
TesterProgrammaticEndpoint.class,
clientEndpointConfig,
@@ -106,7 +106,7 @@ public class TestWebSocketFrameClientSSL
ClientEndpointConfig.Builder.create().build();
clientEndpointConfig.getUserProperties().put(
Constants.SSL_TRUSTSTORE_PROPERTY,
- "test/org/apache/tomcat/util/net/ca.jks");
+ TesterSupport.CA_JKS);
Session wsSession = wsContainer.connectToServer(
TesterProgrammaticEndpoint.class,
clientEndpointConfig,
Modified:
tomcat/trunk/test/org/apache/tomcat/websocket/TestWsWebSocketContainer.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/tomcat/websocket/TestWsWebSocketContainer.java?rev=1804890&r1=1804889&r2=1804890&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/tomcat/websocket/TestWsWebSocketContainer.java
(original)
+++ tomcat/trunk/test/org/apache/tomcat/websocket/TestWsWebSocketContainer.java
Sun Aug 13 10:51:06 2017
@@ -835,7 +835,7 @@ public class TestWsWebSocketContainer ex
ClientEndpointConfig.Builder.create().build();
clientEndpointConfig.getUserProperties().put(
org.apache.tomcat.websocket.Constants.SSL_TRUSTSTORE_PROPERTY,
- "test/org/apache/tomcat/util/net/ca.jks");
+ TesterSupport.CA_JKS);
Session wsSession = wsContainer.connectToServer(
TesterProgrammaticEndpoint.class,
clientEndpointConfig,
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]