JBossWS SVN: r2954 - in branches/JBWS-856/jbossws-core/src/java/org/jboss/ws: metadata/builder and 1 other directory.
by jbossws-commits@lists.jboss.org
Author: palin
Date: 2007-05-03 11:43:45 -0400 (Thu, 03 May 2007)
New Revision: 2954
Modified:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/metadata/PolicyMetaExtension.java
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/builder/MetaDataBuilder.java
Log:
Some changes to MetaDataBuilder to consider policies attached to bindings and portTypes
Modified: branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/metadata/PolicyMetaExtension.java
===================================================================
--- branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/metadata/PolicyMetaExtension.java 2007-05-03 11:47:53 UTC (rev 2953)
+++ branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/metadata/PolicyMetaExtension.java 2007-05-03 15:43:45 UTC (rev 2954)
@@ -1,14 +1,8 @@
package org.jboss.ws.extensions.policy.metadata;
-import java.util.List;
-
import org.jboss.ws.extensions.policy.Policy;
-import org.jboss.ws.extensions.policy.PolicyFactory;
import org.jboss.ws.metadata.umdm.MetaDataExtension;
-import org.jboss.ws.metadata.wsdl.WSDLDefinitions;
-import org.jboss.ws.metadata.wsdl.WSDLExtensibilityElement;
-import org.w3c.dom.Element;
public class PolicyMetaExtension extends MetaDataExtension
{
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-03 11:47:53 UTC (rev 2953)
+++ branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/builder/MetaDataBuilder.java 2007-05-03 15:43:45 UTC (rev 2954)
@@ -28,6 +28,7 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -71,6 +72,7 @@
import org.jboss.ws.metadata.j2ee.UnifiedWebSecurityMetaData.UnifiedWebResourceCollection;
import org.jboss.ws.metadata.umdm.ClientEndpointMetaData;
import org.jboss.ws.metadata.umdm.EndpointMetaData;
+import org.jboss.ws.metadata.umdm.ExtensibleMetaData;
import org.jboss.ws.metadata.umdm.OperationMetaData;
import org.jboss.ws.metadata.umdm.ServerEndpointMetaData;
import org.jboss.ws.metadata.wsdl.WSDLBinding;
@@ -466,41 +468,79 @@
protected void processPolicyMetaDataExtension(EndpointMetaData epMetaData, WSDLDefinitions wsdlDefinitions)
{
- //PolicyReferece at endpointLevel
- List<WSDLExtensibilityElement> policyReferenceList = wsdlDefinitions.getService(epMetaData.getServiceMetaData().
- getServiceName().getLocalPart()).getEndpoint(epMetaData.getPortName()).
- getExtensibilityElements(Constants.WSDL_ELEMENT_POLICYREFERENCE);
- ServerEndpointMetaData sepMetaData = (ServerEndpointMetaData)epMetaData;
+ //Collect all policies defined in our wsdl definitions
+ PolicyFactory factory = PolicyFactory.newInstance();
+ Map<String,Policy> localPolicyElementsMap = new HashMap<String,Policy>();
+ for (WSDLExtensibilityElement policyElement : wsdlDefinitions.getExtensibilityElements(Constants.WSDL_ELEMENT_POLICY))
+ {
+ Policy policy = factory.createPolicy(policyElement.getElement());
+ localPolicyElementsMap.put(policy.getID(), policy);
+ }
- if (policyReferenceList != null && policyReferenceList.size() != 0 && epMetaData instanceof ServerEndpointMetaData)
+ WSDLService wsdlService = wsdlDefinitions.getService(epMetaData.getServiceMetaData().getServiceName().getLocalPart());
+ WSDLEndpoint wsdlEndpoint = wsdlService.getEndpoint(epMetaData.getPortName());
+ WSDLInterface wsdlInterface = wsdlDefinitions.getInterface(epMetaData.getPortTypeName());
+ WSDLBinding wsdlBinding = wsdlDefinitions.getBindingByInterfaceName(epMetaData.getPortTypeName());
+
+ //Port scope
+ List<WSDLExtensibilityElement> portPolicyRefList = wsdlEndpoint.getExtensibilityElements(Constants.WSDL_ELEMENT_POLICYREFERENCE);
+ deployPolicies(portPolicyRefList, localPolicyElementsMap, epMetaData);
+
+ //Binding scope
+ List<WSDLExtensibilityElement> bindingPolicyRefList = wsdlBinding.getExtensibilityElements(Constants.WSDL_ELEMENT_POLICYREFERENCE);
+ deployPolicies(bindingPolicyRefList, localPolicyElementsMap, epMetaData);
+
+ //PortType scope
+ List<WSDLExtensibilityElement> portTypePolicyRefList = wsdlInterface.getExtensibilityElements(Constants.WSDL_PROPERTY_POLICYURIS);
+ deployPolicies(portTypePolicyRefList, localPolicyElementsMap, epMetaData);
+
+ }
+
+
+ private void deployPolicies(List<WSDLExtensibilityElement> policyReferences, Map<String,Policy> localPolicies, ExtensibleMetaData extMetaData)
+ {
+ if (policyReferences != null && policyReferences.size() != 0 && extMetaData instanceof ServerEndpointMetaData)
{
- for (WSDLExtensibilityElement element : policyReferenceList)
+ PolicyFactory factory = PolicyFactory.newInstance();
+ for (WSDLExtensibilityElement element : policyReferences)
{
- for (WSDLExtensibilityElement policyElement : wsdlDefinitions.getExtensibilityElements(element.getElement().getAttribute("URI").substring(1)))
+ boolean local = true;
+ String uri = element.getElement().getAttribute("URI");
+ //TODO!!!
+ //process uri
+ if (local)
{
- PolicyMetaExtension ext = new PolicyMetaExtension(Constants.URI_WS_POLICY);
- Policy policy = PolicyFactory.newInstance().createPolicy(policyElement.getElement());
- try
- {
- Policy deployedPolicy = PolicyDeployer.getInstance().deployServerside(policy, sepMetaData);
- ext.setPolicy(deployedPolicy);
- sepMetaData.addExtension(ext);
- }
- catch (UnsupportedPolicy e)
- {
- if (log.isDebugEnabled())
- {
- log.debug("Policy Not supported:" + policy.toXMLString(true));
- }
- }
-
+ Policy policy = localPolicies.get(uri.substring(1)); //get rid of '#'
+ //clone the policy before asking for deployment
+ deployPolicy(factory.createPolicy(policy.toElement()),extMetaData);
}
-
+ else
+ {
+ //TODO!!! get the policy definition, create the policy and deploy it
+ }
}
-
}
}
+ private void deployPolicy(Policy policy, ExtensibleMetaData extMetaData)
+ {
+ PolicyMetaExtension ext = new PolicyMetaExtension(Constants.URI_WS_POLICY);
+ try
+ {
+ Policy deployedPolicy = PolicyDeployer.getInstance().deployServerside(policy, extMetaData);
+ ext.setPolicy(deployedPolicy);
+ extMetaData.addExtension(ext);
+ }
+ catch (UnsupportedPolicy e)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Policy Not supported:" + policy.toXMLString(true));
+ }
+ }
+ }
+
+
protected void processEndpointMetaDataExtensions(EndpointMetaData epMetaData, WSDLDefinitions wsdlDefinitions)
{
for (WSDLInterface wsdlInterface : wsdlDefinitions.getInterfaces())
17 years, 8 months
JBossWS SVN: r2953 - in branches/jbossws-2.0: jbossws-core/src/java/org/jboss/ws/core/jaxrpc/handler and 3 other directories.
by jbossws-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2007-05-03 07:47:53 -0400 (Thu, 03 May 2007)
New Revision: 2953
Removed:
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/core/server/PropertyCallback.java
Modified:
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/core/CommonMessageContext.java
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/handler/MessageContextJAXRPC.java
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/core/server/ServiceEndpointManager.java
branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/jbws1179/TestEndpointImpl.java
branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/jbws1619/ClientHandler.java
branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/jbws1619/SessionCreatingServlet.java
branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/jbws1619/TestEndpointImpl.java
Log:
Remove support for "javax.xml.ws.servlet.session" message context property.
Fix JBWS-1619 ClientHandler
Modified: branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/core/CommonMessageContext.java
===================================================================
--- branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/core/CommonMessageContext.java 2007-05-03 08:21:10 UTC (rev 2952)
+++ branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/core/CommonMessageContext.java 2007-05-03 11:47:53 UTC (rev 2953)
@@ -34,7 +34,6 @@
import org.jboss.logging.Logger;
import org.jboss.ws.core.jaxrpc.binding.SerializationContext;
-import org.jboss.ws.core.server.PropertyCallback;
import org.jboss.ws.extensions.xop.XOPContext;
import org.jboss.ws.metadata.umdm.EndpointMetaData;
import org.jboss.ws.metadata.umdm.OperationMetaData;
@@ -376,11 +375,7 @@
public Object getValue()
{
- Object realValue = value;
- if (value instanceof PropertyCallback)
- realValue = ((PropertyCallback)value).get();
-
- return realValue;
+ return value;
}
public String toString()
Modified: branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/handler/MessageContextJAXRPC.java
===================================================================
--- branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/handler/MessageContextJAXRPC.java 2007-05-03 08:21:10 UTC (rev 2952)
+++ branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/handler/MessageContextJAXRPC.java 2007-05-03 11:47:53 UTC (rev 2953)
@@ -28,7 +28,6 @@
import java.util.Map;
import javax.xml.rpc.handler.MessageContext;
-import javax.xml.soap.SOAPMessage;
import org.jboss.logging.Logger;
import org.jboss.ws.core.CommonMessageContext;
@@ -56,7 +55,6 @@
public static final String SERVLET_CONTEXT = "javax.xml.ws.servlet.context";
public static final String SERVLET_REQUEST = "javax.xml.ws.servlet.request";
public static final String SERVLET_RESPONSE = "javax.xml.ws.servlet.response";
- public static final String SERVLET_SESSION = "javax.xml.ws.servlet.session";
public MessageContextJAXRPC()
{
Deleted: branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/core/server/PropertyCallback.java
===================================================================
--- branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/core/server/PropertyCallback.java 2007-05-03 08:21:10 UTC (rev 2952)
+++ branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/core/server/PropertyCallback.java 2007-05-03 11:47:53 UTC (rev 2953)
@@ -1,39 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ws.core.server;
-
-/**
- * Interface to be implemented by property helpers to assist the retrieval
- * of objects added to the property context.
- *
- * If an instance of MessageContextPropertyHelper is added to the
- * CommonMessageContext a call to get for the same property will return
- * the result of callig get on the helper instead of returning the helper
- * itself.
- *
- * @author darran.lofthouse(a)jboss.com
- * @since Oct 22, 2006
- */
-public interface PropertyCallback
-{
- Object get();
-}
Modified: branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/core/server/ServiceEndpointManager.java
===================================================================
--- branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/core/server/ServiceEndpointManager.java 2007-05-03 08:21:10 UTC (rev 2952)
+++ branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/core/server/ServiceEndpointManager.java 2007-05-03 11:47:53 UTC (rev 2953)
@@ -412,7 +412,6 @@
HttpServletRequest httpRequest = context.getHttpServletRequest();
HttpServletResponse httpResponse = context.getHttpServletResponse();
ServletHeaderSource headerSource = new ServletHeaderSource(httpRequest, httpResponse);
- HttpSessionPropertyCallback httpSession = new HttpSessionPropertyCallback(context);
// Associate a message context with the current thread
CommonMessageContext msgContext;
@@ -422,7 +421,6 @@
msgContext.put(MessageContextJAXRPC.SERVLET_CONTEXT, servletContext);
msgContext.put(MessageContextJAXRPC.SERVLET_REQUEST, httpRequest);
msgContext.put(MessageContextJAXRPC.SERVLET_RESPONSE, httpResponse);
- msgContext.put(MessageContextJAXRPC.SERVLET_SESSION, httpSession);
}
else
{
@@ -714,19 +712,4 @@
}
return server;
}
-
- public static class HttpSessionPropertyCallback implements PropertyCallback
- {
- private EndpointContext context;
-
- public HttpSessionPropertyCallback(final EndpointContext context)
- {
- this.context = context;
- }
-
- public Object get()
- {
- return context.getHttpSession();
- }
- }
}
Modified: branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/jbws1179/TestEndpointImpl.java
===================================================================
--- branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/jbws1179/TestEndpointImpl.java 2007-05-03 08:21:10 UTC (rev 2952)
+++ branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/jbws1179/TestEndpointImpl.java 2007-05-03 11:47:53 UTC (rev 2953)
@@ -23,6 +23,7 @@
import java.rmi.RemoteException;
+import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.jboss.ws.core.CommonMessageContext;
@@ -45,7 +46,8 @@
public boolean canAccessSession() throws RemoteException
{
CommonMessageContext context = MessageContextAssociation.peekMessageContext();
- HttpSession session = (HttpSession)context.get(MessageContextJAXRPC.SERVLET_SESSION);
+ HttpServletRequest request = (HttpServletRequest)context.get(MessageContextJAXRPC.SERVLET_REQUEST);
+ HttpSession session = (HttpSession)request.getSession();
session.setAttribute("Test", "Test String");
String testString = (String)session.getAttribute("Test");
Modified: branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/jbws1619/ClientHandler.java
===================================================================
--- branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/jbws1619/ClientHandler.java 2007-05-03 08:21:10 UTC (rev 2952)
+++ branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/jbws1619/ClientHandler.java 2007-05-03 11:47:53 UTC (rev 2953)
@@ -53,17 +53,14 @@
try
{
- if ("Use MessageContext".equals(message))
- {
- SOAPMessageContext soapContext = (SOAPMessageContext)msgContext;
- MimeHeaders mimeHeaders = soapContext.getMessage().getMimeHeaders();
+ SOAPMessageContext soapContext = (SOAPMessageContext)msgContext;
+ MimeHeaders mimeHeaders = soapContext.getMessage().getMimeHeaders();
- String[] cookies = mimeHeaders.getHeader("Set-Cookie");
- if (cookies == null || cookies.length != 1)
- throw new IllegalStateException("Unexpected cookie list: " + mimeHeaders);
+ String[] cookies = mimeHeaders.getHeader("Set-Cookie");
+ if (cookies == null || cookies.length != 1)
+ throw new IllegalStateException("Unexpected cookie list: " + mimeHeaders);
- cookie = cookies[0];
- }
+ cookie = cookies[0];
}
catch (Exception e)
{
Modified: branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/jbws1619/SessionCreatingServlet.java
===================================================================
--- branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/jbws1619/SessionCreatingServlet.java 2007-05-03 08:21:10 UTC (rev 2952)
+++ branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/jbws1619/SessionCreatingServlet.java 2007-05-03 11:47:53 UTC (rev 2953)
@@ -54,8 +54,7 @@
private void process(HttpServletRequest httpServletRequest) throws IOException
{
HttpSession session = httpServletRequest.getSession();
- String msg = "Session id:" + session.getId();
- log.info(msg);
+ log.info("Session id: " + session.getId());
}
}
Modified: branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/jbws1619/TestEndpointImpl.java
===================================================================
--- branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/jbws1619/TestEndpointImpl.java 2007-05-03 08:21:10 UTC (rev 2952)
+++ branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/jbws1619/TestEndpointImpl.java 2007-05-03 11:47:53 UTC (rev 2953)
@@ -21,19 +21,21 @@
*/
package org.jboss.test.ws.jaxrpc.jbws1619;
-import org.jboss.logging.Logger;
+import java.rmi.RemoteException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.xml.rpc.ServiceException;
import javax.xml.rpc.handler.MessageContext;
import javax.xml.rpc.server.ServiceLifecycle;
import javax.xml.rpc.server.ServletEndpointContext;
-import java.rmi.RemoteException;
+import org.jboss.logging.Logger;
+import org.jboss.ws.core.jaxrpc.handler.MessageContextJAXRPC;
+
public class TestEndpointImpl implements TestEndpoint, ServiceLifecycle
{
private Logger log = Logger.getLogger(TestEndpointImpl.class);
@@ -42,6 +44,8 @@
public String echoString(String message) throws RemoteException
{
+ log.info("echoString: " + message);
+
HttpSession httpSession = null;
if ("Use ServletEndpointContext".equals(message))
{
@@ -50,7 +54,8 @@
else if ("Use MessageContext".equals(message))
{
MessageContext msgContext = context.getMessageContext();
- httpSession = (HttpSession)msgContext.getProperty("javax.xml.ws.servlet.session");
+ HttpServletRequest req = (HttpServletRequest)msgContext.getProperty(MessageContextJAXRPC.SERVLET_REQUEST);
+ httpSession = req.getSession();
}
else if ("Use RequestDispatcher".equals(message))
{
@@ -59,8 +64,10 @@
RequestDispatcher dispatcher = servletContext.getRequestDispatcher("/");
try
{
- dispatcher.include((ServletRequest)msgContext.getProperty("javax.xml.ws.servlet.request"),
- (ServletResponse)msgContext.getProperty("javax.xml.ws.servlet.response"));
+ HttpServletRequest req = (HttpServletRequest)msgContext.getProperty(MessageContextJAXRPC.SERVLET_REQUEST);
+ HttpServletResponse res = (HttpServletResponse)msgContext.getProperty(MessageContextJAXRPC.SERVLET_RESPONSE);
+ dispatcher.include(req, res);
+ httpSession = req.getSession(false);
}
catch (Exception e)
{
@@ -68,8 +75,10 @@
}
}
- log.info("echoString: " + httpSession);
- return "httpSession: " + httpSession;
+ String sessionID = (httpSession != null ? httpSession.getId() : null);
+ log.info("sessionID: " + sessionID);
+
+ return "httpSession: " + sessionID;
}
public void init(Object context) throws ServiceException
17 years, 8 months
JBossWS SVN: r2952 - in branches/JBWS-856/jbossws-core/src/java/org/jboss/ws: extensions/policy/deployer and 3 other directories.
by jbossws-commits@lists.jboss.org
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",WSSecurityAssertionDeployer.class);
}
//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.
17 years, 8 months
JBossWS SVN: r2951 - in branches/JBWS-856: jbossws-core/src/java/org/jboss/ws/tools/wsdl and 2 other directories.
by jbossws-commits@lists.jboss.org
Author: palin
Date: 2007-05-01 19:12:59 -0400 (Tue, 01 May 2007)
New Revision: 2951
Modified:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/wsdl/Extendable.java
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/tools/wsdl/WSDL11Reader.java
branches/JBWS-856/jbossws-tests/src/java/org/jboss/test/ws/common/wsdl11/WSDL11TestCase.java
branches/JBWS-856/jbossws-tests/src/java/org/jboss/test/ws/tools/validation/WSDLValidationHelper.java
branches/JBWS-856/jbossws-tests/src/java/org/jboss/test/ws/tools/validation/WSDLValidator.java
Log:
Modified the WSDL validator in order to check policy attachments too.
Modified: branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/wsdl/Extendable.java
===================================================================
--- branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/wsdl/Extendable.java 2007-05-01 15:45:11 UTC (rev 2950)
+++ branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/wsdl/Extendable.java 2007-05-01 23:12:59 UTC (rev 2951)
@@ -102,7 +102,8 @@
public List<WSDLExtensibilityElement> getExtensibilityElements(String uri)
{
- return extElements.get(uri);
+ List<WSDLExtensibilityElement> list = extElements.get(uri);
+ return list == null ? new ArrayList<WSDLExtensibilityElement>() : list;
}
public List<WSDLExtensibilityElement> getAllExtensibilityElements()
Modified: branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/tools/wsdl/WSDL11Reader.java
===================================================================
--- branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/tools/wsdl/WSDL11Reader.java 2007-05-01 15:45:11 UTC (rev 2950)
+++ branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/tools/wsdl/WSDL11Reader.java 2007-05-01 23:12:59 UTC (rev 2951)
@@ -356,8 +356,19 @@
private void copyMissingNamespaceDeclarations(Element destElement, Element srcElement)
{
String prefix = destElement.getPrefix();
- if (prefix!=null && destElement.lookupNamespaceURI(prefix) == null)
+ String nsUri;
+ try
+ {
+ nsUri = DOMUtils.getElementQName(destElement).getNamespaceURI();
+ }
+ catch (IllegalArgumentException e)
+ {
+ nsUri = null;
+ }
+ if (prefix!=null && nsUri == null)
+ {
destElement.setAttribute("xmlns:"+prefix, srcElement.lookupNamespaceURI(prefix));
+ }
NamedNodeMap attributes = destElement.getAttributes();
for (int i = 0; i < attributes.getLength(); i++)
@@ -365,7 +376,9 @@
Attr attr = (Attr)attributes.item(i);
String attrPrefix = attr.getPrefix();
if (attrPrefix!=null && !attr.getName().startsWith("xmlns") && destElement.lookupNamespaceURI(attrPrefix) == null)
+ {
destElement.setAttribute("xmlns:"+attrPrefix, srcElement.lookupNamespaceURI(attrPrefix));
+ }
}
NodeList childrenList = destElement.getChildNodes();
for (int i=0; i<childrenList.getLength(); i++)
@@ -376,6 +389,7 @@
}
}
+
private void processSchemaImport(WSDLTypes types, URL wsdlLoc, Element importEl) throws IOException, WSDLException
{
if (wsdlLoc == null)
Modified: branches/JBWS-856/jbossws-tests/src/java/org/jboss/test/ws/common/wsdl11/WSDL11TestCase.java
===================================================================
--- branches/JBWS-856/jbossws-tests/src/java/org/jboss/test/ws/common/wsdl11/WSDL11TestCase.java 2007-05-01 15:45:11 UTC (rev 2950)
+++ branches/JBWS-856/jbossws-tests/src/java/org/jboss/test/ws/common/wsdl11/WSDL11TestCase.java 2007-05-01 23:12:59 UTC (rev 2951)
@@ -28,7 +28,6 @@
import javax.xml.namespace.QName;
import org.jboss.test.ws.JBossWSTest;
-import org.jboss.test.ws.tools.validation.WSDLValidationHelper;
import org.jboss.test.ws.tools.validation.WSDLValidator;
import org.jboss.ws.Constants;
import org.jboss.ws.core.utils.IOUtils;
@@ -310,7 +309,6 @@
WSDLDefinitions newWsdlDefinitions = factory.parse(new File(wsdlDir+"/GeneratedWsdlWithPolicies.wsdl").toURL());
assertNotNull(newWsdlDefinitions);
WSDLValidator validator = new WSDLValidator();
- //TODO!!! Modify the WSDLValidator to validate policy attachments too
assertTrue(validator.validate(wsdlDefinitions,newWsdlDefinitions));
}
Modified: branches/JBWS-856/jbossws-tests/src/java/org/jboss/test/ws/tools/validation/WSDLValidationHelper.java
===================================================================
--- branches/JBWS-856/jbossws-tests/src/java/org/jboss/test/ws/tools/validation/WSDLValidationHelper.java 2007-05-01 15:45:11 UTC (rev 2950)
+++ branches/JBWS-856/jbossws-tests/src/java/org/jboss/test/ws/tools/validation/WSDLValidationHelper.java 2007-05-01 23:12:59 UTC (rev 2951)
@@ -21,24 +21,34 @@
*/
package org.jboss.test.ws.tools.validation;
+import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import javax.xml.namespace.QName;
+import org.jboss.logging.Logger;
+import org.jboss.ws.Constants;
+import org.jboss.ws.core.utils.DOMUtils;
+import org.jboss.ws.metadata.wsdl.Extendable;
import org.jboss.ws.metadata.wsdl.WSDLBinding;
import org.jboss.ws.metadata.wsdl.WSDLBindingOperation;
import org.jboss.ws.metadata.wsdl.WSDLBindingOperationInput;
import org.jboss.ws.metadata.wsdl.WSDLBindingOperationOutput;
import org.jboss.ws.metadata.wsdl.WSDLDefinitions;
import org.jboss.ws.metadata.wsdl.WSDLEndpoint;
+import org.jboss.ws.metadata.wsdl.WSDLExtensibilityElement;
import org.jboss.ws.metadata.wsdl.WSDLInterface;
import org.jboss.ws.metadata.wsdl.WSDLInterfaceOperation;
import org.jboss.ws.metadata.wsdl.WSDLInterfaceOperationInfault;
import org.jboss.ws.metadata.wsdl.WSDLInterfaceOperationInput;
import org.jboss.ws.metadata.wsdl.WSDLInterfaceOperationOutfault;
import org.jboss.ws.metadata.wsdl.WSDLInterfaceOperationOutput;
+import org.jboss.ws.metadata.wsdl.WSDLProperty;
import org.jboss.ws.metadata.wsdl.WSDLService;
import org.jboss.ws.tools.exceptions.JBossWSToolsException;
+import org.w3c.dom.Element;
/**
* WSDL Validator Helper class
@@ -47,6 +57,9 @@
*/
public class WSDLValidationHelper
{
+
+ private final static Logger log = Logger.getLogger(WSDLValidationHelper.class);
+
/**
* Validate the WSDLBinding objects
* @param w1 WSDLDefinitions object for the first wsdl
@@ -56,7 +69,7 @@
*/
public static boolean validateBindings(WSDLDefinitions w1, WSDLDefinitions w2)
throws JBossWSToolsException
- { boolean bool = false;
+ { boolean bool = true;
WSDLBinding[] bindings1 = w1.getBindings();
WSDLBinding[] bindings2 = w2.getBindings();
if (bindings1 == null || bindings1.length == 0)
@@ -74,7 +87,8 @@
{
WSDLBinding binding1 = bindings1[i];
WSDLBinding binding2 = bindings2[i];
- bool = validateBindingOperations(binding1.getOperations(),binding2.getOperations());
+ bool = bool && validateExtensibilityElements(binding1, binding2);
+ bool = bool && validateBindingOperations(binding1.getOperations(),binding2.getOperations());
}
return bool;
}
@@ -106,6 +120,8 @@
WSDLInterface wi2 = wiarr2[i];
if(checkQNameEquality(wi1.getName(),wi2.getName()) == false)
throw new JBossWSToolsException("Interface mismatch");
+ if (!validateExtensibilityElements(wi1,wi2))
+ throw new JBossWSToolsException("WSDLEntensibilityElement mismatch");
WSDLInterfaceOperation[] wioparr1 = wi1.getOperations();
WSDLInterfaceOperation[] wioparr2 = wi2.getOperations();
@@ -123,6 +139,104 @@
}
/**
+ * Validates the extensibility elements contained into the specified Extendable
+ * objects.
+ * @param w1
+ * @param w2
+ * @return
+ * @throws JBossWSToolsException
+ */
+ public static boolean validateExtensibilityElements(Extendable ext1, Extendable ext2)
+ throws JBossWSToolsException
+ {
+ boolean bool = true;
+ //add validation of further extensibility element types below
+ if (bool) bool = validatePolicyElements(ext1,ext2);
+
+ return bool;
+ }
+
+
+ private static boolean validatePolicyElements(Extendable ext1, Extendable ext2)
+ throws JBossWSToolsException
+ {
+ //policies
+ List<WSDLExtensibilityElement> pol1 = new ArrayList<WSDLExtensibilityElement>(
+ ext1.getExtensibilityElements(Constants.WSDL_ELEMENT_POLICY));
+ List<WSDLExtensibilityElement> pol2 = new ArrayList<WSDLExtensibilityElement>(
+ ext2.getExtensibilityElements(Constants.WSDL_ELEMENT_POLICY));
+ //check whether lists are the same size
+ if (pol1.size() != pol2.size())
+ throw new JBossWSToolsException("Policy WSDLExtensibilityElement mismatch!");
+ //check equality
+ for (WSDLExtensibilityElement el1 : pol1)
+ {
+ boolean done = false;
+ Iterator it = pol2.iterator();
+ WSDLExtensibilityElement el2 = null;
+ while (it.hasNext() && !done)
+ {
+ el2 = (WSDLExtensibilityElement)it.next();
+ done = (el1.isRequired() == el2.isRequired()) &&
+ checkElementEquality(el1.getElement(), el2.getElement());
+ }
+ if (!done)
+ {
+ log.error("Failing policy validation on policy on: "+ext1+" and "+ext2);
+ return false;
+ }
+ pol2.remove(el2);
+ }
+ //policy references
+ List<WSDLExtensibilityElement> polRef1 = new ArrayList<WSDLExtensibilityElement>(
+ ext1.getExtensibilityElements(Constants.WSDL_ELEMENT_POLICYREFERENCE));
+ List<WSDLExtensibilityElement> polRef2 = new ArrayList<WSDLExtensibilityElement>(
+ ext2.getExtensibilityElements(Constants.WSDL_ELEMENT_POLICYREFERENCE));
+ //check whether lists are the same size
+ if (polRef1.size() != polRef2.size())
+ throw new JBossWSToolsException("Policy ref WSDLExtensibilityElement mismatch!");
+ //check equality
+ for (WSDLExtensibilityElement el1 : polRef1)
+ {
+ boolean done = false;
+ Iterator it = polRef2.iterator();
+ WSDLExtensibilityElement el2 = null;
+ while (it.hasNext() && !done)
+ {
+ el2 = (WSDLExtensibilityElement)it.next();
+ done = (el1.isRequired() == el2.isRequired()) &&
+ checkElementEquality(el1.getElement(), el2.getElement());
+ }
+ if (!done)
+ {
+ log.error("Failing policy validation on policy ref on: "+ext1+" and "+ext2);
+ return false;
+ }
+ polRef2.remove(el2);
+ }
+ //check properties
+ WSDLProperty prop1 = ext1.getProperty(Constants.WSDL_PROPERTY_POLICYURIS);
+ WSDLProperty prop2 = ext2.getProperty(Constants.WSDL_PROPERTY_POLICYURIS);
+ if (prop1 != null || prop2 != null)
+ {
+ if (prop1 == null || prop2 == null || prop1.isRequired() != prop2.isRequired())
+ throw new JBossWSToolsException("Policy prop WSDLExtensibilityElement mismatch!");
+ String value1 = prop1.getValue();
+ String value2 = prop2.getValue();
+ if (value1 != null || value2 != null)
+ {
+ if (value1 == null || value2 == null || !value1.equalsIgnoreCase(value2))
+ {
+ log.error("Failing policy validation on policy uri prop on: "+ext1+" and "+ext2);
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+
+ /**
* Validates the namespace definitions in the wsdl
* @param w1 WSDL Definitions for the first wsdl
* @param w2 WSDL Definitions for the second wsdl
@@ -215,9 +329,10 @@
bool = checkQNameEquality(s1.getName(),s2.getName());
if(bool)
{
+ bool = validateExtensibilityElements(s1, s2);
WSDLEndpoint[] we1 = s1.getEndpoints();
WSDLEndpoint[] we2 = s2.getEndpoints();
- bool = validateWSDLEndpoints(we1, we2);
+ bool = bool && validateWSDLEndpoints(we1, we2);
}
}
return bool;
@@ -238,11 +353,47 @@
return true;
}
+ /**
+ * Compare two Element (s) for equality (this cares about child elements and attributes only)
+ * @param el1
+ * @param el2
+ * @return
+ */
+ private static boolean checkElementEquality(Element el1, Element el2)
+ {
+ QName qName1 = DOMUtils.getElementQName(el1);
+ QName qName2 = DOMUtils.getElementQName(el2);
+ if (!checkQNameEquality(qName1,qName2)) return false;
+ Map attributes1 = DOMUtils.getAttributes(el1); //map <QName, String>
+ Map attributes2 = DOMUtils.getAttributes(el2);
+ if (attributes1.size()!=attributes2.size()) return false;
+ for (Iterator it = attributes1.keySet().iterator(); it.hasNext(); )
+ {
+ QName key = (QName)it.next();
+ if (key.getPrefix().startsWith("xmlns")) continue;
+ if (!attributes2.containsKey(key)) return false;
+ String value1 = (String)attributes1.get(key);
+ String value2 = (String)attributes2.get(key);
+ if (!value1.equals(value2)) return false;
+ }
+ for (Iterator it = DOMUtils.getChildElements(el1); it.hasNext(); )
+ {
+ Element child1 = (Element)it.next();
+ Iterator it2 = DOMUtils.getChildElements(el2, DOMUtils.getElementQName(child1));
+ if (!it2.hasNext()) return false;
+ Element child2 = (Element)it2.next();
+ if (it2.hasNext() || !checkElementEquality(child1, child2)) return false;
+ }
+ return true;
+ }
+
+
private static boolean validateInterfaceOperation(WSDLInterfaceOperation w1,
WSDLInterfaceOperation w2) throws JBossWSToolsException
{
boolean bool = checkQNameEquality(w1.getName(),w2.getName());
+ bool = bool && validateExtensibilityElements(w1, w2);
if(bool)
{
//validate the inputs
@@ -323,6 +474,9 @@
bool = checkQNameEquality(xmlName1,xmlName2);
if(bool == false)
throw new JBossWSToolsException(xmlName1 + " & " + xmlName2 + " mismatch");
+ bool = validateExtensibilityElements(i1, i2);
+ if(bool == false)
+ throw new JBossWSToolsException("WSDLExtensibilityElement mismatch");
return bool;
}
@@ -374,6 +528,7 @@
WSDLBindingOperationInput bindin1 = wb1[i];
WSDLBindingOperationInput bindin2 = wb2[i];
bool = checkStringEquality(bindin1.getMessageLabel(),bindin2.getMessageLabel());
+ bool = bool & validateExtensibilityElements(bindin1, bindin2);
if(!bool) return bool;
}
@@ -390,6 +545,7 @@
WSDLBindingOperationOutput bindout2 = wboutarr2[i];
bool = checkStringEquality(bindout1.getMessageLabel(),bindout2.getMessageLabel());
}
+ bool = bool & validateExtensibilityElements(b1, b2);
return bool;
}
@@ -416,6 +572,7 @@
bool = checkQNameEquality(e1.getName(),e2.getName());
if(bool == false)
throw new JBossWSToolsException("Endpoint Names do not match");
+ bool = bool && validateExtensibilityElements(e1, e2);
}
return bool;
}
Modified: branches/JBWS-856/jbossws-tests/src/java/org/jboss/test/ws/tools/validation/WSDLValidator.java
===================================================================
--- branches/JBWS-856/jbossws-tests/src/java/org/jboss/test/ws/tools/validation/WSDLValidator.java 2007-05-01 15:45:11 UTC (rev 2950)
+++ branches/JBWS-856/jbossws-tests/src/java/org/jboss/test/ws/tools/validation/WSDLValidator.java 2007-05-01 23:12:59 UTC (rev 2951)
@@ -100,6 +100,8 @@
{
boolean bool = false;
bool = WSDLValidationHelper.validateNSDefinitions(wsdlExp,wsdlAct);
+ if ( bool )
+ bool = WSDLValidationHelper.validateExtensibilityElements(wsdlExp,wsdlAct);
if( bool)
bool = WSDLValidationHelper.validateBindings(wsdlExp,wsdlAct);
if( bool)
17 years, 8 months
JBossWS SVN: r2950 - in branches/JBWS-856/jbossws-core: src/java/org/jboss/ws/extensions/policy and 4 other directories.
by jbossws-commits@lists.jboss.org
Author: maeste
Date: 2007-05-01 11:45:11 -0400 (Tue, 01 May 2007)
New Revision: 2950
Added:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/AssertionDeployer.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/extensions/policy/deployer/exceptions/
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/exceptions/UnsupportedAlternative.java
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/exceptions/UnsupportedAssertion.java
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/exceptions/UnsupportedPolicy.java
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/metadata/
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/metadata/PolicyMetaExtension.java
Modified:
branches/JBWS-856/jbossws-core/.classpath
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/PolicyAssertion.java
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/PolicyFactory.java
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/builder/MetaDataBuilder.java
Log:
First implementation of PolicyDeployer
Modified: branches/JBWS-856/jbossws-core/.classpath
===================================================================
--- branches/JBWS-856/jbossws-core/.classpath 2007-04-30 20:08:38 UTC (rev 2949)
+++ branches/JBWS-856/jbossws-core/.classpath 2007-05-01 15:45:11 UTC (rev 2950)
@@ -33,5 +33,6 @@
<classpathentry kind="lib" path="/build/thirdparty/getopt.jar"/>
<classpathentry kind="lib" path="/build/thirdparty/jboss-common-core.jar" sourcepath="/build/thirdparty/jboss-common-core-sources.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/jbossws-api"/>
+ <classpathentry kind="lib" path="/build/thirdparty/policy.jar"/>
<classpathentry kind="output" path="output-eclipse"/>
</classpath>
Modified: branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/PolicyAssertion.java
===================================================================
--- branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/PolicyAssertion.java 2007-04-30 20:08:38 UTC (rev 2949)
+++ branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/PolicyAssertion.java 2007-05-01 15:45:11 UTC (rev 2950)
@@ -52,11 +52,13 @@
public class PolicyAssertion
{
private Element assertionElement;
+ private String nameSpace;
PolicyAssertion(Element element)
{
Document doc = DOMUtils.getOwnerDocument();
this.assertionElement = (Element)doc.adoptNode(element);
+ this.nameSpace = assertionElement.getNamespaceURI();
}
public Element getElement()
@@ -73,4 +75,10 @@
{
return toXMLString(true);
}
+
+ public String getNameSpace()
+ {
+ return nameSpace;
+ }
+
}
Modified: branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/PolicyFactory.java
===================================================================
--- branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/PolicyFactory.java 2007-04-30 20:08:38 UTC (rev 2949)
+++ branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/PolicyFactory.java 2007-05-01 15:45:11 UTC (rev 2950)
@@ -23,17 +23,23 @@
// $Id$
+import java.io.File;
import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.util.Iterator;
import javax.xml.namespace.QName;
+import org.apache.xml.utils.DOMBuilder;
import org.jboss.ws.WSException;
import org.jboss.ws.core.utils.DOMUtils;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
+
+
/**
* A factory for Policy construction
*
@@ -113,4 +119,7 @@
return policy;
}
+
+
+
}
Added: branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/AssertionDeployer.java
===================================================================
--- branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/AssertionDeployer.java (rev 0)
+++ branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/AssertionDeployer.java 2007-05-01 15:45:11 UTC (rev 2950)
@@ -0,0 +1,10 @@
+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.ExtensibleMetaData;
+
+public interface AssertionDeployer
+{
+ public void deploy(PolicyAssertion assertion, ExtensibleMetaData extMetaData) throws UnsupportedAssertion;
+}
Added: 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 (rev 0)
+++ branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/PolicyDeployer.java 2007-05-01 15:45:11 UTC (rev 2950)
@@ -0,0 +1,144 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.extensions.policy.deployer;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.ws.extensions.policy.Policy;
+import org.jboss.ws.extensions.policy.PolicyAlternative;
+import org.jboss.ws.extensions.policy.PolicyAssertion;
+import org.jboss.ws.extensions.policy.PolicyFactory;
+import org.jboss.ws.extensions.policy.deployer.exceptions.UnsupportedAlternative;
+import org.jboss.ws.extensions.policy.deployer.exceptions.UnsupportedAssertion;
+import org.jboss.ws.extensions.policy.deployer.exceptions.UnsupportedPolicy;
+import org.jboss.ws.metadata.umdm.ExtensibleMetaData;
+
+
+
+/**
+ * @author Stefano Maestri <mailto:stefano.maestri@javalinux.it>
+ *
+ * since 27/04/2007
+ */
+public class PolicyDeployer
+{
+
+ private static PolicyDeployer me;
+ private Map<String, Class> domainDeployerMap = new HashMap<String, Class>();
+
+
+ static {
+ me = new PolicyDeployer();
+ me.domainDeployerMap.put("",Object.class);
+ }
+
+ //hide constructor
+ PolicyDeployer()
+ {
+ }
+
+ public static PolicyDeployer getInstance()
+ {
+ return me;
+ }
+
+ //for test
+ public static PolicyDeployer newInstance(Map<String,Class> specialDomainMap)
+ {
+ PolicyDeployer instance = new PolicyDeployer();
+ instance.domainDeployerMap = specialDomainMap;
+ return instance;
+
+ }
+
+
+ public Policy deployServerside(Policy policy, ExtensibleMetaData extMetaData) throws UnsupportedPolicy
+ {
+ Policy returnedPolicy = PolicyFactory.newInstance().createPolicy(policy.toElement());
+ returnedPolicy.getPolicyAlternatives().clear();
+ for (PolicyAlternative alternative : policy.getPolicyAlternatives())
+ {
+ try
+ {
+ deployAlternativeServerSide(alternative,extMetaData);
+ returnedPolicy.addPolicyAlternative(alternative);
+ }
+ catch (UnsupportedAlternative e)
+ {
+ //policy is unsupported only if it have all alternative unsupported
+ }
+
+ }
+ if (returnedPolicy.getPolicyAlternatives().size() == 0)
+ {
+ throw new UnsupportedPolicy();
+ }
+ return returnedPolicy;
+ }
+
+ public void deployClientSide(Policy policy)
+ {
+
+ }
+
+ private void deployAlternativeServerSide(PolicyAlternative alternative, ExtensibleMetaData extMetaData) throws UnsupportedAlternative
+ {
+ for (PolicyAssertion assertion : alternative.getPolicyAssertions())
+ {
+ try
+ {
+ deployAssertionServerSide(assertion,extMetaData);
+ }
+ catch (UnsupportedAssertion e)
+ {
+ //If there is al least one unsupported assertion the alternative isn't supported
+ throw new UnsupportedAlternative();
+ }
+ }
+ }
+
+ private void deployAssertionServerSide(PolicyAssertion assertion, ExtensibleMetaData extMetaData) throws UnsupportedAssertion
+ {
+ AssertionDeployer deployer = getDomainDeployerInstance(assertion.getNameSpace());
+ deployer.deploy(assertion,extMetaData);
+ }
+
+
+ /**
+ *
+ * @param namespace
+ * @return the correct AssertionDeployer instance, or null if namespace not supported
+ */
+ private AssertionDeployer getDomainDeployerInstance(String namespace) throws UnsupportedAssertion
+ {
+ try {
+ if (! domainDeployerMap.containsKey(namespace) )
+ {
+ throw new UnsupportedAssertion();
+ }
+ return (AssertionDeployer) (domainDeployerMap.get(namespace)).newInstance();
+ } catch (Exception e) {
+ throw new UnsupportedAssertion();
+ }
+ }
+}
Added: branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/exceptions/UnsupportedAlternative.java
===================================================================
--- branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/exceptions/UnsupportedAlternative.java (rev 0)
+++ branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/exceptions/UnsupportedAlternative.java 2007-05-01 15:45:11 UTC (rev 2950)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.extensions.policy.deployer.exceptions;
+
+/**
+ * @author Stefano Maestri <mailto:stefano.maestri@javalinux.it>
+ *
+ * since 27/04/2007
+ */
+public class UnsupportedAlternative extends Exception
+{
+
+}
Added: branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/exceptions/UnsupportedAssertion.java
===================================================================
--- branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/exceptions/UnsupportedAssertion.java (rev 0)
+++ branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/exceptions/UnsupportedAssertion.java 2007-05-01 15:45:11 UTC (rev 2950)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.extensions.policy.deployer.exceptions;
+
+/**
+ * @author Stefano Maestri <mailto:stefano.maestri@javalinux.it>
+ *
+ * since 27/04/2007
+ */
+public class UnsupportedAssertion extends Exception
+{
+
+}
Added: branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/exceptions/UnsupportedPolicy.java
===================================================================
--- branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/exceptions/UnsupportedPolicy.java (rev 0)
+++ branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/exceptions/UnsupportedPolicy.java 2007-05-01 15:45:11 UTC (rev 2950)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.extensions.policy.deployer.exceptions;
+
+/**
+ * @author Stefano Maestri <mailto:stefano.maestri@javalinux.it>
+ *
+ * since 27/04/2007
+ */
+public class UnsupportedPolicy extends Exception
+{
+
+}
Added: branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/metadata/PolicyMetaExtension.java
===================================================================
--- branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/metadata/PolicyMetaExtension.java (rev 0)
+++ branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/metadata/PolicyMetaExtension.java 2007-05-01 15:45:11 UTC (rev 2950)
@@ -0,0 +1,37 @@
+package org.jboss.ws.extensions.policy.metadata;
+
+
+import java.util.List;
+
+import org.jboss.ws.extensions.policy.Policy;
+import org.jboss.ws.extensions.policy.PolicyFactory;
+import org.jboss.ws.metadata.umdm.MetaDataExtension;
+import org.jboss.ws.metadata.wsdl.WSDLDefinitions;
+import org.jboss.ws.metadata.wsdl.WSDLExtensibilityElement;
+import org.w3c.dom.Element;
+
+public class PolicyMetaExtension extends MetaDataExtension
+{
+
+ Policy policy;
+
+
+ public PolicyMetaExtension(String extensionNameSpace)
+ {
+ super(extensionNameSpace);
+ }
+
+
+ public Policy getPolicy()
+ {
+ return policy;
+ }
+
+ public void setPolicy(Policy policy)
+ {
+ this.policy = policy;
+ }
+
+
+
+}
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-04-30 20:08:38 UTC (rev 2949)
+++ branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/builder/MetaDataBuilder.java 2007-05-01 15:45:11 UTC (rev 2950)
@@ -57,6 +57,11 @@
import org.jboss.ws.extensions.eventing.EventingUtils;
import org.jboss.ws.extensions.eventing.deployment.EventingEndpoint;
import org.jboss.ws.extensions.eventing.metadata.EventingEpMetaExt;
+import org.jboss.ws.extensions.policy.Policy;
+import org.jboss.ws.extensions.policy.PolicyFactory;
+import org.jboss.ws.extensions.policy.deployer.PolicyDeployer;
+import org.jboss.ws.extensions.policy.deployer.exceptions.UnsupportedPolicy;
+import org.jboss.ws.extensions.policy.metadata.PolicyMetaExtension;
import org.jboss.ws.metadata.j2ee.UnifiedApplicationMetaData;
import org.jboss.ws.metadata.j2ee.UnifiedBeanMetaData;
import org.jboss.ws.metadata.j2ee.UnifiedEjbPortComponentMetaData;
@@ -72,6 +77,7 @@
import org.jboss.ws.metadata.wsdl.WSDLBindingOperation;
import org.jboss.ws.metadata.wsdl.WSDLDefinitions;
import org.jboss.ws.metadata.wsdl.WSDLEndpoint;
+import org.jboss.ws.metadata.wsdl.WSDLExtensibilityElement;
import org.jboss.ws.metadata.wsdl.WSDLInterface;
import org.jboss.ws.metadata.wsdl.WSDLInterfaceOperation;
import org.jboss.ws.metadata.wsdl.WSDLInterfaceOperationOutput;
@@ -458,6 +464,43 @@
}
}
+ protected void processPolicyMetaDataExtension(EndpointMetaData epMetaData, WSDLDefinitions wsdlDefinitions)
+ {
+ //PolicyReferece at endpointLevel
+ List<WSDLExtensibilityElement> policyReferenceList = wsdlDefinitions.getService(epMetaData.getServiceMetaData().
+ getServiceName().getLocalPart()).getEndpoint(epMetaData.getPortName()).
+ getExtensibilityElements(Constants.WSDL_ELEMENT_POLICYREFERENCE);
+ ServerEndpointMetaData sepMetaData = (ServerEndpointMetaData)epMetaData;
+
+ if (policyReferenceList != null && policyReferenceList.size() != 0 && epMetaData instanceof ServerEndpointMetaData)
+ {
+ for (WSDLExtensibilityElement element : policyReferenceList)
+ {
+ for (WSDLExtensibilityElement policyElement : wsdlDefinitions.getExtensibilityElements(element.getElement().getAttribute("URI")))
+ {
+ PolicyMetaExtension ext = new PolicyMetaExtension(Constants.URI_WS_POLICY);
+ Policy policy = PolicyFactory.newInstance().createPolicy(policyElement.getElement());
+ try
+ {
+ Policy deployedPolicy = PolicyDeployer.getInstance().deployServerside(policy, sepMetaData);
+ ext.setPolicy(deployedPolicy);
+ sepMetaData.addExtension(ext);
+ }
+ catch (UnsupportedPolicy e)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Policy Not supported:" + policy.toXMLString(true));
+ }
+ }
+
+ }
+
+ }
+
+ }
+ }
+
protected void processEndpointMetaDataExtensions(EndpointMetaData epMetaData, WSDLDefinitions wsdlDefinitions)
{
for (WSDLInterface wsdlInterface : wsdlDefinitions.getInterfaces())
@@ -495,6 +538,7 @@
sepMetaData.addExtension(ext);
sepMetaData.setManagedEndpointBean(EventingEndpoint.class.getName());
}
+
}
}
17 years, 8 months