You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by ve...@apache.org on 2017/01/28 16:00:33 UTC
svn commit: r1780712 - in /axis/axis2/java/rampart/branches/RAMPART-423: ./
modules/rampart-integration/
modules/rampart-integration/src/main/java/org/apache/axis2/integration/
modules/rampart-integration/src/main/java/org/apache/rahas/
modules/rampart...
Author: veithen
Date: Sat Jan 28 16:00:33 2017
New Revision: 1780712
URL: http://svn.apache.org/viewvc?rev=1780712&view=rev
Log:
Merge latest changes from trunk.
Added:
axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/main/java/org/apache/axis2/integration/TestConstants.java
- copied unchanged from r1780711, axis/axis2/java/rampart/trunk/modules/rampart-integration/src/main/java/org/apache/axis2/integration/TestConstants.java
Modified:
axis/axis2/java/rampart/branches/RAMPART-423/ (props changed)
axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/pom.xml
axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/main/java/org/apache/axis2/integration/JettyServer.java
axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/main/java/org/apache/rahas/TestClient.java
axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAML2TokenCertForHoKTest.java
axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAML2TokenTest.java
axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAML2TokenUTForBearerTest.java
axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenAttributeTest.java
axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenCertForHoKTest.java
axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenCertForHoKV1205Test.java
axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenTest.java
axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenUTForBearerTest.java
axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenUTForBearerV1205Test.java
axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenUTForHoKTest.java
axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenUTForHoKV1205Test.java
axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenV1205Test.java
axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rampart/RampartTest.java
Propchange: axis/axis2/java/rampart/branches/RAMPART-423/
------------------------------------------------------------------------------
svn:mergeinfo = /axis/axis2/java/rampart/trunk:1778774-1780711
Modified: axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/pom.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/pom.xml?rev=1780712&r1=1780711&r2=1780712&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/pom.xml (original)
+++ axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/pom.xml Sat Jan 28 16:00:33 2017
@@ -85,6 +85,7 @@
</goals>
<configuration>
<modules>addressing,rampart,rahas</modules>
+ <axis2xml>src/test/resources/conf/axis2.xml</axis2xml>
<outputDirectory>target/test-resources/rampart_service_repo</outputDirectory>
</configuration>
</execution>
@@ -105,6 +106,7 @@
</goals>
<configuration>
<modules>addressing,rampart,rahas</modules>
+ <axis2xml>src/test/resources/conf/axis2.xml</axis2xml>
<outputDirectory>target/test-resources/rahas_service_repo_1</outputDirectory>
</configuration>
</execution>
@@ -115,6 +117,7 @@
</goals>
<configuration>
<modules>addressing,rampart,rahas</modules>
+ <axis2xml>src/test/resources/conf/axis2.xml</axis2xml>
<outputDirectory>target/test-resources/rahas_service_repo_3</outputDirectory>
</configuration>
</execution>
@@ -126,6 +129,7 @@
<configuration>
<modules>addressing,rampart</modules>
<axis2xml>src/test/resources/conf/axis2.xml</axis2xml>
+ <configurationDirectory>conf</configurationDirectory>
<outputDirectory>target/test-resources/default_security_client_repo</outputDirectory>
</configuration>
</execution>
@@ -136,13 +140,11 @@
</goals>
<configuration>
<modules>addressing,rampart,rahas</modules>
+ <axis2xml>src/test/resources/conf/axis2.xml</axis2xml>
<outputDirectory>target/test-resources/rahas_service_repo_5</outputDirectory>
</configuration>
</execution>
</executions>
- <configuration>
- <configurationDirectory>conf</configurationDirectory>
- </configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -368,83 +370,6 @@
</execution>
</executions>
</plugin>
- <plugin>
- <artifactId>maven-clean-plugin</artifactId>
- <executions>
- <execution>
- <!-- Need to clean the keystore because keytool-maven-plugin is not idempotent and fails
- when executing mvn install twice in a row. Note that keytool-maven-plugin also has
- a "clean" goal but we don't use it because it generates a warning if the keystore
- doesn't exist. -->
- <phase>generate-test-resources</phase>
- <goals>
- <goal>clean</goal>
- </goals>
- <configuration>
- <excludeDefaultDirectories>true</excludeDefaultDirectories>
- <filesets>
- <fileset>
- <directory>${project.build.directory}/test-resources/jetty</directory>
- <includes>
- <include>server.jks</include>
- <include>server.cer</include>
- <include>client.jks</include>
- </includes>
- </fileset>
- </filesets>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>keytool-maven-plugin</artifactId>
- <version>1.5</version>
- <executions>
- <execution>
- <id>generate-key-pair</id>
- <phase>generate-test-resources</phase>
- <goals>
- <goal>generateKeyPair</goal>
- </goals>
- <configuration>
- <alias>server</alias>
- <dname>cn=localhost,o=OASIS</dname>
- <keyalg>RSA</keyalg>
- <keypass>password</keypass>
- <keystore>${project.build.directory}/test-resources/jetty/server.jks</keystore>
- <storepass>password</storepass>
- </configuration>
- </execution>
- <execution>
- <id>export-certificate</id>
- <phase>generate-test-resources</phase>
- <goals>
- <goal>exportCertificate</goal>
- </goals>
- <configuration>
- <alias>server</alias>
- <file>${project.build.directory}/test-resources/jetty/server.cer</file>
- <keystore>${project.build.directory}/test-resources/jetty/server.jks</keystore>
- <storepass>password</storepass>
- </configuration>
- </execution>
- <execution>
- <id>import-certificate</id>
- <phase>generate-test-resources</phase>
- <goals>
- <goal>importCertificate</goal>
- </goals>
- <configuration>
- <alias>server</alias>
- <file>${project.build.directory}/test-resources/jetty/server.cer</file>
- <keystore>${project.build.directory}/test-resources/jetty/client.jks</keystore>
- <storepass>password</storepass>
- <noprompt>true</noprompt>
- </configuration>
- </execution>
- </executions>
- </plugin>
<!--plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
@@ -585,5 +510,10 @@
<artifactId>axis2-testutils</artifactId>
<version>${axis2.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.bouncycastle</groupId>
+ <artifactId>bcpkix-jdk15on</artifactId>
+ <version>${bcprov.jdk15.version}</version>
+ </dependency>
</dependencies>
</project>
Modified: axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/main/java/org/apache/axis2/integration/JettyServer.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/main/java/org/apache/axis2/integration/JettyServer.java?rev=1780712&r1=1780711&r2=1780712&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/main/java/org/apache/axis2/integration/JettyServer.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/main/java/org/apache/axis2/integration/JettyServer.java Sat Jan 28 16:00:33 2017
@@ -16,6 +16,20 @@
package org.apache.axis2.integration;
import java.io.File;
+import java.io.FileOutputStream;
+import java.math.BigInteger;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.KeyStore;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.security.SecureRandom;
+import java.security.cert.X509Certificate;
+import java.util.Date;
+import java.util.Random;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Server;
@@ -24,145 +38,145 @@ import org.eclipse.jetty.server.ssl.SslS
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.webapp.WebAppContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.axis2.testutils.PortAllocator;
+import org.junit.rules.ExternalResource;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.transport.http.AxisServlet;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.bouncycastle.asn1.x500.X500Name;
+import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
+import org.bouncycastle.cert.X509CertificateHolder;
+import org.bouncycastle.cert.X509v3CertificateBuilder;
+import org.bouncycastle.cert.jcajce.JcaX509CertificateConverter;
+import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder;
/**
* Support for running an embedded Jetty server
*/
-public class JettyServer {
-
- /**
- * Keystore to configure for Jetty's ssl context factory: {@value}
- */
- public 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";
-
- /**
- * Keystore password to configure for Jetty's ssl context factory: {@value}
- */
- public static final String KEYSTORE_PASSWORD = "password";
-
+public class JettyServer extends ExternalResource {
/**
* The alias of the certificate to configure for Jetty's ssl context factory: {@value}
*/
- public 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";
-
- /**
- * Axis2 configuration file to use: {@value}
- */
- public static final String AXIS2_XML = "src/test/resources/conf/axis2.xml";
+ private static final String CERT_ALIAS = "server";
/**
* 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);
+ private static final Log log = LogFactory.getLog(JettyServer.class);
- private static Server server;
-
- private JettyServer() {
-
- }
+ private final String repository;
+ private final boolean secure;
+ private File keyStoreFile;
+ private File trustStoreFile;
+ private Server server;
+ private boolean systemPropertiesSet;
+ private String savedTrustStore;
+ private String savedTrustStorePassword;
+ private String savedTrustStoreType;
/**
- * Starts the embedded Jetty server using dynamic port allocation with both http and https connectors enabled.
- *
- * @param repository The path to the Axis2 repository to use. Must not be null or empty.
+ * Constructor.
*
- * @throws Exception
+ * @param repository
+ * The path to the Axis2 repository to use. Must not be null or empty.
+ * @param secure
+ * Whether to enable HTTPS.
*/
- public static synchronized void start(String repository) throws Exception {
- start(repository, true, true);
+ public JettyServer(String repository, boolean secure) {
+ if (repository == null || repository.trim().length() == 0) {
+ throw new IllegalArgumentException("Axis2 repository must not be null or empty");
+ }
+ this.repository = repository;
+ this.secure = secure;
}
- /**
- * Starts the embedded Jetty server using dynamic port allocation.
- *
- * @param repository The path to the Axis2 repository to use. Must not be null or empty.
- * @param enableHttp Specifies whether to enable http connector.
- * @param enableHttps Specifies whether to enable https connector.
- *
- * @throws Exception
- */
- public static synchronized void start(String repository, boolean enableHttp, boolean enableHttps) throws Exception {
- int httpPort = enableHttp ? PortAllocator.allocatePort() : -1;
- int httpsPort = enableHttps ? PortAllocator.allocatePort() : -1;
-
- start(repository, httpPort, httpsPort);
+ private String generatePassword(Random random) {
+ char[] password = new char[8];
+ for (int i=0; i<password.length; i++) {
+ password[i] = (char)('0' + random.nextInt(10));
+ }
+ return new String(password);
}
- /**
- * Starts the embedded Jetty server.
- *
- * @param repository The path to the Axis2 repository to use. Must not be null or empty.
- * @param httpPort The http port to use. Set to <code>-1</code> to disable http connector.
- * @param httpsPort The https port to use. Set to <code>-1</code> to disable https connector.
- *
- * @throws Exception
- * @throws IllegalArgumentException If both ports are set to <code>-1</code>
- */
- public static synchronized void start(String repository, int httpPort, int httpsPort) throws Exception {
- if (repository == null || repository.trim().length() == 0) {
- throw new IllegalArgumentException("Axis2 repository must not be null or empty");
- }
- else if (httpPort == -1 && httpsPort == -1) {
- throw new IllegalArgumentException("At least one port must be specified.");
+ private void writeKeyStore(KeyStore keyStore, File file, String password) throws Exception {
+ FileOutputStream out = new FileOutputStream(file);
+ try {
+ keyStore.store(out, password.toCharArray());
+ } finally {
+ out.close();
}
+ }
+ @Override
+ protected void before() throws Throwable {
server = new Server();
- SelectChannelConnector connector = null;
- if (httpPort == -1) {
- logger.debug("Http connector is disabled");
- }
- else {
- logger.info("Starting http connector on port: " + httpPort);
-
- connector = new SelectChannelConnector();
- connector.setPort(httpPort);
+ if (!secure) {
+ SelectChannelConnector connector = new SelectChannelConnector();
server.addConnector(connector);
- }
-
- if (httpsPort == -1) {
- logger.debug("Https connector is disabled");
- }
- else {
+ } else {
+ SecureRandom random = new SecureRandom();
+
+ // Generate key pair
+ KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
+ keyPairGenerator.initialize(1024, random);
+ KeyPair keyPair = keyPairGenerator.generateKeyPair();
+ PrivateKey privateKey = keyPair.getPrivate();
+ PublicKey publicKey = keyPair.getPublic();
+
+ // Generate certificate
+ X500Name dn = new X500Name("cn=localhost,o=Apache");
+ BigInteger serial = BigInteger.valueOf(random.nextInt());
+ Date notBefore = new Date();
+ Date notAfter = new Date(notBefore.getTime() + 3600000L);
+ SubjectPublicKeyInfo subPubKeyInfo = SubjectPublicKeyInfo.getInstance(publicKey.getEncoded());
+ X509v3CertificateBuilder certBuilder = new X509v3CertificateBuilder(dn, serial, notBefore, notAfter, dn, subPubKeyInfo);
+ X509CertificateHolder certHolder = certBuilder.build(new JcaContentSignerBuilder("SHA1WithRSA").build(privateKey));
+ X509Certificate cert = new JcaX509CertificateConverter().getCertificate(certHolder);
+
+ // Build key store
+ keyStoreFile = File.createTempFile("keystore", "jks", null);
+ String keyStorePassword = generatePassword(random);
+ String keyPassword = generatePassword(random);
+ KeyStore keyStore = KeyStore.getInstance("JKS");
+ keyStore.load(null, null);
+ keyStore.setKeyEntry(CERT_ALIAS, privateKey, keyPassword.toCharArray(), new X509Certificate[] { cert });
+ writeKeyStore(keyStore, keyStoreFile, keyStorePassword);
+
+ // Build trust store
+ trustStoreFile = File.createTempFile("truststore", "jks", null);
+ String trustStorePassword = generatePassword(random);
+ KeyStore trustStore = KeyStore.getInstance("JKS");
+ trustStore.load(null, null);
+ trustStore.setCertificateEntry(CERT_ALIAS, cert);
+ writeKeyStore(trustStore, trustStoreFile, trustStorePassword);
+
SslContextFactory sslContextFactory = new SslContextFactory();
- sslContextFactory.setKeyStorePath(KEYSTORE);
- sslContextFactory.setKeyStorePassword(KEYSTORE_PASSWORD);
- sslContextFactory.setKeyManagerPassword(KEYMAN_PASSWORD);
- sslContextFactory.setTrustStore(KEYSTORE);
- sslContextFactory.setTrustStorePassword(KEYSTORE_PASSWORD);
+ sslContextFactory.setKeyStorePath(keyStoreFile.getAbsolutePath());
+ sslContextFactory.setKeyStorePassword(keyStorePassword);
+ sslContextFactory.setKeyManagerPassword(keyPassword);
sslContextFactory.setCertAlias(CERT_ALIAS);
SslSelectChannelConnector sslConnector = new SslSelectChannelConnector(sslContextFactory);
- logger.info("Starting https connector on port: " + httpsPort);
-
- sslConnector.setPort(httpsPort);
server.addConnector(sslConnector);
- if (connector != null) {
- connector.setConfidentialPort(httpsPort);
- }
+ savedTrustStore = System.getProperty("javax.net.ssl.trustStore");
+ System.setProperty("javax.net.ssl.trustStore", trustStoreFile.getAbsolutePath());
+ savedTrustStorePassword = System.getProperty("javax.net.ssl.trustStorePassword");
+ System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);
+ savedTrustStoreType = System.getProperty("javax.net.ssl.trustStoreType");
+ System.setProperty("javax.net.ssl.trustStoreType", "JKS");
+ systemPropertiesSet = true;
}
WebAppContext context = new WebAppContext();
File webappDir = new File(WEBAPP_DIR);
if (!webappDir.exists() && !webappDir.mkdirs()) {
- logger.error("Failed to create Axis2 webapp directory: " + webappDir.getAbsolutePath());
+ log.error("Failed to create Axis2 webapp directory: " + webappDir.getAbsolutePath());
}
context.setResourceBase(webappDir.getAbsolutePath());
@@ -170,10 +184,16 @@ public class JettyServer {
context.setParentLoaderPriority(true);
context.setThrowUnavailableOnStartupException(true);
- ServletHolder servlet = new ServletHolder();
- servlet.setClassName(AxisServlet.class.getName());
- servlet.setInitParameter("axis2.repository.path", repository);
- servlet.setInitParameter("axis2.xml.path", AXIS2_XML);
+ final ConfigurationContext configurationContext =
+ ConfigurationContextFactory.createConfigurationContextFromFileSystem(repository);
+ @SuppressWarnings("serial")
+ ServletHolder servlet = new ServletHolder(new AxisServlet() {
+ @Override
+ protected ConfigurationContext initConfigContext(ServletConfig config)
+ throws ServletException {
+ return configurationContext;
+ }
+ });
//load on startup to trigger Axis2 initialization and service deployment
//this is for backward compatibility with the SimpleHttpServer which initializes Axis2 on startup
@@ -188,33 +208,69 @@ public class JettyServer {
}
catch (SecurityException e) {
if (e.getMessage().equals("class \"javax.servlet.ServletRequestListener\"'s signer information does not match signer information of other classes in the same package")) {
- logger.error(
+ log.error(
"It is likely your test classpath contains multiple different versions of servlet api.\n" +
"If you are running this test in an IDE, please configure it to exclude Rampart's core module servlet api dependency.");
throw e;
}
}
+
+ log.info("Server started on port " + getPort());
}
- /**
- * Stops the embedded Jetty server.
- *
- * @throws Exception
- */
- public static synchronized void stop() throws Exception {
+ @Override
+ protected void after() {
if (server != null) {
- logger.info("Stop called");
- server.stop();
+ log.info("Stop called");
+ try {
+ server.stop();
+ } catch (Exception ex) {
+ log.error("Failed to stop Jetty server", ex);
+ }
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;
+ }
+ if (keyStoreFile != null) {
+ keyStoreFile.delete();
+ keyStoreFile = null;
+ }
+ if (trustStoreFile != null) {
+ trustStoreFile.delete();
+ trustStoreFile = null;
+ }
}
/**
* @return Jetty's http connector port.
* @throws IllegalStateException If Jetty is not running or the http connector cannot be found.
*/
- public static synchronized int getHttpPort() throws IllegalStateException {
- assertStarted();
+ public int getPort() throws IllegalStateException {
+ if (server == null) {
+ throw new IllegalStateException("Jetty server is not initialized");
+ }
+ if (!server.isStarted()) {
+ throw new IllegalStateException("Jetty server is not started");
+ }
Connector[] connectors = server.getConnectors();
if (connectors.length == 0) {
@@ -222,44 +278,20 @@ public class JettyServer {
}
for (Connector connector : connectors) {
- if ((connector instanceof SelectChannelConnector) &&
- !(connector instanceof SslSelectChannelConnector)) {
+ if (connector instanceof SelectChannelConnector) {
//must be the http connector
- return connector.getPort();
+ return connector.getLocalPort();
}
}
throw new IllegalStateException("Could not find Jetty http connector");
}
-
- /**
- * @return Jetty's ssl connector port.
- * @throws IllegalStateException If Jetty is not running or the ssl connector cannot be found.
- */
- public static synchronized int getHttpsPort() throws IllegalStateException {
- assertStarted();
-
- Connector[] connectors = server.getConnectors();
- if (connectors.length == 0) {
- throw new IllegalStateException("Jetty server is not configured with any connectors");
- }
-
- for (Connector connector : connectors) {
- if (connector instanceof SslSelectChannelConnector) {
- //must be the https connector
- return connector.getPort();
- }
- }
-
- throw new IllegalStateException("Could not find Jetty https connector");
+
+ public String getEndpoint(String serviceName) {
+ return String.format("%s://localhost:%s/axis2/services/%s", secure ? "https" : "http", getPort(), serviceName);
}
-
- private static void assertStarted() throws IllegalStateException {
- if (server == null) {
- throw new IllegalStateException("Jetty server is not initialized");
- }
- else if (!server.isStarted()) {
- throw new IllegalStateException("Jetty server is not started");
- }
+
+ public EndpointReference getEndpointReference(String serviceName) {
+ return new EndpointReference(getEndpoint(serviceName));
}
}
Modified: axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/main/java/org/apache/rahas/TestClient.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/main/java/org/apache/rahas/TestClient.java?rev=1780712&r1=1780711&r2=1780712&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/main/java/org/apache/rahas/TestClient.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/main/java/org/apache/rahas/TestClient.java Sat Jan 28 16:00:33 2017
@@ -16,6 +16,8 @@
package org.apache.rahas;
+import static org.apache.axis2.integration.TestConstants.TESTING_PATH;
+
import java.io.FileInputStream;
import java.io.InputStream;
@@ -24,7 +26,6 @@ import org.apache.axiom.om.OMXMLBuilderF
import org.apache.axiom.om.OMXMLParserWrapper;
import org.apache.axis2.Constants;
import org.apache.axis2.addressing.AddressingConstants;
-import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.context.ConfigurationContext;
@@ -34,30 +35,20 @@ import org.apache.axis2.integration.Jett
import org.apache.neethi.Policy;
import org.apache.neethi.PolicyEngine;
import org.apache.rampart.RampartMessageData;
+import org.junit.Rule;
+import org.junit.Test;
-import junit.framework.TestCase;
-
-public abstract class TestClient extends TestCase {
-
- protected int port = 5555;
-
- public TestClient(String name) {
- super(name);
- }
-
- protected void setUp() throws Exception {
- JettyServer.start(Constants.TESTING_PATH + getServiceRepo(), port, -1);
- }
+public abstract class TestClient {
- protected void tearDown() throws Exception {
- JettyServer.stop();
- }
+ @Rule
+ public final JettyServer server = new JettyServer(TESTING_PATH + getServiceRepo(), false);
/**
*/
+ @Test
public void testRequest() throws Exception {
// Get the repository location from the args
- String repo = Constants.TESTING_PATH + "rahas_client_repo";
+ String repo = TESTING_PATH + "rahas_client_repo";
ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repo,
null);
@@ -70,7 +61,7 @@ public abstract class TestClient extends
System.setProperty("javax.net.ssl.trustStorePassword", "password");
System.setProperty("javax.net.ssl.trustStoreType","JKS");
- options.setTo(new EndpointReference("http://127.0.0.1:" + port + "/axis2/services/SecureService"));
+ options.setTo(server.getEndpointReference("SecureService"));
// options.setTo(new EndpointReference("http://127.0.0.1:" + 9090 + "/axis2/services/UTSAMLHoK"));
// options.setTo(new EndpointReference("https://www-lk.wso2.com:8443/axis2/services/UTSAMLHoK"));
// options.setTo(new EndpointReference("https://192.18.49.133:2343/jaxws-s1-sts/sts"));
Modified: axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAML2TokenCertForHoKTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAML2TokenCertForHoKTest.java?rev=1780712&r1=1780711&r2=1780712&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAML2TokenCertForHoKTest.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAML2TokenCertForHoKTest.java Sat Jan 28 16:00:33 2017
@@ -22,13 +22,11 @@ import org.apache.axiom.om.OMAbstractFac
import org.apache.neethi.Policy;
import org.apache.ws.secpolicy.SP11Constants;
+import static org.junit.Assert.assertNotNull;
+
import javax.xml.namespace.QName;
public class RahasSAML2TokenCertForHoKTest extends TestClient{
- public RahasSAML2TokenCertForHoKTest(String name) {
- super(name);
- }
-
public String getServiceRepo() {
return "rahas_service_repo_1";
}
Modified: axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAML2TokenTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAML2TokenTest.java?rev=1780712&r1=1780711&r2=1780712&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAML2TokenTest.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAML2TokenTest.java Sat Jan 28 16:00:33 2017
@@ -22,15 +22,11 @@ import org.apache.axiom.om.OMAbstractFac
import org.apache.neethi.Policy;
import org.apache.ws.secpolicy.SP11Constants;
+import static org.junit.Assert.assertNotNull;
+
import javax.xml.namespace.QName;
-public class RahasSAML2TokenTest extends TestClient{
- /**
- * @param name
- */
- public RahasSAML2TokenTest(String name) {
- super(name);
- }
+public class RahasSAML2TokenTest extends TestClient{
public String getServiceRepo() {
return "rahas_service_repo_1";
}
Modified: axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAML2TokenUTForBearerTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAML2TokenUTForBearerTest.java?rev=1780712&r1=1780711&r2=1780712&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAML2TokenUTForBearerTest.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAML2TokenUTForBearerTest.java Sat Jan 28 16:00:33 2017
@@ -33,6 +33,10 @@ import org.w3c.dom.Element;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
import java.io.ByteArrayInputStream;
import java.util.List;
@@ -41,11 +45,6 @@ import java.util.List;
* @author Ruchith Fernando (ruchith.fernando@gmail.com)
*/
public class RahasSAML2TokenUTForBearerTest extends TestClient {
-
- public RahasSAML2TokenUTForBearerTest(String name) {
- super(name);
- }
-
public OMElement getRequest() {
try {
OMElement rstElem = TrustUtil.createRequestSecurityTokenElement(RahasConstants.VERSION_05_02);
Modified: axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenAttributeTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenAttributeTest.java?rev=1780712&r1=1780711&r2=1780712&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenAttributeTest.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenAttributeTest.java Sat Jan 28 16:00:33 2017
@@ -1,5 +1,7 @@
package org.apache.rahas;
+import static org.junit.Assert.assertNotNull;
+
import javax.xml.namespace.QName;
import org.apache.axiom.om.OMAbstractFactory;
@@ -9,11 +11,6 @@ import org.apache.neethi.Policy;
import org.apache.ws.secpolicy.SP11Constants;
public class RahasSAMLTokenAttributeTest extends TestClient{
-
- public RahasSAMLTokenAttributeTest(String name) {
- super(name);
- }
-
public OMElement getRequest() {
try {
OMElement rstElem = TrustUtil.createRequestSecurityTokenElement(RahasConstants.VERSION_05_02);
Modified: axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenCertForHoKTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenCertForHoKTest.java?rev=1780712&r1=1780711&r2=1780712&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenCertForHoKTest.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenCertForHoKTest.java Sat Jan 28 16:00:33 2017
@@ -22,15 +22,11 @@ import org.apache.axiom.om.OMFactory;
import org.apache.neethi.Policy;
import org.apache.ws.secpolicy.SP11Constants;
-import javax.xml.namespace.QName;
+import static org.junit.Assert.assertNotNull;
+import javax.xml.namespace.QName;
public class RahasSAMLTokenCertForHoKTest extends TestClient {
-
- public RahasSAMLTokenCertForHoKTest(String name) {
- super(name);
- }
-
public String getServiceRepo() {
return "rahas_service_repo_1";
}
Modified: axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenCertForHoKV1205Test.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenCertForHoKV1205Test.java?rev=1780712&r1=1780711&r2=1780712&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenCertForHoKV1205Test.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenCertForHoKV1205Test.java Sat Jan 28 16:00:33 2017
@@ -22,15 +22,11 @@ import org.apache.axiom.om.OMFactory;
import org.apache.neethi.Policy;
import org.apache.ws.secpolicy.SP12Constants;
+import static org.junit.Assert.assertNotNull;
+
import javax.xml.namespace.QName;
public class RahasSAMLTokenCertForHoKV1205Test extends TestClient {
-
-
- public RahasSAMLTokenCertForHoKV1205Test(String name) {
- super(name);
- }
-
public OMElement getRequest() {
try {
OMElement rstElem =
Modified: axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenTest.java?rev=1780712&r1=1780711&r2=1780712&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenTest.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenTest.java Sat Jan 28 16:00:33 2017
@@ -22,18 +22,11 @@ import org.apache.axiom.om.OMFactory;
import org.apache.neethi.Policy;
import org.apache.ws.secpolicy.SP11Constants;
+import static org.junit.Assert.assertNotNull;
+
import javax.xml.namespace.QName;
public class RahasSAMLTokenTest extends TestClient {
-
-
- /**
- * @param name
- */
- public RahasSAMLTokenTest(String name) {
- super(name);
- }
-
public String getServiceRepo() {
return "rahas_service_repo_1";
}
Modified: axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenUTForBearerTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenUTForBearerTest.java?rev=1780712&r1=1780711&r2=1780712&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenUTForBearerTest.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenUTForBearerTest.java Sat Jan 28 16:00:33 2017
@@ -34,6 +34,10 @@ import org.w3c.dom.Element;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
import java.io.ByteArrayInputStream;
import java.util.List;
@@ -42,11 +46,6 @@ import java.util.List;
* @author Ruchith Fernando (ruchith.fernando@gmail.com)
*/
public class RahasSAMLTokenUTForBearerTest extends TestClient {
-
- public RahasSAMLTokenUTForBearerTest(String name) {
- super(name);
- }
-
public OMElement getRequest() {
try {
OMElement rstElem = TrustUtil.createRequestSecurityTokenElement(RahasConstants.VERSION_05_02);
Modified: axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenUTForBearerV1205Test.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenUTForBearerV1205Test.java?rev=1780712&r1=1780711&r2=1780712&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenUTForBearerV1205Test.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenUTForBearerV1205Test.java Sat Jan 28 16:00:33 2017
@@ -22,17 +22,11 @@ import org.apache.axiom.om.OMFactory;
import org.apache.neethi.Policy;
import org.apache.ws.secpolicy.SP12Constants;
+import static org.junit.Assert.assertNotNull;
+
import javax.xml.namespace.QName;
public class RahasSAMLTokenUTForBearerV1205Test extends TestClient {
-
- /**
- * @param name
- */
- public RahasSAMLTokenUTForBearerV1205Test(String name) {
- super(name);
- }
-
public OMElement getRequest() {
try {
OMElement rstElem = TrustUtil.createRequestSecurityTokenElement(RahasConstants.VERSION_05_12);
Modified: axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenUTForHoKTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenUTForHoKTest.java?rev=1780712&r1=1780711&r2=1780712&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenUTForHoKTest.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenUTForHoKTest.java Sat Jan 28 16:00:33 2017
@@ -22,14 +22,11 @@ import org.apache.axiom.om.OMFactory;
import org.apache.neethi.Policy;
import org.apache.ws.secpolicy.SP11Constants;
+import static org.junit.Assert.assertNotNull;
+
import javax.xml.namespace.QName;
public class RahasSAMLTokenUTForHoKTest extends TestClient {
-
- public RahasSAMLTokenUTForHoKTest(String name) {
- super(name);
- }
-
public OMElement getRequest() {
try {
OMElement rstElem = TrustUtil.createRequestSecurityTokenElement(RahasConstants.VERSION_05_02);
Modified: axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenUTForHoKV1205Test.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenUTForHoKV1205Test.java?rev=1780712&r1=1780711&r2=1780712&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenUTForHoKV1205Test.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenUTForHoKV1205Test.java Sat Jan 28 16:00:33 2017
@@ -16,6 +16,8 @@
package org.apache.rahas;
+import static org.junit.Assert.assertNotNull;
+
import javax.xml.namespace.QName;
import org.apache.axiom.om.OMAbstractFactory;
@@ -30,13 +32,6 @@ public class RahasSAMLTokenUTForHoKV1205
byte[] clientEntr;
- /**
- * @param name
- */
- public RahasSAMLTokenUTForHoKV1205Test(String name) {
- super(name);
- }
-
public OMElement getRequest() {
try {
OMElement rstElem = TrustUtil.createRequestSecurityTokenElement(RahasConstants.VERSION_05_12);
Modified: axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenV1205Test.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenV1205Test.java?rev=1780712&r1=1780711&r2=1780712&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenV1205Test.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenV1205Test.java Sat Jan 28 16:00:33 2017
@@ -22,20 +22,14 @@ import org.apache.axiom.om.OMFactory;
import org.apache.neethi.Policy;
import org.apache.ws.secpolicy.SP12Constants;
+import static org.junit.Assert.assertNotNull;
+
import javax.xml.namespace.QName;
/**
* RahasSAMLTokenTest with the WS-SX namespaces
*/
public class RahasSAMLTokenV1205Test extends TestClient {
-
- /**
- * @param name
- */
- public RahasSAMLTokenV1205Test(String name) {
- super(name);
- }
-
public OMElement getRequest() {
try {
OMElement rstElem = TrustUtil.createRequestSecurityTokenElement(RahasConstants.VERSION_05_12);
Modified: axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rampart/RampartTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rampart/RampartTest.java?rev=1780712&r1=1780711&r2=1780712&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rampart/RampartTest.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-423/modules/rampart-integration/src/test/java/org/apache/rampart/RampartTest.java Sat Jan 28 16:00:33 2017
@@ -16,12 +16,10 @@
package org.apache.rampart;
-import static org.apache.axis2.integration.JettyServer.getHttpPort;
-import static org.apache.axis2.integration.JettyServer.getHttpsPort;
-import static org.apache.axis2.integration.JettyServer.CLIENT_KEYSTORE;
-import static org.apache.axis2.integration.JettyServer.KEYSTORE_PASSWORD;
+import static org.apache.axis2.integration.TestConstants.TESTING_PATH;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
-import junit.framework.TestCase;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
@@ -30,7 +28,6 @@ import org.apache.axiom.om.util.AXIOMUti
import org.apache.axiom.soap.SOAPHeaderBlock;
import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
-import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.context.ConfigurationContext;
@@ -39,17 +36,21 @@ 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.Rule;
+import org.junit.Test;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
-
-public class RampartTest extends TestCase {
+public class RampartTest {
private static ResourceBundle resources;
- private String trustStore;
- private String trustStorePassword;
- private String trustStoreType;
+
+ @Rule
+ public final JettyServer server = new JettyServer(TESTING_PATH + "rampart_service_repo", false);
+
+ @Rule
+ public final JettyServer secureServer = new JettyServer(TESTING_PATH + "rampart_service_repo", true);
static {
try {
@@ -59,55 +60,9 @@ public class RampartTest extends TestCas
}
}
- public RampartTest(String name) {
- super(name);
- }
-
- protected 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");
-
- JettyServer.start(Constants.TESTING_PATH + "rampart_service_repo");
- }
-
-
- protected void tearDown() throws Exception {
- try {
- JettyServer.stop();
- }
- finally {
- 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";
+ String repository = TESTING_PATH + "rampart_client_repo";
ConfigurationContext configContext = ConfigurationContextFactory.
createConfigurationContextFromFileSystem(repository, null);
@@ -121,6 +76,7 @@ public class RampartTest extends TestCas
}
+ @Test
public void testWithPolicy() {
try {
@@ -148,17 +104,13 @@ public class RampartTest extends TestCas
Options options = new Options();
if( i == 13 ) {
- options.setTo(new EndpointReference("https://localhost:" +
- getHttpsPort() +
- "/axis2/services/SecureService" + i));
+ options.setTo(secureServer.getEndpointReference("SecureService" + i));
//Username token created with user/pass from options
options.setUserName("alice");
options.setPassword("password");
}
else {
- options.setTo(new EndpointReference("http://localhost:" +
- getHttpPort() +
- "/axis2/services/SecureService" + i));
+ options.setTo(server.getEndpointReference("SecureService" + i));
}
System.out.println("Testing WS-Sec: custom scenario " + i);
@@ -224,17 +176,13 @@ public class RampartTest extends TestCas
Options options = new Options();
if (i == 13) {
- options.setTo(new EndpointReference("https://localhost:" +
- getHttpsPort() +
- "/axis2/services/SecureService" + i));
+ options.setTo(secureServer.getEndpointReference("SecureService" + i));
//Username token created with user/pass from options
options.setUserName("alice");
options.setPassword("password");
}
else {
- options.setTo(new EndpointReference("http://localhost:" +
- getHttpPort() +
- "/axis2/services/SecureService" + i));
+ options.setTo(server.getEndpointReference("SecureService" + i));
}
System.out.println("Testing WS-Sec: negative scenario " + i);
options.setAction("urn:returnError");
@@ -259,10 +207,10 @@ public class RampartTest extends TestCas
Options options = new Options();
if (i == 3 || i == 6) {
- options.setTo(new EndpointReference("https://localhost:" + getHttpsPort() + "/axis2/services/SecureServiceSC" + i));
+ options.setTo(secureServer.getEndpointReference("SecureServiceSC" + i));
}
else {
- options.setTo(new EndpointReference("http://localhost:" + getHttpPort() + "/axis2/services/SecureServiceSC" + i));
+ options.setTo(server.getEndpointReference("SecureServiceSC" + i));
}
System.out.println("Testing WS-SecConv: custom scenario " + i);