Author: maeste
Date: 2007-05-03 04:21:10 -0400 (Thu, 03 May 2007)
New Revision: 2952
Added:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/WSSecurityAssertionDeployer.java
Modified:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/Policy.java
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/PolicyDeployer.java
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/builder/MetaDataBuilder.java
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSWebServiceMetaDataBuilder.java
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/wsse/WSSecurityConfigFactory.java
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/wsse/WSSecurityOMFactory.java
Log:
WSSecurityAssertionDeployer implementation
Modified:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/Policy.java
===================================================================
---
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/Policy.java 2007-05-01
23:12:59 UTC (rev 2951)
+++
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/Policy.java 2007-05-03
08:21:10 UTC (rev 2952)
@@ -115,6 +115,11 @@
{
return new ArrayList<PolicyAlternative>(alternatives);
}
+
+ public void clearPolicyAlternatives()
+ {
+ alternatives.clear();
+ }
public Element toElement()
{
Modified:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/PolicyDeployer.java
===================================================================
---
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/PolicyDeployer.java 2007-05-01
23:12:59 UTC (rev 2951)
+++
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/PolicyDeployer.java 2007-05-03
08:21:10 UTC (rev 2952)
@@ -49,7 +49,7 @@
static {
me = new PolicyDeployer();
- me.domainDeployerMap.put("",Object.class);
+
me.domainDeployerMap.put("http://www.jboss.com/ws-security/config&qu...;
}
//hide constructor
@@ -75,7 +75,7 @@
public Policy deployServerside(Policy policy, ExtensibleMetaData extMetaData) throws
UnsupportedPolicy
{
Policy returnedPolicy =
PolicyFactory.newInstance().createPolicy(policy.toElement());
- returnedPolicy.getPolicyAlternatives().clear();
+ returnedPolicy.clearPolicyAlternatives();
for (PolicyAlternative alternative : policy.getPolicyAlternatives())
{
try
Added:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/WSSecurityAssertionDeployer.java
===================================================================
---
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/WSSecurityAssertionDeployer.java
(rev 0)
+++
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/WSSecurityAssertionDeployer.java 2007-05-03
08:21:10 UTC (rev 2952)
@@ -0,0 +1,44 @@
+package org.jboss.ws.extensions.policy.deployer;
+
+import org.jboss.ws.extensions.policy.PolicyAssertion;
+import org.jboss.ws.extensions.policy.deployer.exceptions.UnsupportedAssertion;
+import org.jboss.ws.metadata.umdm.EndpointMetaData;
+import org.jboss.ws.metadata.umdm.ExtensibleMetaData;
+import org.jboss.ws.metadata.wsse.WSSecurityConfigFactory;
+import org.jboss.ws.metadata.wsse.WSSecurityConfiguration;
+import org.jboss.ws.metadata.wsse.WSSecurityOMFactory;
+import org.jboss.xb.binding.JBossXBException;
+
+public class WSSecurityAssertionDeployer implements AssertionDeployer
+{
+
+ public void deploy(PolicyAssertion assertion, ExtensibleMetaData extMetaData) throws
UnsupportedAssertion
+ {
+ if (extMetaData instanceof EndpointMetaData)
+ {
+ EndpointMetaData ep = (EndpointMetaData) extMetaData;
+
+ WSSecurityConfiguration securityConfiguration;
+ try
+ {
+ //Set security configuration
+ securityConfiguration =
WSSecurityOMFactory.newInstance().parse(assertion.toXMLString(true));
+ WSSecurityConfigFactory.newInstance().initKeystorePath(ep.getRootFile(),
securityConfiguration);
+ ep.getServiceMetaData().setSecurityConfiguration(securityConfiguration);
+ //set up handler chain as defined in standard file
+ ep.setConfigName("Standard WSSecurity Endpoint");
+ ep.initEndpointConfig();
+ }
+ catch (JBossXBException e)
+ {
+ throw new UnsupportedAssertion();
+ }
+
+
+ }
+
+ }
+
+
+
+}
Modified:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/builder/MetaDataBuilder.java
===================================================================
---
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/builder/MetaDataBuilder.java 2007-05-01
23:12:59 UTC (rev 2951)
+++
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/builder/MetaDataBuilder.java 2007-05-03
08:21:10 UTC (rev 2952)
@@ -476,7 +476,7 @@
{
for (WSDLExtensibilityElement element : policyReferenceList)
{
- for (WSDLExtensibilityElement policyElement :
wsdlDefinitions.getExtensibilityElements(element.getElement().getAttribute("URI")))
+ for (WSDLExtensibilityElement policyElement :
wsdlDefinitions.getExtensibilityElements(element.getElement().getAttribute("URI").substring(1)))
{
PolicyMetaExtension ext = new
PolicyMetaExtension(Constants.URI_WS_POLICY);
Policy policy =
PolicyFactory.newInstance().createPolicy(policyElement.getElement());
Modified:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSWebServiceMetaDataBuilder.java
===================================================================
---
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSWebServiceMetaDataBuilder.java 2007-05-01
23:12:59 UTC (rev 2951)
+++
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSWebServiceMetaDataBuilder.java 2007-05-03
08:21:10 UTC (rev 2952)
@@ -107,6 +107,8 @@
sepMetaData.setServiceEndpointImplName(sepClass.getName());
sepMetaData.setServiceEndpointInterfaceName(seiClass.getName());
+ //maeste
+ //TODO: use this 4 lines in asserion deployer
// Assign the WS-Security configuration,
WSSecurityConfigFactory wsseConfFactory =
WSSecurityConfigFactory.newInstance();
WSSecurityConfiguration securityConfiguration =
wsseConfFactory.createConfiguration(
Modified:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/wsse/WSSecurityConfigFactory.java
===================================================================
---
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/wsse/WSSecurityConfigFactory.java 2007-05-01
23:12:59 UTC (rev 2951)
+++
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/wsse/WSSecurityConfigFactory.java 2007-05-03
08:21:10 UTC (rev 2952)
@@ -71,28 +71,34 @@
{
log.debug("createConfiguration from: " + configLocation);
config = WSSecurityOMFactory.newInstance().parse(configLocation);
-
- // Get and set deployment path to the keystore file
- URL keystoreLocation = null;
- if (config.getKeyStoreFile() != null)
- {
- keystoreLocation = getResource(vfsRoot, config.getKeyStoreFile(), true);
- log.debug("Add keystore: " + keystoreLocation);
- config.setKeyStoreURL(keystoreLocation);
- }
-
- URL truststoreLocation = null;
- if (config.getTrustStoreFile() != null)
- {
- truststoreLocation = getResource(vfsRoot, config.getTrustStoreFile(), true);
- log.debug("Add truststore: " + truststoreLocation);
- config.setTrustStoreURL(truststoreLocation);
- }
+ initKeystorePath(vfsRoot, config);
}
return config;
}
+
+
+ public void initKeystorePath(UnifiedVirtualFile vfsRoot, WSSecurityConfiguration
config)
+ {
+ // Get and set deployment path to the keystore file
+ URL keystoreLocation = null;
+ if (config.getKeyStoreFile() != null)
+ {
+ keystoreLocation = getResource(vfsRoot, config.getKeyStoreFile(), true);
+ log.debug("Add keystore: " + keystoreLocation);
+ config.setKeyStoreURL(keystoreLocation);
+ }
+
+ URL truststoreLocation = null;
+ if (config.getTrustStoreFile() != null)
+ {
+ truststoreLocation = getResource(vfsRoot, config.getTrustStoreFile(), true);
+ log.debug("Add truststore: " + truststoreLocation);
+ config.setTrustStoreURL(truststoreLocation);
+ }
+ }
+
private URL getResource(UnifiedVirtualFile vfsRoot, String resource, boolean
failOnNotFound)
{
URL resourceURL = null;
Modified:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/wsse/WSSecurityOMFactory.java
===================================================================
---
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/wsse/WSSecurityOMFactory.java 2007-05-01
23:12:59 UTC (rev 2951)
+++
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/wsse/WSSecurityOMFactory.java 2007-05-03
08:21:10 UTC (rev 2952)
@@ -103,7 +103,18 @@
is.close();
}
}
+
+ public WSSecurityConfiguration parse(String xmlString) throws JBossXBException
+ {
+ if (xmlString == null)
+ throw new IllegalArgumentException("Security config xml String cannot be
null");
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ WSSecurityConfiguration configuration = (WSSecurityConfiguration)
unmarshaller.unmarshal(xmlString, this, null);
+ return configuration;
+
+ }
+
/**
* This method is called on the factory by the object model builder when the
* parsing starts.