Author: veithen
Date: Sat Jan 14 18:37:08 2017
New Revision: 1778815

URL: http://svn.apache.org/viewvc?rev=1778815&view=rev
Log:
Merge latest changes from trunk.

Modified:
    axis/axis2/java/rampart/branches/RAMPART-433/   (props changed)
    
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/main/java/org/apache/axis2/integration/JettyServer.java
    
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/main/java/org/apache/rahas/TestClient.java
    
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rampart/RampartKerberosTest.java
    
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rampart/RampartTest.java

Propchange: axis/axis2/java/rampart/branches/RAMPART-433/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Jan 14 18:37:08 2017
@@ -1 +1 @@
-/axis/axis2/java/rampart/trunk:1778760-1778807
+/axis/axis2/java/rampart/trunk:1778760-1778814

Modified: 
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/main/java/org/apache/axis2/integration/JettyServer.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/main/java/org/apache/axis2/integration/JettyServer.java?rev=1778815&r1=1778814&r2=1778815&view=diff
==============================================================================
--- 
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/main/java/org/apache/axis2/integration/JettyServer.java
 (original)
+++ 
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/main/java/org/apache/axis2/integration/JettyServer.java
 Sat Jan 14 18:37:08 2017
@@ -73,8 +73,8 @@ public class JettyServer extends Externa
     private static final Logger logger = 
LoggerFactory.getLogger(JettyServer.class);
     
     private final String repository;
-    private final int httpPort;
-    private final int httpsPort;
+    private final int port;
+    private final boolean secure;
     private Server server;
     private boolean systemPropertiesSet;
     private String savedTrustStore;
@@ -86,49 +86,32 @@ public class JettyServer extends Externa
      * 
      * @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. Set to
-     *            <code>0</code> to enable dynamic port allocation.
-     * @param httpsPort
-     *            The https port to use. Set to <code>-1</code> to disable 
https connector. Set to
-     *            <code>0</code> to enable dynamic port allocation.
-     * @throws IllegalArgumentException If both ports are set to 
<code>-1</code>
+     * @param port
+     *            The port to use. Set to <code>0</code> to enable dynamic 
port allocation.
+     * @param secure
+     *            Whether to enable HTTPS.
      */
-    public JettyServer(String repository, int httpPort, int httpsPort) {
+    public JettyServer(String repository, int port, boolean secure) {
         if (repository == null || repository.trim().length() == 0) {
             throw new IllegalArgumentException("Axis2 repository must not be 
null or empty");
         }
-        if (httpPort == -1 && httpsPort == -1) {
-            throw new IllegalArgumentException("At least one port must be 
specified.");
-        }
         this.repository = repository;
-        this.httpPort = httpPort;
-        this.httpsPort = httpsPort;
+        this.port = port;
+        this.secure = secure;
     }
     
     @Override
     protected void before() throws Throwable {
-        int httpPort = this.httpPort == 0 ? PortAllocator.allocatePort() : 
this.httpPort;
-        int httpsPort = this.httpsPort == 0 ? PortAllocator.allocatePort() : 
this.httpsPort;
+        int port = this.port == 0 ? PortAllocator.allocatePort() : this.port;
         
         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);
+        logger.info("Starting server on port: " + port);
+        if (!secure) {
+            SelectChannelConnector connector = new SelectChannelConnector();
+            connector.setPort(port);
             server.addConnector(connector);
-        }
-        
-        if (httpsPort == -1) {
-            logger.debug("Https connector is disabled");
-        }
-        else {
+        } else {
             SslContextFactory sslContextFactory = new SslContextFactory();
             sslContextFactory.setKeyStorePath(KEYSTORE);
             sslContextFactory.setKeyStorePassword(KEYSTORE_PASSWORD);
@@ -138,15 +121,9 @@ public class JettyServer extends Externa
             sslContextFactory.setCertAlias(CERT_ALIAS);
             SslSelectChannelConnector sslConnector = new 
SslSelectChannelConnector(sslContextFactory);
             
-            logger.info("Starting https connector on port: " + httpsPort);
-            
-            sslConnector.setPort(httpsPort);
+            sslConnector.setPort(port);
             server.addConnector(sslConnector);
             
-            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");
@@ -231,53 +208,26 @@ public class JettyServer extends Externa
      * @return Jetty's http connector port. 
      * @throws IllegalStateException If Jetty is not running or the http 
connector cannot be found.
      */
-    public int getHttpPort() throws IllegalStateException {
-        assertStarted();
-        
-        Connector[] connectors = server.getConnectors();
-        if (connectors.length == 0) {
-            throw new IllegalStateException("Jetty server is not configured 
with any connectors");
+    public int getPort() throws IllegalStateException {
+        if (server == null) {
+            throw new IllegalStateException("Jetty server is not initialized");
         }
-        
-        for (Connector connector : connectors) {
-            if ((connector instanceof SelectChannelConnector) &&
-                !(connector instanceof SslSelectChannelConnector)) {
-                //must be the http connector
-                return connector.getPort();
-            }
+        if (!server.isStarted()) {
+            throw new IllegalStateException("Jetty server is not started");
         }
         
-        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 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
+            if (connector instanceof SelectChannelConnector) {
+                //must be the http connector
                 return connector.getPort();
             }
         }
         
-        throw new IllegalStateException("Could not find Jetty https 
connector");
-    }
-    
-    private 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");
-        }
+        throw new IllegalStateException("Could not find Jetty http connector");
     }
 }

Modified: 
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/main/java/org/apache/rahas/TestClient.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/main/java/org/apache/rahas/TestClient.java?rev=1778815&r1=1778814&r2=1778815&view=diff
==============================================================================
--- 
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/main/java/org/apache/rahas/TestClient.java
 (original)
+++ 
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/main/java/org/apache/rahas/TestClient.java
 Sat Jan 14 18:37:08 2017
@@ -42,7 +42,7 @@ public abstract class TestClient {
     protected int port = 5555;
 
     @Rule
-    public final JettyServer server = new JettyServer(Constants.TESTING_PATH + 
getServiceRepo(), port, -1);
+    public final JettyServer server = new JettyServer(Constants.TESTING_PATH + 
getServiceRepo(), port, false);
 
     /**
      */

Modified: 
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rampart/RampartKerberosTest.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rampart/RampartKerberosTest.java?rev=1778815&r1=1778814&r2=1778815&view=diff
==============================================================================
--- 
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rampart/RampartKerberosTest.java
 (original)
+++ 
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rampart/RampartKerberosTest.java
 Sat Jan 14 18:37:08 2017
@@ -65,7 +65,7 @@ public class RampartKerberosTest extends
     public static final String KERBEROS_CONF_KDC_PORT_TOKEN = "KDC_PORT";
     
     @Rule
-    public final JettyServer server = new 
JettyServer("target/test-resources/rampart_service_repo", -1, 0);
+    public final JettyServer server = new 
JettyServer("target/test-resources/rampart_service_repo", 0, true);
     
     /**
      * Stores any original JAAS configuration set via {@link 
#JAAS_CONF_SYS_PROP} property to restore it after test execution.
@@ -80,7 +80,7 @@ public class RampartKerberosTest extends
     @Test
     public void testKerberosOverTransportKeytab() throws XMLStreamException, 
SAXException, IOException {
         final String serviceName = "KerberosOverTransportKeytab";
-        URL serviceUrl = new 
URL(String.format("https://localhost:%s/axis2/services/%s?wsdl";, 
server.getHttpsPort(), serviceName));
+        URL serviceUrl = new 
URL(String.format("https://localhost:%s/axis2/services/%s?wsdl";, 
server.getPort(), serviceName));
         
         ServiceClient serviceClient = getServiceClientInstance(serviceUrl);
 
@@ -107,7 +107,7 @@ public class RampartKerberosTest extends
     @Test
     public void testKerberosOverTransportPWCB() throws XMLStreamException, 
SAXException, IOException {
         final String serviceName = "KerberosOverTransportPWCB";
-        URL serviceUrl = new 
URL(String.format("https://localhost:%s/axis2/services/%s?wsdl";, 
server.getHttpsPort(), serviceName));
+        URL serviceUrl = new 
URL(String.format("https://localhost:%s/axis2/services/%s?wsdl";, 
server.getPort(), serviceName));
         
         ServiceClient serviceClient = getServiceClientInstance(serviceUrl);
 
@@ -136,7 +136,7 @@ public class RampartKerberosTest extends
     @Test
     public void testKerberosDelegation() throws XMLStreamException, 
SAXException, IOException {
         final String serviceName = "KerberosDelegation";
-        URL serviceUrl = new 
URL(String.format("https://localhost:%s/axis2/services/%s?wsdl";, 
server.getHttpsPort(), serviceName));
+        URL serviceUrl = new 
URL(String.format("https://localhost:%s/axis2/services/%s?wsdl";, 
server.getPort(), serviceName));
 
         ServiceClient serviceClient = getServiceClientInstance(serviceUrl);
 

Modified: 
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rampart/RampartTest.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rampart/RampartTest.java?rev=1778815&r1=1778814&r2=1778815&view=diff
==============================================================================
--- 
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rampart/RampartTest.java
 (original)
+++ 
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rampart/RampartTest.java
 Sat Jan 14 18:37:08 2017
@@ -47,8 +47,10 @@ public class RampartTest {
     private static ResourceBundle resources;
     
     @Rule
-    public final JettyServer server = new JettyServer(Constants.TESTING_PATH + 
"rampart_service_repo", 0, 0);
+    public final JettyServer server = new JettyServer(Constants.TESTING_PATH + 
"rampart_service_repo", 0, false);
     
+    @Rule
+    public final JettyServer secureServer = new 
JettyServer(Constants.TESTING_PATH + "rampart_service_repo", 0, true);
     
     static {
         try {
@@ -103,7 +105,7 @@ public class RampartTest {
                 
                 if( i == 13 ) {
                     options.setTo(new EndpointReference("https://localhost:"; +
-                                    server.getHttpsPort() +  
+                                    secureServer.getPort() +  
                                     "/axis2/services/SecureService" + i));
                     //Username token created with user/pass from options
                     options.setUserName("alice");
@@ -111,7 +113,7 @@ public class RampartTest {
                 }
                 else {
                     options.setTo(new EndpointReference("http://localhost:"; +
-                                    server.getHttpPort() +  
+                                    server.getPort() +  
                                     "/axis2/services/SecureService" + i));
                 }
                 
@@ -179,7 +181,7 @@ public class RampartTest {
 
                 if (i == 13) {
                     options.setTo(new EndpointReference("https://localhost:"; +
-                                    server.getHttpsPort() +
+                                    secureServer.getPort() +
                                     "/axis2/services/SecureService" + i));
                     //Username token created with user/pass from options
                     options.setUserName("alice");
@@ -187,7 +189,7 @@ public class RampartTest {
                 }
                 else {
                     options.setTo(new EndpointReference("http://localhost:"; +
-                                    server.getHttpPort() +
+                                    server.getPort() +
                                     "/axis2/services/SecureService" + i));
                 }
                 System.out.println("Testing WS-Sec: negative scenario " + i);
@@ -213,10 +215,10 @@ public class RampartTest {
                 Options options = new Options();
                 
                 if (i == 3 || i == 6) {
-                    options.setTo(new EndpointReference("https://localhost:"; + 
server.getHttpsPort() + "/axis2/services/SecureServiceSC" + i));
+                    options.setTo(new EndpointReference("https://localhost:"; + 
secureServer.getPort() + "/axis2/services/SecureServiceSC" + i));
                 }
                 else {
-                    options.setTo(new EndpointReference("http://localhost:"; + 
server.getHttpPort() + "/axis2/services/SecureServiceSC" + i));
+                    options.setTo(new EndpointReference("http://localhost:"; + 
server.getPort() + "/axis2/services/SecureServiceSC" + i));
                 }
 
                 System.out.println("Testing WS-SecConv: custom scenario " + i);


Reply via email to