Author: alessio.soldano(a)jboss.com
Date: 2010-05-07 11:39:32 -0400 (Fri, 07 May 2010)
New Revision: 12195
Modified:
framework/branches/jbossws-framework-3.1.2/src/main/java/org/jboss/wsf/framework/deployment/EndpointAddressDeploymentAspect.java
framework/branches/jbossws-framework-3.1.2/src/main/java/org/jboss/wsf/framework/management/ManagedEndpoint.java
framework/branches/jbossws-framework-3.1.2/src/main/java/org/jboss/wsf/framework/management/ManagedEndpointMBean.java
framework/branches/jbossws-framework-3.1.2/testsuite/test/java/org/jboss/test/ws/jaxws/jbws1190/ConfidentialEndpoint.java
framework/branches/jbossws-framework-3.1.2/testsuite/test/java/org/jboss/test/ws/jaxws/jbws1190/Endpoint.java
framework/branches/jbossws-framework-3.1.2/testsuite/test/java/org/jboss/test/ws/jaxws/jbws1190/EndpointImpl.java
framework/branches/jbossws-framework-3.1.2/testsuite/test/java/org/jboss/test/ws/jaxws/jbws1190/JBWS1190TestCase.java
framework/branches/jbossws-framework-3.1.2/testsuite/test/java/org/jboss/test/ws/jaxws/jbws2150/JBWS2150TestCase.java
Log:
[JBPAPP-4245] Endpoint address rewrite and multiple virtual host support (merge revisions
10463,10483,10484)
Modified:
framework/branches/jbossws-framework-3.1.2/src/main/java/org/jboss/wsf/framework/deployment/EndpointAddressDeploymentAspect.java
===================================================================
---
framework/branches/jbossws-framework-3.1.2/src/main/java/org/jboss/wsf/framework/deployment/EndpointAddressDeploymentAspect.java 2010-05-07
14:09:31 UTC (rev 12194)
+++
framework/branches/jbossws-framework-3.1.2/src/main/java/org/jboss/wsf/framework/deployment/EndpointAddressDeploymentAspect.java 2010-05-07
15:39:32 UTC (rev 12195)
@@ -21,13 +21,22 @@
*/
package org.jboss.wsf.framework.deployment;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
import org.jboss.wsf.spi.SPIProvider;
import org.jboss.wsf.spi.SPIProviderResolver;
+import org.jboss.wsf.spi.annotation.WebContext;
import org.jboss.wsf.spi.deployment.DeploymentAspect;
import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.deployment.Deployment.DeploymentType;
import org.jboss.wsf.spi.management.ServerConfig;
import org.jboss.wsf.spi.management.ServerConfigFactory;
+import org.jboss.wsf.spi.metadata.j2ee.JSEArchiveMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.JSESecurityMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.JSESecurityMetaData.JSEResourceCollection;
/**
* A deployer that assigns the endpoint address.
@@ -50,10 +59,12 @@
String host = serverConfig.getWebServiceHost();
int port = serverConfig.getWebServicePort();
- String hostAndPort = host + (port > 0 ? ":" + port : "");
-
+ int securePort = serverConfig.getWebServiceSecurePort();
for (Endpoint ep : dep.getService().getEndpoints())
{
+ boolean confidential = isConfidentialTransportGuarantee(dep, ep);
+ int currentPort = confidential ? securePort : port;
+ String hostAndPort = host + (currentPort > 0 ? ":" + currentPort :
"");
String urlPattern = ep.getURLPattern();
if (urlPattern == null)
throw new IllegalStateException("Cannot obtain url pattern");
@@ -61,7 +72,56 @@
if (urlPattern.endsWith("/*"))
urlPattern = urlPattern.substring(0, urlPattern.length() - 2);
- ep.setAddress("http://" + hostAndPort + contextRoot + urlPattern);
+ String protocol = confidential ? "https://" : "http://";
+ ep.setAddress(protocol + hostAndPort + contextRoot + urlPattern);
}
}
+
+ protected boolean isConfidentialTransportGuarantee(Deployment dep, Endpoint ep)
+ {
+ String transportGuarantee = null;
+ if (DeploymentType.JAXWS_JSE == dep.getType())
+ {
+ JSEArchiveMetaData webMetaData = dep.getAttachment(JSEArchiveMetaData.class);
+ if (webMetaData != null)
+ {
+ String servletLink = ep.getShortName();
+ Map<String, String> servletMappings =
webMetaData.getServletMappings();
+ String urlPattern = servletMappings.get(servletLink);
+
+ if (urlPattern == null)
+ throw new RuntimeException("Cannot find <url-pattern> for
servlet-name: " + servletLink);
+
+ List<JSESecurityMetaData> securityList =
webMetaData.getSecurityMetaData();
+ for (JSESecurityMetaData currentSecurity : securityList)
+ {
+ if (currentSecurity.getTransportGuarantee() != null &&
currentSecurity.getTransportGuarantee().length() > 0)
+ {
+ for (JSEResourceCollection currentCollection :
currentSecurity.getWebResources())
+ {
+ for (String currentUrlPattern : currentCollection.getUrlPatterns())
+ {
+ if (urlPattern.equals(currentUrlPattern) ||
"/*".equals(currentUrlPattern))
+ {
+ transportGuarantee = currentSecurity.getTransportGuarantee();
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ //TODO Unify annotation scans
+ Class implClass = ep.getTargetBeanClass();
+ WebContext anWebContext =
(WebContext)implClass.getAnnotation(WebContext.class);
+ if (anWebContext != null)
+ {
+ transportGuarantee = anWebContext.transportGuarantee();
+ }
+ }
+ return "CONFIDENTIAL".equals(transportGuarantee);
+ }
+
}
Modified:
framework/branches/jbossws-framework-3.1.2/src/main/java/org/jboss/wsf/framework/management/ManagedEndpoint.java
===================================================================
---
framework/branches/jbossws-framework-3.1.2/src/main/java/org/jboss/wsf/framework/management/ManagedEndpoint.java 2010-05-07
14:09:31 UTC (rev 12194)
+++
framework/branches/jbossws-framework-3.1.2/src/main/java/org/jboss/wsf/framework/management/ManagedEndpoint.java 2010-05-07
15:39:32 UTC (rev 12195)
@@ -52,6 +52,11 @@
this.endpoint = endpoint;
this.mbeanServer = mbeanServer;
}
+
+ public String getAddress()
+ {
+ return endpoint.getAddress();
+ }
public long getAverageProcessingTime()
{
Modified:
framework/branches/jbossws-framework-3.1.2/src/main/java/org/jboss/wsf/framework/management/ManagedEndpointMBean.java
===================================================================
---
framework/branches/jbossws-framework-3.1.2/src/main/java/org/jboss/wsf/framework/management/ManagedEndpointMBean.java 2010-05-07
14:09:31 UTC (rev 12194)
+++
framework/branches/jbossws-framework-3.1.2/src/main/java/org/jboss/wsf/framework/management/ManagedEndpointMBean.java 2010-05-07
15:39:32 UTC (rev 12195)
@@ -36,6 +36,8 @@
void start();
void stop();
+
+ String getAddress();
Date getStartTime();
Modified:
framework/branches/jbossws-framework-3.1.2/testsuite/test/java/org/jboss/test/ws/jaxws/jbws1190/ConfidentialEndpoint.java
===================================================================
---
framework/branches/jbossws-framework-3.1.2/testsuite/test/java/org/jboss/test/ws/jaxws/jbws1190/ConfidentialEndpoint.java 2010-05-07
14:09:31 UTC (rev 12194)
+++
framework/branches/jbossws-framework-3.1.2/testsuite/test/java/org/jboss/test/ws/jaxws/jbws1190/ConfidentialEndpoint.java 2010-05-07
15:39:32 UTC (rev 12195)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
@@ -36,11 +36,9 @@
@SOAPBinding(style = SOAPBinding.Style.RPC)
public class ConfidentialEndpoint
{
-
// Intentionally no @WebMethod, see above
public String helloWorld(final String message)
{
return message;
}
-
}
Modified:
framework/branches/jbossws-framework-3.1.2/testsuite/test/java/org/jboss/test/ws/jaxws/jbws1190/Endpoint.java
===================================================================
---
framework/branches/jbossws-framework-3.1.2/testsuite/test/java/org/jboss/test/ws/jaxws/jbws1190/Endpoint.java 2010-05-07
14:09:31 UTC (rev 12194)
+++
framework/branches/jbossws-framework-3.1.2/testsuite/test/java/org/jboss/test/ws/jaxws/jbws1190/Endpoint.java 2010-05-07
15:39:32 UTC (rev 12195)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
@@ -38,6 +38,6 @@
{
@WebMethod
- public void testAddress(final String archive, final String service, final String
scheme, final String port);
+ public void test();
}
Modified:
framework/branches/jbossws-framework-3.1.2/testsuite/test/java/org/jboss/test/ws/jaxws/jbws1190/EndpointImpl.java
===================================================================
---
framework/branches/jbossws-framework-3.1.2/testsuite/test/java/org/jboss/test/ws/jaxws/jbws1190/EndpointImpl.java 2010-05-07
14:09:31 UTC (rev 12194)
+++
framework/branches/jbossws-framework-3.1.2/testsuite/test/java/org/jboss/test/ws/jaxws/jbws1190/EndpointImpl.java 2010-05-07
15:39:32 UTC (rev 12195)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
@@ -21,25 +21,8 @@
*/
package org.jboss.test.ws.jaxws.jbws1190;
-import java.io.File;
-import java.io.FilenameFilter;
-import java.util.List;
-import java.util.Map;
-
import javax.jws.WebService;
-import javax.wsdl.Definition;
-import javax.wsdl.Port;
-import javax.wsdl.Service;
-import javax.wsdl.WSDLException;
-import javax.wsdl.extensions.soap.SOAPAddress;
-import javax.wsdl.factory.WSDLFactory;
-import javax.wsdl.xml.WSDLReader;
-import org.jboss.wsf.spi.management.ServerConfig;
-import org.jboss.wsf.spi.management.ServerConfigFactory;
-import org.jboss.wsf.spi.SPIProvider;
-import org.jboss.wsf.spi.SPIProviderResolver;
-
/**
* [JBWS-1190] - WSDL generated for JSR-181 POJO does not take
'transport-guarantee' in web.xml into account
*
@@ -51,84 +34,8 @@
@WebService(serviceName = "EndpointService", targetNamespace =
"http://org.jboss/test/ws/jbws1190", endpointInterface =
"org.jboss.test.ws.jaxws.jbws1190.Endpoint")
public class EndpointImpl implements Endpoint
{
-
- public void testAddress(final String archive, final String service, final String
scheme, final String port)
+ public void test()
{
- SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
- ServerConfig serverConfig =
spiProvider.getSPI(ServerConfigFactory.class).getServerConfig();File tmpDir =
serverConfig.getServerTempDir();
-
- File dataDir = serverConfig.getServerDataDir();
- File wsdlDir = new File(dataDir.getAbsolutePath() + File.separator +
"wsdl" + File.separator + archive);
-
- if (wsdlDir.exists() == false)
- {
- throw new JBWS1190Exception(wsdlDir.getAbsolutePath() + " does not
exist.");
- }
-
- File[] wsdls = wsdlDir.listFiles(new FilenameFilter() {
- public boolean accept(File dir, String name)
- {
- return name.startsWith(service);
- }
- });
-
- File wsdlFile = null;
- for (int i = 0; i < wsdls.length; i++)
- {
- if (wsdlFile == null || wsdls[i].compareTo(wsdlFile) > 0)
- {
- wsdlFile = wsdls[i];
- }
- }
- assertTrue("No WSDL files found", wsdlFile != null);
-
- Definition wsdl;
- try
- {
- WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
- wsdl = wsdlReader.readWSDL(wsdlFile.getAbsolutePath());
- }
- catch (WSDLException e)
- {
- throw new JBWS1190Exception("Error readin WSDL", e);
- }
-
- Map services = wsdl.getServices();
- assertEquals("No of services", 1, services.size());
-
- Service _service = (Service)services.values().iterator().next();
- Map ports = _service.getPorts();
- assertEquals("No of endpoints", 1, ports.size());
- Port _port = (Port)ports.values().iterator().next();
-
- List extElements = _port.getExtensibilityElements();
- String address = null;
- for (int i = 0; i < extElements.size(); i++)
- {
- if (extElements.get(i) instanceof SOAPAddress)
- {
- SOAPAddress soapAddrExtElement = (SOAPAddress)extElements.get(i);
- address = soapAddrExtElement.getLocationURI();
- }
- }
- assertTrue("Address is null", address != null);
- assertTrue("Expected Scheme '" + scheme + "' from address
'" + address + "'", address.startsWith(scheme + "://"));
- assertTrue("Expected Port '" + port + "' from address
'" + address + "'", address.indexOf(":" + port +
"/") > -1);
+ System.out.println("test");
}
-
- private void assertEquals(final String message, final int expected, final int actual)
- {
- if (expected != actual)
- {
- throw new JBWS1190Exception(message + " expected=" + expected + "
actual=" + actual);
- }
- }
-
- private void assertTrue(final String message, final boolean value)
- {
- if (value == false)
- {
- throw new JBWS1190Exception(message);
- }
- }
}
Modified:
framework/branches/jbossws-framework-3.1.2/testsuite/test/java/org/jboss/test/ws/jaxws/jbws1190/JBWS1190TestCase.java
===================================================================
---
framework/branches/jbossws-framework-3.1.2/testsuite/test/java/org/jboss/test/ws/jaxws/jbws1190/JBWS1190TestCase.java 2010-05-07
14:09:31 UTC (rev 12194)
+++
framework/branches/jbossws-framework-3.1.2/testsuite/test/java/org/jboss/test/ws/jaxws/jbws1190/JBWS1190TestCase.java 2010-05-07
15:39:32 UTC (rev 12195)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
@@ -23,6 +23,8 @@
import java.net.URL;
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
@@ -37,38 +39,30 @@
*
http://jira.jboss.org/jira/browse/JBWS-1190
*
* @author darran.lofthouse(a)jboss.com
+ * @author alessio.soldano(a)jboss.com
* @since 19-October-2006
*/
public class JBWS1190TestCase extends JBossWSTest
{
- private static final String ARCHIVE_NAME = "jaxws-jbws1190.war";
-
- private static Endpoint port;
-
public static Test suite()
{
- return new JBossWSTestSetup(JBWS1190TestCase.class, ARCHIVE_NAME);
+ return new JBossWSTestSetup(JBWS1190TestCase.class,
"jaxws-jbws1190.war");
}
-
- protected void setUp() throws Exception
+
+ public void testEndpointAddress() throws Exception
{
- if (port == null)
- {
- URL wsdlURL = new URL("http://" + getServerHost() +
":8080/jaxws-jbws1190/Endpoint?wsdl");
- QName qname = new QName("http://org.jboss/test/ws/jbws1190",
"EndpointService");
- Service service = Service.create(wsdlURL, qname);
- port = (Endpoint)service.getPort(Endpoint.class);
- }
+ MBeanServerConnection server = getServer();
+ ObjectName oname = new
ObjectName("jboss.ws:context=jaxws-jbws1190,endpoint=Endpoint");
+ String address = (String)server.getAttribute(oname, "Address");
+ assertTrue("Expected http address, but got: " + address,
address.startsWith("http://"));
}
- public void testEndpoint() throws Exception
+ public void testConfidentialEndpointAddress() throws Exception
{
- port.testAddress(ARCHIVE_NAME, "EndpointService", "http",
"8080");
+ MBeanServerConnection server = getServer();
+ ObjectName oname = new
ObjectName("jboss.ws:context=jaxws-jbws1190,endpoint=ConfidentialEndpoint");
+ String address = (String)server.getAttribute(oname, "Address");
+ assertTrue("Expected https address, but got: " + address,
address.startsWith("https://"));
}
-
- public void testConfidentialEndpoint() throws Exception
- {
- port.testAddress(ARCHIVE_NAME, "ConfidentialService", "https",
"8443");
- }
}
Modified:
framework/branches/jbossws-framework-3.1.2/testsuite/test/java/org/jboss/test/ws/jaxws/jbws2150/JBWS2150TestCase.java
===================================================================
---
framework/branches/jbossws-framework-3.1.2/testsuite/test/java/org/jboss/test/ws/jaxws/jbws2150/JBWS2150TestCase.java 2010-05-07
14:09:31 UTC (rev 12194)
+++
framework/branches/jbossws-framework-3.1.2/testsuite/test/java/org/jboss/test/ws/jaxws/jbws2150/JBWS2150TestCase.java 2010-05-07
15:39:32 UTC (rev 12195)
@@ -173,7 +173,9 @@
private ServiceIface getEndpoint(String wsdlLocation, String serviceName) throws
Exception
{
- return Service.create(new URL(wsdlLocation), new QName(NAMESPACE,
serviceName)).getPort(ServiceIface.class);
+ Service service = Service.create(new URL(wsdlLocation), new QName(NAMESPACE,
serviceName));
+ QName portName = service.getPorts().next();
+ return service.getPort(portName, ServiceIface.class);
}
private Definition getWSDLDefinition(String wsdlLocation) throws Exception