Author: alessio.soldano(a)jboss.com
Date: 2009-08-03 15:12:40 -0400 (Mon, 03 Aug 2009)
New Revision: 10463
Modified:
framework/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointAddressDeploymentAspect.java
Log:
[JBWS-1655] Setting https address in EndpointAddressDeploymentAspect when confidential
transport guarantee is requested
Modified:
framework/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointAddressDeploymentAspect.java
===================================================================
---
framework/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointAddressDeploymentAspect.java 2009-08-03
16:20:04 UTC (rev 10462)
+++
framework/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointAddressDeploymentAspect.java 2009-08-03
19:12:40 UTC (rev 10463)
@@ -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);
+ }
+
}
Show replies by date