Author: veithen
Date: Sat Jan 14 17:39:22 2017
New Revision: 1778805
URL: http://svn.apache.org/viewvc?rev=1778805&view=rev
Log:
Let JettyServer configure the system properties for the client trust store.
Modified:
axis/axis2/java/rampart/trunk/modules/rampart-integration/src/main/java/org/apache/axis2/integration/JettyServer.java
axis/axis2/java/rampart/trunk/modules/rampart-integration/src/test/java/org/apache/rampart/RampartTest.java
Modified:
axis/axis2/java/rampart/trunk/modules/rampart-integration/src/main/java/org/apache/axis2/integration/JettyServer.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/rampart/trunk/modules/rampart-integration/src/main/java/org/apache/axis2/integration/JettyServer.java?rev=1778805&r1=1778804&r2=1778805&view=diff
==============================================================================
---
axis/axis2/java/rampart/trunk/modules/rampart-integration/src/main/java/org/apache/axis2/integration/JettyServer.java
(original)
+++
axis/axis2/java/rampart/trunk/modules/rampart-integration/src/main/java/org/apache/axis2/integration/JettyServer.java
Sat Jan 14 17:39:22 2017
@@ -38,37 +38,37 @@ public class JettyServer extends Externa
/**
* Keystore to configure for Jetty's ssl context factory: {@value}
*/
- public static final String KEYSTORE =
"target/test-resources/jetty/server.jks";
+ private static final String KEYSTORE =
"target/test-resources/jetty/server.jks";
/**
* Keymanager password to configure for Jetty's ssl context factory:
{@value
*/
- public static final String KEYMAN_PASSWORD = "password";
+ private static final String KEYMAN_PASSWORD = "password";
/**
* Keystore password to configure for Jetty's ssl context factory:
{@value}
*/
- public static final String KEYSTORE_PASSWORD = "password";
+ private static final String KEYSTORE_PASSWORD = "password";
/**
* The alias of the certificate to configure for Jetty's ssl context
factory: {@value}
*/
- public static final String CERT_ALIAS = "server";
+ private static final String CERT_ALIAS = "server";
/**
* Client keystore containing Jetty's server certificate as trusted
certificate entry: : {@value}
*/
- public static final String CLIENT_KEYSTORE =
"target/test-resources/jetty/client.jks";
+ private static final String CLIENT_KEYSTORE =
"target/test-resources/jetty/client.jks";
/**
* Axis2 configuration file to use: {@value}
*/
- public static final String AXIS2_XML = "src/test/resources/conf/axis2.xml";
+ private static final String AXIS2_XML =
"src/test/resources/conf/axis2.xml";
/**
* Webapp resource base directory to use: {@value}
*/
- public static final String WEBAPP_DIR = "target" + File.separator +
"webapp";
+ private static final String WEBAPP_DIR = "target" + File.separator +
"webapp";
private static final Logger logger =
LoggerFactory.getLogger(JettyServer.class);
@@ -76,6 +76,10 @@ public class JettyServer extends Externa
private final int httpPort;
private final int httpsPort;
private Server server;
+ private boolean systemPropertiesSet;
+ private String savedTrustStore;
+ private String savedTrustStorePassword;
+ private String savedTrustStoreType;
/**
* Constructor.
@@ -142,6 +146,14 @@ public class JettyServer extends Externa
if (connector != null) {
connector.setConfidentialPort(httpsPort);
}
+
+ savedTrustStore = System.getProperty("javax.net.ssl.trustStore");
+ System.setProperty("javax.net.ssl.trustStore", CLIENT_KEYSTORE);
+ savedTrustStorePassword =
System.getProperty("javax.net.ssl.trustStorePassword");
+ System.setProperty("javax.net.ssl.trustStorePassword",
KEYSTORE_PASSWORD);
+ savedTrustStoreType =
System.getProperty("javax.net.ssl.trustStoreType");
+ System.setProperty("javax.net.ssl.trustStoreType", "JKS");
+ systemPropertiesSet = true;
}
WebAppContext context = new WebAppContext();
@@ -192,6 +204,27 @@ public class JettyServer extends Externa
}
server = null;
}
+ if (systemPropertiesSet) {
+ if (savedTrustStore != null) {
+ System.setProperty("javax.net.ssl.trustStore",
savedTrustStore);
+ } else {
+ System.clearProperty("javax.net.ssl.trustStore");
+ }
+ if (savedTrustStorePassword != null) {
+ System.setProperty("javax.net.ssl.trustStorePassword",
savedTrustStorePassword);
+ } else {
+ System.clearProperty("javax.net.ssl.trustStorePassword");
+ }
+ if (savedTrustStoreType != null) {
+ System.setProperty("javax.net.ssl.trustStoreType",
savedTrustStoreType);
+ } else {
+ System.clearProperty("javax.net.ssl.trustStoreType");
+ }
+ savedTrustStore = null;
+ savedTrustStorePassword = null;
+ savedTrustStoreType = null;
+ systemPropertiesSet = false;
+ }
}
/**
Modified:
axis/axis2/java/rampart/trunk/modules/rampart-integration/src/test/java/org/apache/rampart/RampartTest.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/rampart/trunk/modules/rampart-integration/src/test/java/org/apache/rampart/RampartTest.java?rev=1778805&r1=1778804&r2=1778805&view=diff
==============================================================================
---
axis/axis2/java/rampart/trunk/modules/rampart-integration/src/test/java/org/apache/rampart/RampartTest.java
(original)
+++
axis/axis2/java/rampart/trunk/modules/rampart-integration/src/test/java/org/apache/rampart/RampartTest.java
Sat Jan 14 17:39:22 2017
@@ -16,8 +16,6 @@
package org.apache.rampart;
-import static org.apache.axis2.integration.JettyServer.CLIENT_KEYSTORE;
-import static org.apache.axis2.integration.JettyServer.KEYSTORE_PASSWORD;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
@@ -38,15 +36,12 @@ import org.apache.axis2.context.ServiceC
import org.apache.axis2.integration.JettyServer;
import org.apache.neethi.Policy;
import org.apache.neethi.PolicyEngine;
-import org.junit.After;
-import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
-
public class RampartTest {
private static ResourceBundle resources;
@@ -54,9 +49,6 @@ public class RampartTest {
@Rule
public final JettyServer server = new JettyServer(Constants.TESTING_PATH +
"rampart_service_repo", 0, 0);
- private String trustStore;
- private String trustStorePassword;
- private String trustStoreType;
static {
try {
@@ -66,43 +58,6 @@ public class RampartTest {
}
}
- @Before
- public void setUp() throws Exception {
- trustStore = System.getProperty("javax.net.ssl.trustStore");
- System.setProperty("javax.net.ssl.trustStore", CLIENT_KEYSTORE);
-
- trustStorePassword =
System.getProperty("javax.net.ssl.trustStorePassword");
- System.setProperty("javax.net.ssl.trustStorePassword",
KEYSTORE_PASSWORD);
-
- trustStoreType = System.getProperty("javax.net.ssl.trustStoreType");
- System.setProperty("javax.net.ssl.trustStoreType", "JKS");
- }
-
-
- @After
- public void tearDown() throws Exception {
- if (trustStore != null) {
- System.setProperty("javax.net.ssl.trustStore", trustStore);
- }
- else {
- System.clearProperty("javax.net.ssl.trustStore");
- }
-
- if (trustStorePassword != null) {
- System.setProperty("javax.net.ssl.trustStorePassword",
trustStorePassword);
- }
- else {
- System.clearProperty("javax.net.ssl.trustStorePassword");
- }
-
- if (trustStoreType != null) {
- System.setProperty("javax.net.ssl.trustStoreType", trustStoreType);
- }
- else {
- System.clearProperty("javax.net.ssl.trustStoreType");
- }
- }
-
private ServiceClient getServiceClientInstance() throws AxisFault {
String repository = Constants.TESTING_PATH + "rampart_client_repo";