[jboss-svn-commits] JBL Code SVN: r34410 - in labs/jbossesb/trunk/product/samples/quickstarts: security_saml/src/org/jboss/soa/esb/samples/quickstart/securitysaml/webservice and 20 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Jul 30 05:45:23 EDT 2010
Author: mageshbk at jboss.com
Date: 2010-07-30 05:45:21 -0400 (Fri, 30 Jul 2010)
New Revision: 34410
Added:
labs/jbossesb/trunk/product/samples/quickstarts/security_saml/sts-client.properties
labs/jbossesb/trunk/product/samples/quickstarts/webservice_wsaddressing/src_as5/org/jboss/soa/esb/samples/quickstart/webservicewsa/AddressingPort.java
labs/jbossesb/trunk/product/samples/quickstarts/webservice_wsaddressing/war/resources/WEB-INF/jbossws-cxf.xml
labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src_cxf/
labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src_cxf/META-INF/
labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src_cxf/META-INF/alice.jks
labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src_cxf/META-INF/alice.properties
labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src_cxf/org/
labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src_cxf/org/jboss/
labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src_cxf/org/jboss/test/
labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src_cxf/org/jboss/test/ws/
labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src_cxf/org/jboss/test/ws/jaxws/
labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src_cxf/org/jboss/test/ws/jaxws/samples/
labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src_cxf/org/jboss/test/ws/jaxws/samples/wssecurity/
labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src_cxf/org/jboss/test/ws/jaxws/samples/wssecurity/Hello.java
labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src_cxf/org/jboss/test/ws/jaxws/samples/wssecurity/HelloJavaBean.java
labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src_cxf/org/jboss/test/ws/jaxws/samples/wssecurity/KeystorePasswordCallback.java
labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src_cxf/org/jboss/test/ws/jaxws/samples/wssecurity/UserType.java
labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src_cxf/org/jboss/test/ws/jaxws/samples/wssecurity/client/
labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src_cxf/org/jboss/test/ws/jaxws/samples/wssecurity/client/WSSClient.java
labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/war/resources_cxf/
labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/war/resources_cxf/WEB-INF/
labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/war/resources_cxf/WEB-INF/classes/
labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/war/resources_cxf/WEB-INF/classes/bob.jks
labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/war/resources_cxf/WEB-INF/classes/bob.properties
labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/war/resources_cxf/WEB-INF/jboss-web.xml
labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/war/resources_cxf/WEB-INF/jbossws-cxf.xml
labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/war/resources_cxf/WEB-INF/web.xml
Removed:
labs/jbossesb/trunk/product/samples/quickstarts/security_saml/picketlink-sts-client.properties
labs/jbossesb/trunk/product/samples/quickstarts/webservice_wsaddressing/src_as5/org/jboss/soa/esb/samples/quickstart/webservicewsa/client/ClientHandler.java
Modified:
labs/jbossesb/trunk/product/samples/quickstarts/security_saml/build.xml
labs/jbossesb/trunk/product/samples/quickstarts/security_saml/picketlink-sts.war
labs/jbossesb/trunk/product/samples/quickstarts/security_saml/src/org/jboss/soa/esb/samples/quickstart/securitysaml/webservice/handlerchain.xml
labs/jbossesb/trunk/product/samples/quickstarts/security_saml/war/resources/WEB-INF/web.xml
labs/jbossesb/trunk/product/samples/quickstarts/webservice_mtom/src_as5/org/jboss/soa/esb/samples/quickstart/webservicemtom/webservice/client/MTOMClient.java
labs/jbossesb/trunk/product/samples/quickstarts/webservice_wsaddressing/src_as5/org/jboss/soa/esb/samples/quickstart/webservicewsa/ServerHandler.java
labs/jbossesb/trunk/product/samples/quickstarts/webservice_wsaddressing/src_as5/org/jboss/soa/esb/samples/quickstart/webservicewsa/StatefulEndpoint.java
labs/jbossesb/trunk/product/samples/quickstarts/webservice_wsaddressing/src_as5/org/jboss/soa/esb/samples/quickstart/webservicewsa/StatefulEndpointImpl.java
labs/jbossesb/trunk/product/samples/quickstarts/webservice_wsaddressing/src_as5/org/jboss/soa/esb/samples/quickstart/webservicewsa/client/WSAClient.java
labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/build.xml
Log:
[JBESB-3371] - Updated quickstarts to work with AS5.1 configured with CXF.
Modified: labs/jbossesb/trunk/product/samples/quickstarts/security_saml/build.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/security_saml/build.xml 2010-07-30 09:38:21 UTC (rev 34409)
+++ labs/jbossesb/trunk/product/samples/quickstarts/security_saml/build.xml 2010-07-30 09:45:21 UTC (rev 34410)
@@ -6,7 +6,7 @@
</description>
<!-- additional deploys -->
- <property name="additional.deploys" value="jboss-wsse-client.xml, smooks/*.xml, picketlink-sts-client.properties, jboss-service.xml, login-config.xml"/>
+ <property name="additional.deploys" value="jboss-wsse-client.xml, smooks/*.xml, sts-client.properties, jboss-service.xml, login-config.xml"/>
<target name="quickstart-specific-checks" depends="assert-ws-available, assert-as5"/>
@@ -41,7 +41,7 @@
<copy file="${basedir}/login-config-unfiltered.xml" tofile="${basedir}/login-config.xml" filtering="true" overwrite="true">
<filterset>
- <filter token="STS_CONFIG_FILE_PATH" value="${basedir}/picketlink-sts-client.properties"/>
+ <filter token="STS_CONFIG_FILE_PATH" value="${basedir}/sts-client.properties"/>
</filterset>
</copy>
</target>
Deleted: labs/jbossesb/trunk/product/samples/quickstarts/security_saml/picketlink-sts-client.properties
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/security_saml/picketlink-sts-client.properties 2010-07-30 09:38:21 UTC (rev 34409)
+++ labs/jbossesb/trunk/product/samples/quickstarts/security_saml/picketlink-sts-client.properties 2010-07-30 09:45:21 UTC (rev 34410)
@@ -1,5 +0,0 @@
-serviceName=PicketLinkSTS
-portName=PicketLinkSTSPort
-endpointAddress=http://localhost:8080/picketlink-sts/PicketLinkSTS
-username=admin
-password=admin
Modified: labs/jbossesb/trunk/product/samples/quickstarts/security_saml/picketlink-sts.war
===================================================================
(Binary files differ)
Modified: labs/jbossesb/trunk/product/samples/quickstarts/security_saml/src/org/jboss/soa/esb/samples/quickstart/securitysaml/webservice/handlerchain.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/security_saml/src/org/jboss/soa/esb/samples/quickstart/securitysaml/webservice/handlerchain.xml 2010-07-30 09:38:21 UTC (rev 34409)
+++ labs/jbossesb/trunk/product/samples/quickstarts/security_saml/src/org/jboss/soa/esb/samples/quickstart/securitysaml/webservice/handlerchain.xml 2010-07-30 09:45:21 UTC (rev 34410)
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jws:handler-config xmlns:jws="http://java.sun.com/xml/ns/javaee">
- <jws:handler-chains>
- <jws:handler-chain>
- <jws:handler>
- <jws:handler-class>org.picketlink.identity.federation.core.wstrust.handlers.STSSaml20Handler</jws:handler-class>
- </jws:handler>
- </jws:handler-chain>
- </jws:handler-chains>
-</jws:handler-config>
+<handler-chains xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee">
+ <handler-chain>
+ <handler>
+ <handler-class>org.picketlink.identity.federation.core.wstrust.handlers.STSSaml20Handler</handler-class>
+ </handler>
+ </handler-chain>
+</handler-chains>
Added: labs/jbossesb/trunk/product/samples/quickstarts/security_saml/sts-client.properties
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/security_saml/sts-client.properties (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/security_saml/sts-client.properties 2010-07-30 09:45:21 UTC (rev 34410)
@@ -0,0 +1,5 @@
+serviceName=PicketLinkSTS
+portName=PicketLinkSTSPort
+endpointAddress=http://localhost:8080/picketlink-sts/PicketLinkSTS
+username=admin
+password=admin
Modified: labs/jbossesb/trunk/product/samples/quickstarts/security_saml/war/resources/WEB-INF/web.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/security_saml/war/resources/WEB-INF/web.xml 2010-07-30 09:38:21 UTC (rev 34409)
+++ labs/jbossesb/trunk/product/samples/quickstarts/security_saml/war/resources/WEB-INF/web.xml 2010-07-30 09:45:21 UTC (rev 34410)
@@ -18,7 +18,7 @@
<env-entry>
<env-entry-name>STSClientConfig</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
- <env-entry-value>/picketlink-sts-client.properties</env-entry-value>
+ <env-entry-value>/sts-client.properties</env-entry-value>
</env-entry>
</web-app>
Modified: labs/jbossesb/trunk/product/samples/quickstarts/webservice_mtom/src_as5/org/jboss/soa/esb/samples/quickstart/webservicemtom/webservice/client/MTOMClient.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_mtom/src_as5/org/jboss/soa/esb/samples/quickstart/webservicemtom/webservice/client/MTOMClient.java 2010-07-30 09:38:21 UTC (rev 34409)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_mtom/src_as5/org/jboss/soa/esb/samples/quickstart/webservicemtom/webservice/client/MTOMClient.java 2010-07-30 09:45:21 UTC (rev 34410)
@@ -20,6 +20,7 @@
package org.jboss.soa.esb.samples.quickstart.webservicemtom.webservice.client;
import org.jboss.soa.esb.samples.quickstart.webservicemtom.webservice.*;
+import org.jboss.internal.soa.esb.util.JBossDeployerUtil;
import org.jboss.internal.soa.esb.util.StreamUtils;
import javax.xml.namespace.QName;
@@ -78,10 +79,14 @@
SOAPBinding binding = (SOAPBinding)((BindingProvider)mtomEndpoint).getBinding();
binding.setMTOMEnabled(true);
- List<Handler> handlerChain = new ArrayList<Handler>();
- handlerChain.addAll(binding.getHandlerChain());
- handlerChain.add(new MTOMProtocolHandler());
- binding.setHandlerChain(handlerChain);
+ if (JBossDeployerUtil.getWSImpl().equals(JBossDeployerUtil.WSIMPL_NATIVE))
+ {
+ // Set protocol handler only for native client
+ List<Handler> handlerChain = new ArrayList<Handler>();
+ handlerChain.addAll(binding.getHandlerChain());
+ handlerChain.add(new MTOMProtocolHandler());
+ binding.setHandlerChain(handlerChain);
+ }
return mtomEndpoint;
}
Added: labs/jbossesb/trunk/product/samples/quickstarts/webservice_wsaddressing/src_as5/org/jboss/soa/esb/samples/quickstart/webservicewsa/AddressingPort.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_wsaddressing/src_as5/org/jboss/soa/esb/samples/quickstart/webservicewsa/AddressingPort.java (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_wsaddressing/src_as5/org/jboss/soa/esb/samples/quickstart/webservicewsa/AddressingPort.java 2010-07-30 09:45:21 UTC (rev 34410)
@@ -0,0 +1,172 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.
+ *
+ * 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.soa.esb.samples.quickstart.webservicewsa;
+
+import java.io.IOException;
+import java.rmi.RemoteException;
+import java.util.Map;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
+
+import org.jboss.logging.Logger;
+import org.jboss.util.xml.DOMUtils;
+import org.jboss.internal.soa.esb.webservice.addressing.MAP;
+import org.jboss.internal.soa.esb.webservice.addressing.MAPBuilder;
+import org.jboss.internal.soa.esb.webservice.addressing.MAPConstants;
+import org.jboss.internal.soa.esb.webservice.addressing.MAPBuilderFactory;
+import org.jboss.internal.soa.esb.webservice.addressing.MAPEndpoint;
+import org.jboss.wsf.common.utils.UUIDGenerator;
+import org.w3c.dom.Element;
+
+/**
+ * This is a wrapper around the StatefulEndpoint port, setting / handling client IDs
+ * using WS-Addressing (common JSR-261 API).
+ *
+ * The work performed by this class cannot always be done simply using
+ * handlers on client side. That's because (for instance) CXF's
+ * ws-addressing interceptors run before user provided handlers
+ * when dealing with outbound client messages.
+ *
+ * @author alessio.soldano at jboss.com
+ * @author <a href="mailto:mageshbk at jboss.com">mageshbk at jboss.com</a>
+ * @since 27-May-2009
+ *
+ */
+public class AddressingPort implements StatefulEndpoint
+{
+ private static Logger log = Logger.getLogger(AddressingPort.class);
+ private static final QName IDQN = StatefulEndpointImpl.IDQN;
+ private StatefulEndpoint port;
+ private static int maxClientId;
+ private String clientID;
+
+ public AddressingPort(StatefulEndpoint port)
+ {
+ this.port = port;
+ }
+
+
+ public void addItem(String item) throws RemoteException
+ {
+ setClientID("addItem");
+ port.addItem(item);
+ readClientID();
+ }
+
+ public void checkout() throws RemoteException
+ {
+ setClientID("checkout");
+ port.checkout();
+ readClientID();
+ }
+
+ public String getItems() throws RemoteException
+ {
+ setClientID("getItems");
+ String result = port.getItems();
+ readClientID();
+ return result;
+ }
+
+ /**
+ * This installs the ID for this client in the outbound messages
+ */
+ private void setClientID(String action)
+ {
+ BindingProvider bindingProvider = (BindingProvider)port;
+ Map<String, Object> msgContext = bindingProvider.getRequestContext();
+ MAPBuilder builder = MAPBuilderFactory.getInstance().getBuilderInstance();
+ MAPConstants ADDR = builder.newConstants();
+ MAP outProps = builder.newMap();
+ outProps.setTo("uri:jaxrpc-samples-wsaddressing/TestService");
+ outProps.setMessageID("urn:uuid:" + UUIDGenerator.generateRandomUUIDString());
+ outProps.setAction("http://webservice.webservicewsa.quickstart.samples.esb.soa.jboss.org/" + action);
+
+ MAPEndpoint replyTo = builder.newEndpoint(ADDR.getAnonymousURI());
+ outProps.setReplyTo(replyTo);
+
+ // Assign a new clientid
+ if (clientID == null)
+ {
+ clientID = "clientid-" + (++maxClientId);
+ log.info("New clientid: " + clientID);
+ }
+
+ try
+ {
+ Element ele = DOMUtils.parse(getClientIdElement(clientID));
+ replyTo.addReferenceParameter(ele);
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException(e);
+ }
+ outProps.installOutboundMapOnClientSide(msgContext, outProps);
+ }
+
+ /**
+ * This verifies the client ID is available in inbound messages
+ */
+ @SuppressWarnings("unchecked")
+ private void readClientID()
+ {
+ BindingProvider bindingProvider = (BindingProvider)port;
+ Map<String, Object> msgContext = bindingProvider.getResponseContext();
+ MAPBuilder builder = MAPBuilderFactory.getInstance().getBuilderInstance();
+ MAP addrProps = builder.inboundMap(msgContext);
+ if (addrProps == null)
+ return; //throw new IllegalStateException("Cannot obtain AddressingProperties");
+ for (Object obj : addrProps.getReferenceParameters())
+ {
+ if (obj instanceof Element) //Native always uses Element for ref params
+ {
+ Element el = (Element)obj;
+ QName qname = DOMUtils.getElementQName(el);
+ if (qname.equals(IDQN))
+ {
+ clientID = DOMUtils.getTextContent(el);
+ }
+ }
+ else if (obj instanceof JAXBElement) //CXF also uses JAXBElement
+ {
+ JAXBElement<String> el = (JAXBElement<String>)obj;
+ if (IDQN.equals(el.getName()))
+ {
+ clientID = el.getValue();
+ }
+ }
+ }
+ if (clientID == null)
+ throw new IllegalStateException("Cannot obtain clientid");
+ }
+
+ private static String getClientIdElement(String clientid)
+ {
+ String qualname = IDQN.getPrefix() + ":" + IDQN.getLocalPart();
+ StringBuffer buffer = new StringBuffer("<" + qualname);
+ buffer.append(" xmlns:" + IDQN.getPrefix() + "='" + IDQN.getNamespaceURI() + "'");
+ buffer.append(">" + clientid + "</" + qualname + ">");
+ return buffer.toString();
+ }
+}
Modified: labs/jbossesb/trunk/product/samples/quickstarts/webservice_wsaddressing/src_as5/org/jboss/soa/esb/samples/quickstart/webservicewsa/ServerHandler.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_wsaddressing/src_as5/org/jboss/soa/esb/samples/quickstart/webservicewsa/ServerHandler.java 2010-07-30 09:38:21 UTC (rev 34409)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_wsaddressing/src_as5/org/jboss/soa/esb/samples/quickstart/webservicewsa/ServerHandler.java 2010-07-30 09:45:21 UTC (rev 34410)
@@ -21,21 +21,21 @@
*/
package org.jboss.soa.esb.samples.quickstart.webservicewsa;
-import java.net.URISyntaxException;
-
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.JAXBElement;
import javax.xml.namespace.QName;
-import javax.xml.soap.SOAPElement;
-import javax.xml.ws.addressing.AddressingBuilder;
-import javax.xml.ws.addressing.AddressingProperties;
-import javax.xml.ws.addressing.EndpointReference;
-import javax.xml.ws.addressing.JAXWSAConstants;
-import javax.xml.ws.addressing.ReferenceParameters;
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.handler.MessageContext.Scope;
import org.jboss.logging.Logger;
-import org.jboss.util.xml.DOMUtils;
+import org.jboss.wsf.common.DOMUtils;
+import org.jboss.internal.soa.esb.webservice.addressing.MAP;
+import org.jboss.internal.soa.esb.webservice.addressing.MAPBuilder;
+import org.jboss.internal.soa.esb.webservice.addressing.MAPBuilderFactory;
+import org.jboss.internal.soa.esb.webservice.addressing.MAPEndpoint;
import org.jboss.wsf.common.handler.GenericSOAPHandler;
+import org.w3c.dom.Element;
/**
* A server side handler for the ws-addressing
@@ -55,24 +55,39 @@
{
log.info("handleRequest");
- AddressingProperties addrProps = (AddressingProperties)msgContext.get(JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_INBOUND);
+ MAPBuilder builder = MAPBuilderFactory.getInstance().getBuilderInstance();
+ MAP addrProps = builder.inboundMap(msgContext);
+
if (addrProps == null)
throw new IllegalStateException("Cannot obtain AddressingProperties");
String clientid = null;
- EndpointReference replyTo = addrProps.getReplyTo();
- ReferenceParameters refParams = replyTo!=null ? replyTo.getReferenceParameters() : null;
- if (refParams != null)
+ MAPEndpoint replyTo = addrProps.getReplyTo();
+ List<Object> refParams = replyTo == null? new ArrayList<Object>() : replyTo.getReferenceParameters();
+ for (Object obj : refParams)
{
- for (Object obj : refParams.getElements())
+ if (obj instanceof Element)
{
- SOAPElement el = (SOAPElement)obj;
+ Element el = (Element)obj;
QName qname = DOMUtils.getElementQName(el);
if (qname.equals(IDQN))
{
clientid = DOMUtils.getTextContent(el);
}
}
+ else if (obj instanceof JAXBElement)
+ {
+ JAXBElement<String> el = (JAXBElement)obj;
+ QName qname = el.getName();
+ if (qname.equals(IDQN))
+ {
+ clientid = el.getValue();
+ }
+ }
+ else
+ {
+ log.warn("Unsupported reference parameter found: " + obj);
+ }
}
if (clientid == null)
@@ -88,25 +103,17 @@
public boolean handleOutbound(MessageContext msgContext)
{
log.info("handleResponse");
+
+ MAPBuilder builder = MAPBuilderFactory.getInstance().getBuilderInstance();
+ MAP inProps = builder.inboundMap(msgContext);
+ MAP outProps = builder.newMap();
+ if (inProps.getReplyTo() != null)
+ outProps.initializeAsDestination(inProps.getReplyTo());
+ outProps.setAction("http://org.jboss.ws/addressing/stateful/actionReply");
+
+ outProps.installOutboundMapOnServerSide(msgContext, outProps);
+ msgContext.setScope(builder.newConstants().getServerAddressingPropertiesOutbound(), Scope.APPLICATION);
- try
- {
- AddressingProperties inProps = (AddressingProperties)msgContext.get(JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_INBOUND);
- AddressingBuilder builder = AddressingBuilder.getAddressingBuilder();
-
- builder.newAddressingConstants();
- AddressingProperties outProps = builder.newAddressingProperties();
- outProps.initializeAsReply(inProps, false);
- outProps.setAction(builder.newURI("http://org.jboss.ws/addressing/stateful/actionReply"));
-
- msgContext.put(JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_OUTBOUND, outProps);
- msgContext.setScope(JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_OUTBOUND, Scope.APPLICATION);
- }
- catch (URISyntaxException ex)
- {
- throw new IllegalStateException("Cannot handle response", ex);
- }
-
return true;
}
}
Modified: labs/jbossesb/trunk/product/samples/quickstarts/webservice_wsaddressing/src_as5/org/jboss/soa/esb/samples/quickstart/webservicewsa/StatefulEndpoint.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_wsaddressing/src_as5/org/jboss/soa/esb/samples/quickstart/webservicewsa/StatefulEndpoint.java 2010-07-30 09:38:21 UTC (rev 34409)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_wsaddressing/src_as5/org/jboss/soa/esb/samples/quickstart/webservicewsa/StatefulEndpoint.java 2010-07-30 09:45:21 UTC (rev 34410)
@@ -28,13 +28,13 @@
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
+import javax.xml.ws.Action;
-import org.jboss.ws.annotation.EndpointConfig;
-
/**
* WS-Addressing stateful service endpoint interface
*
* @author Thomas.Diesler at jboss.org
+ * @author <a href="mailto:mageshbk at jboss.com">mageshbk at jboss.com</a>
*
* @since 24-Nov-2005
*/
@@ -43,11 +43,14 @@
public interface StatefulEndpoint extends Remote
{
@WebMethod
+ @Action(input="http://webservice.webservicewsa.quickstart.samples.esb.soa.jboss.org/addItem")
public void addItem(String item) throws RemoteException;
@WebMethod
+ @Action(input="http://webservice.webservicewsa.quickstart.samples.esb.soa.jboss.org/checkout")
public void checkout() throws RemoteException;
@WebMethod
+ @Action(input="http://webservice.webservicewsa.quickstart.samples.esb.soa.jboss.org/getItems")
public String getItems() throws RemoteException;
}
Modified: labs/jbossesb/trunk/product/samples/quickstarts/webservice_wsaddressing/src_as5/org/jboss/soa/esb/samples/quickstart/webservicewsa/StatefulEndpointImpl.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_wsaddressing/src_as5/org/jboss/soa/esb/samples/quickstart/webservicewsa/StatefulEndpointImpl.java 2010-07-30 09:38:21 UTC (rev 34409)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_wsaddressing/src_as5/org/jboss/soa/esb/samples/quickstart/webservicewsa/StatefulEndpointImpl.java 2010-07-30 09:45:21 UTC (rev 34410)
@@ -35,9 +35,9 @@
import javax.xml.namespace.QName;
import javax.xml.ws.WebServiceContext;
import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.soap.Addressing;
import org.jboss.logging.Logger;
-import org.jboss.ws.annotation.EndpointConfig;
/**
* WS-Addressing stateful service endpoint
@@ -46,7 +46,7 @@
* @since 24-Nov-2005
*/
@WebService(name = "WsaEndpoint", targetNamespace = "http://webservice.webservicewsa.quickstart.samples.esb.soa.jboss.org/", serviceName = "WsaService")
- at EndpointConfig(configName = "Standard WSAddressing Endpoint")
+ at Addressing(required=true, enabled=true)
@HandlerChain(file = "jaxws-handlers.xml")
@SOAPBinding(style = SOAPBinding.Style.RPC)
public class StatefulEndpointImpl implements StatefulEndpoint
@@ -64,7 +64,7 @@
private WebServiceContext context;
@Resource
- public void setContext(WebServiceContext context)
+ private void setContext(WebServiceContext context)
{
log.info("injecting: " + context);
this.context = context;
Deleted: labs/jbossesb/trunk/product/samples/quickstarts/webservice_wsaddressing/src_as5/org/jboss/soa/esb/samples/quickstart/webservicewsa/client/ClientHandler.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_wsaddressing/src_as5/org/jboss/soa/esb/samples/quickstart/webservicewsa/client/ClientHandler.java 2010-07-30 09:38:21 UTC (rev 34409)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_wsaddressing/src_as5/org/jboss/soa/esb/samples/quickstart/webservicewsa/client/ClientHandler.java 2010-07-30 09:45:21 UTC (rev 34410)
@@ -1,129 +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.soa.esb.samples.quickstart.webservicewsa.client;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import javax.xml.namespace.QName;
-import javax.xml.soap.SOAPHeaderElement;
-import javax.xml.ws.addressing.AddressingBuilder;
-import javax.xml.ws.addressing.AddressingConstants;
-import javax.xml.ws.addressing.AddressingProperties;
-import javax.xml.ws.addressing.EndpointReference;
-import javax.xml.ws.addressing.JAXWSAConstants;
-import javax.xml.ws.addressing.ReferenceParameters;
-import javax.xml.ws.handler.MessageContext;
-import javax.xml.ws.handler.MessageContext.Scope;
-
-import org.jboss.logging.Logger;
-import org.jboss.util.xml.DOMUtils;
-import org.jboss.wsf.common.handler.GenericSOAPHandler;
-import org.jboss.wsf.common.utils.UUIDGenerator;
-import org.jboss.soa.esb.samples.quickstart.webservicewsa.StatefulEndpointImpl;
-
-/**
- * A client side handler for the ws-addressing
- *
- * @author Thomas.Diesler at jboss.org
- * @since 24-Nov-2005
- */
-public class ClientHandler extends GenericSOAPHandler
-{
- // Provide logging
- private static Logger log = Logger.getLogger(ClientHandler.class);
-
- private static final QName IDQN = StatefulEndpointImpl.IDQN;
-
- private static int maxClientId;
- private String clientid;
-
- @Override
- public boolean handleOutbound(MessageContext msgContext)
- {
- try
- {
- AddressingBuilder builder = AddressingBuilder.getAddressingBuilder();
- AddressingConstants ADDR = builder.newAddressingConstants();
-
- AddressingProperties outProps = builder.newAddressingProperties();
- outProps.setTo(builder.newURI("uri:jaxrpc-samples-wsaddressing/TestService"));
- outProps.setAction(builder.newURI("http://org.jboss.ws/addressing/stateful/action"));
-
- EndpointReference replyTo = builder.newEndpointReference(new URI(ADDR.getAnonymousURI()));
- outProps.setReplyTo(replyTo);
- outProps.setMessageID(builder.newURI("urn:uuid:"+ UUIDGenerator.generateRandomUUIDString()));
-
- // Assign a new clientid
- if (clientid == null)
- {
- clientid = "clientid-" + (++maxClientId);
- log.info("New clientid: " + clientid);
- }
-
- ReferenceParameters refParams = replyTo.getReferenceParameters();
- refParams.addElement(getClientIdElement(clientid));
-
- msgContext.put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND, outProps);
- msgContext.setScope(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND, Scope.APPLICATION);
- }
- catch (URISyntaxException ex)
- {
- throw new IllegalStateException("Cannot handle request", ex);
- }
-
- return true;
- }
-
- @Override
- public boolean handleInbound(MessageContext msgContext)
- {
- AddressingProperties addrProps = (AddressingProperties)msgContext.get(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_INBOUND);
- if (addrProps == null)
- throw new IllegalStateException("Cannot obtain AddressingProperties");
-
- ReferenceParameters refParams = addrProps.getReferenceParameters();
- for (Object obj : refParams.getElements())
- {
- SOAPHeaderElement el = (SOAPHeaderElement)obj;
- QName qname = DOMUtils.getElementQName(el);
- if (qname.equals(IDQN))
- {
- clientid = DOMUtils.getTextContent(el);
- }
- }
-
- if (clientid == null)
- throw new IllegalStateException("Cannot obtain clientid");
-
- return true;
- }
-
- private String getClientIdElement(String clientid)
- {
- String qualname = IDQN.getPrefix() + ":" + IDQN.getLocalPart();
- StringBuffer buffer = new StringBuffer("<" + qualname);
- buffer.append(" xmlns:" + IDQN.getPrefix() + "='" + IDQN.getNamespaceURI() + "'");
- buffer.append(">" + clientid + "</" + qualname + ">");
- return buffer.toString();
- }
-}
Modified: labs/jbossesb/trunk/product/samples/quickstarts/webservice_wsaddressing/src_as5/org/jboss/soa/esb/samples/quickstart/webservicewsa/client/WSAClient.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_wsaddressing/src_as5/org/jboss/soa/esb/samples/quickstart/webservicewsa/client/WSAClient.java 2010-07-30 09:38:21 UTC (rev 34409)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_wsaddressing/src_as5/org/jboss/soa/esb/samples/quickstart/webservicewsa/client/WSAClient.java 2010-07-30 09:45:21 UTC (rev 34410)
@@ -19,13 +19,14 @@
*/
package org.jboss.soa.esb.samples.quickstart.webservicewsa.client;
+import org.jboss.soa.esb.samples.quickstart.webservicewsa.AddressingPort;
import org.jboss.soa.esb.samples.quickstart.webservicewsa.StatefulEndpoint;
-import org.jboss.ws.extensions.addressing.jaxws.WSAddressingClientHandler;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.handler.Handler;
+import javax.xml.ws.soap.AddressingFeature;
import javax.xml.ws.soap.SOAPBinding;
import java.net.MalformedURLException;
import java.net.URL;
@@ -38,6 +39,7 @@
* The basis of this code was lifted from JBossWS test code. Thanks guys :-)
*
* @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ * @author <a href="mailto:mageshbk at jboss.com">mageshbk at jboss.com</a>
*/
public class WSAClient {
@@ -73,16 +75,7 @@
URL wsdlURL = new URL("http://localhost:8080/contract/contract.jsp?serviceCat=MyServiceCategory&serviceName=MyWsaService&protocol=http");
Service service = Service.create(wsdlURL, serviceName);
- endpoint = service.getPort(StatefulEndpoint.class);
-
- SOAPBinding binding = (SOAPBinding)((BindingProvider)endpoint).getBinding();
- List<Handler> handlerChain = new ArrayList<Handler>();
-
- handlerChain.addAll(binding.getHandlerChain());
- handlerChain.add(new ClientHandler());
- handlerChain.add(new WSAddressingClientHandler());
- binding.setHandlerChain(handlerChain);
-
+ endpoint = new AddressingPort(service.getPort(StatefulEndpoint.class, new AddressingFeature(true, true)));
return endpoint;
}
}
Added: labs/jbossesb/trunk/product/samples/quickstarts/webservice_wsaddressing/war/resources/WEB-INF/jbossws-cxf.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_wsaddressing/war/resources/WEB-INF/jbossws-cxf.xml (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_wsaddressing/war/resources/WEB-INF/jbossws-cxf.xml 2010-07-30 09:45:21 UTC (rev 34410)
@@ -0,0 +1,23 @@
+<beans
+ xmlns='http://www.springframework.org/schema/beans'
+ xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
+ xmlns:beans='http://www.springframework.org/schema/beans'
+ xmlns:jaxws='http://cxf.apache.org/jaxws'
+ xsi:schemaLocation='http://cxf.apache.org/core
+ http://cxf.apache.org/schemas/core.xsd
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://cxf.apache.org/jaxws
+ http://cxf.apache.org/schemas/jaxws.xsd'>
+
+ <jaxws:endpoint
+ id='StatefulEndpoint'
+ address='http://localhost:8080/Quickstart_webservice_wsaddressing'
+ implementor='org.jboss.soa.esb.samples.quickstart.webservicewsa.StatefulEndpointImpl'>
+ <jaxws:invoker>
+ <bean class='org.jboss.wsf.stack.cxf.InvokerJSE'/>
+ </jaxws:invoker>
+ </jaxws:endpoint>
+
+
+</beans>
Modified: labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/build.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/build.xml 2010-07-30 09:38:21 UTC (rev 34409)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/build.xml 2010-07-30 09:45:21 UTC (rev 34410)
@@ -8,8 +8,26 @@
<!-- Import the base Ant build script... -->
<import file="../conf/base-build.xml"/>
- <target name="quickstart-specific-checks" depends="assert-ws-available,assert-jbossremoting-version"/>
+ <target name="quickstart-specific-checks" depends="assert-ws-available,assert-jbossremoting-version, check-src-dir, check-rsrc-dir"/>
+ <target name="check-src-dir">
+ <condition property="quickstart.src.dir" value="src_cxf" else="src">
+ <and>
+ <available classname="org.apache.cxf.endpoint.Endpoint" classpathref="compile-classpath"/>
+ </and>
+ </condition>
+ <echo message="Set src dir to : ${quickstart.src.dir}"/>
+ </target>
+
+ <target name="check-rsrc-dir">
+ <condition property="wss.rsrc.dir" value="${basedir}/war/resources_cxf" else="${basedir}/war/resources">
+ <and>
+ <available classname="org.apache.cxf.endpoint.Endpoint" classpathref="compile-classpath"/>
+ </and>
+ </condition>
+ <echo message="Set resource dir to : ${wss.rsrc.dir}"/>
+ </target>
+
<target name="quickstart-specific-dependencies">
<path id="quickstart-dependencies-classpath">
<fileset dir="${org.jboss.esb.server.home}/client" includes="jbossws-client.jar,jboss-remoting.jar"/>
@@ -22,15 +40,12 @@
<!-- Build the webservice... -->
<war warfile="build/${ant.project.name}.war"
- webxml="${basedir}/war/resources/WEB-INF/web.xml">
- <webinf dir="${basedir}/war/resources/WEB-INF">
- <include name="jboss-web.xml"/>
- </webinf>
+ webxml="${wss.rsrc.dir}/WEB-INF/web.xml">
<fileset dir="${basedir}/war/view">
<include name="**/*"/>
</fileset>
- <fileset dir="${basedir}/war/resources/">
- <include name="WEB-INF/**/*"/>
+ <fileset dir="${wss.rsrc.dir}">
+ <include name="**/*"/>
</fileset>
</war>
</target>
Added: labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src_cxf/META-INF/alice.jks
===================================================================
(Binary files differ)
Property changes on: labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src_cxf/META-INF/alice.jks
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src_cxf/META-INF/alice.properties
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src_cxf/META-INF/alice.properties (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src_cxf/META-INF/alice.properties 2010-07-30 09:45:21 UTC (rev 34410)
@@ -0,0 +1,5 @@
+org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin
+org.apache.ws.security.crypto.merlin.keystore.type=jks
+org.apache.ws.security.crypto.merlin.keystore.password=password
+org.apache.ws.security.crypto.merlin.keystore.alias=alice
+org.apache.ws.security.crypto.merlin.file=src_cxf/META-INF/alice.jks
\ No newline at end of file
Added: labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src_cxf/org/jboss/test/ws/jaxws/samples/wssecurity/Hello.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src_cxf/org/jboss/test/ws/jaxws/samples/wssecurity/Hello.java (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src_cxf/org/jboss/test/ws/jaxws/samples/wssecurity/Hello.java 2010-07-30 09:45:21 UTC (rev 34410)
@@ -0,0 +1,36 @@
+
+package org.jboss.test.ws.jaxws.samples.wssecurity;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+
+/**
+ * This class was generated by the JAX-WS RI.
+ * JAX-WS RI 2.1.1-b03-
+ * Generated source version: 2.0
+ *
+ */
+ at WebService(name = "Hello", targetNamespace = "http://org.jboss.ws/samples/wssecurity")
+ at SOAPBinding(style = SOAPBinding.Style.RPC)
+public interface Hello {
+
+ public static final String SERVICE_NAME = "HelloService";
+ public static final String SERVICE_NAMESPACE = "http://org.jboss.ws/samples/wssecurity";
+
+ /**
+ *
+ * @param user
+ * @return
+ * returns org.jboss.test.ws.jaxws.samples.wssecurity.UserType
+ */
+ @WebMethod
+ @WebResult(partName = "return")
+ public UserType echoUserType(
+ @WebParam(name = "user", partName = "user")
+ UserType user);
+
+}
Added: labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src_cxf/org/jboss/test/ws/jaxws/samples/wssecurity/HelloJavaBean.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src_cxf/org/jboss/test/ws/jaxws/samples/wssecurity/HelloJavaBean.java (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src_cxf/org/jboss/test/ws/jaxws/samples/wssecurity/HelloJavaBean.java 2010-07-30 09:45:21 UTC (rev 34410)
@@ -0,0 +1,43 @@
+/*
+ * 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.test.ws.jaxws.samples.wssecurity;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+import org.jboss.logging.Logger;
+
+ at WebService(name = "Hello", serviceName = "HelloService", targetNamespace = "http://org.jboss.ws/samples/wssecurity")
+ at SOAPBinding(style = SOAPBinding.Style.RPC)
+public class HelloJavaBean
+{
+ private Logger log = Logger.getLogger(HelloJavaBean.class);
+
+ @WebMethod
+ public UserType echoUserType(@WebParam(name = "user") UserType in0)
+ {
+ log.info(in0);
+ return in0;
+ }
+}
Added: labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src_cxf/org/jboss/test/ws/jaxws/samples/wssecurity/KeystorePasswordCallback.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src_cxf/org/jboss/test/ws/jaxws/samples/wssecurity/KeystorePasswordCallback.java (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src_cxf/org/jboss/test/ws/jaxws/samples/wssecurity/KeystorePasswordCallback.java 2010-07-30 09:45:21 UTC (rev 34410)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.
+ *
+ * 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.test.ws.jaxws.samples.wssecurity;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import org.apache.ws.security.WSPasswordCallback;
+
+public class KeystorePasswordCallback implements CallbackHandler
+{
+
+ private Map<String, String> passwords = new HashMap<String, String>();
+
+ public KeystorePasswordCallback()
+ {
+ passwords.put("alice", "password");
+ passwords.put("bob", "password");
+ }
+
+ /**
+ * It attempts to get the password from the private
+ * alias/passwords map.
+ */
+ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
+ {
+ for (int i = 0; i < callbacks.length; i++)
+ {
+ WSPasswordCallback pc = (WSPasswordCallback)callbacks[i];
+
+ String pass = passwords.get(pc.getIdentifer());
+ if (pass != null)
+ {
+ pc.setPassword(pass);
+ return;
+ }
+ }
+ }
+
+ /**
+ * Add an alias/password pair to the callback mechanism.
+ */
+ public void setAliasPassword(String alias, String password)
+ {
+ passwords.put(alias, password);
+ }
+}
Added: labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src_cxf/org/jboss/test/ws/jaxws/samples/wssecurity/UserType.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src_cxf/org/jboss/test/ws/jaxws/samples/wssecurity/UserType.java (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src_cxf/org/jboss/test/ws/jaxws/samples/wssecurity/UserType.java 2010-07-30 09:45:21 UTC (rev 34410)
@@ -0,0 +1,60 @@
+
+package org.jboss.test.ws.jaxws.samples.wssecurity;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for UserType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="UserType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="msg" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+ at XmlAccessorType(XmlAccessType.FIELD)
+ at XmlType(name = "UserType", propOrder = {
+ "msg"
+})
+public class UserType {
+
+ protected String msg;
+
+ /**
+ * Gets the value of the msg property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getMsg() {
+ return msg;
+ }
+
+ /**
+ * Sets the value of the msg property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setMsg(String value) {
+ this.msg = value;
+ }
+
+}
Added: labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src_cxf/org/jboss/test/ws/jaxws/samples/wssecurity/client/WSSClient.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src_cxf/org/jboss/test/ws/jaxws/samples/wssecurity/client/WSSClient.java (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src_cxf/org/jboss/test/ws/jaxws/samples/wssecurity/client/WSSClient.java 2010-07-30 09:45:21 UTC (rev 34410)
@@ -0,0 +1,103 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.test.ws.jaxws.samples.wssecurity.client;
+
+import org.jboss.test.ws.jaxws.samples.wssecurity.Hello;
+import org.jboss.test.ws.jaxws.samples.wssecurity.UserType;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Service;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.rmi.RemoteException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.cxf.binding.soap.saaj.SAAJInInterceptor;
+import org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.frontend.ClientProxy;
+import org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor;
+import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor;
+
+/**
+ * CXF WSA Client.
+ *
+ * @author <a href="mailto:mageshbk at jboss.com">mageshbk at jboss.com</a>
+ */
+public class WSSClient {
+
+ public static void main(String[] args) throws MalformedURLException, RemoteException {
+ Hello hello = getEndpointPort();
+
+ UserType userType = new UserType();
+ userType.setMsg("Hello ESB");
+ UserType retObj = hello.echoUserType(userType);
+ System.out.println("Echo received '" + retObj.getMsg() + "'.");
+ }
+
+ private static Hello getEndpointPort() throws MalformedURLException {
+ QName serviceName = new QName(Hello.SERVICE_NAMESPACE, Hello.SERVICE_NAME);
+ URL wsdlURL = new URL("http://localhost:8080/contract/contract.jsp?serviceCat=MyServiceCategory&serviceName=MyWssService&protocol=http");
+
+ Service service = Service.create(wsdlURL, serviceName);
+ Hello endpoint = service.getPort(Hello.class);
+ setupWsse(endpoint);
+
+ Map<String, Object> reqContext = ((BindingProvider) endpoint).getRequestContext();
+ reqContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:9876/");
+
+ return endpoint;
+ }
+
+ private static void setupWsse(Hello proxy)
+ {
+ Client client = ClientProxy.getClient(proxy);
+ Endpoint cxfEndpoint = client.getEndpoint();
+
+ Map<String, Object> outProps = new HashMap<String, Object>();
+ outProps.put("action", "Timestamp Signature Encrypt");
+ outProps.put("user", "alice");
+ outProps.put("signaturePropFile", "src_cxf/META-INF/alice.properties");
+ outProps.put("signatureKeyIdentifier", "DirectReference");
+ outProps.put("passwordCallbackClass", "org.jboss.test.ws.jaxws.samples.wssecurity.KeystorePasswordCallback");
+ outProps.put("signatureParts", "{Element}{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd}Timestamp;{Element}{http://schemas.xmlsoap.org/soap/envelope/}Body");
+ outProps.put("encryptionPropFile", "src_cxf/META-INF/alice.properties");
+ outProps.put("encryptionUser", "Bob");
+ outProps.put("encryptionParts", "{Element}{http://www.w3.org/2000/09/xmldsig#}Signature;{Content}{http://schemas.xmlsoap.org/soap/envelope/}Body");
+ outProps.put("encryptionSymAlgorithm", "http://www.w3.org/2001/04/xmlenc#tripledes-cbc");
+ outProps.put("encryptionKeyTransportAlgorithm", "http://www.w3.org/2001/04/xmlenc#rsa-1_5");
+ WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps); //request
+ cxfEndpoint.getOutInterceptors().add(wssOut);
+ cxfEndpoint.getOutInterceptors().add(new SAAJOutInterceptor());
+
+ Map<String,Object> inProps= new HashMap<String,Object>();
+ inProps.put("action", "Timestamp Signature Encrypt");
+ inProps.put("signaturePropFile", "src_cxf/META-INF/alice.properties");
+ inProps.put("passwordCallbackClass", "org.jboss.test.ws.jaxws.samples.wssecurity.KeystorePasswordCallback");
+ inProps.put("decryptionPropFile", "src_cxf/META-INF/alice.properties");
+ WSS4JInInterceptor wssIn = new WSS4JInInterceptor(inProps); //response
+ cxfEndpoint.getInInterceptors().add(wssIn);
+ cxfEndpoint.getInInterceptors().add(new SAAJInInterceptor());
+ }
+
+}
Added: labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/war/resources_cxf/WEB-INF/classes/bob.jks
===================================================================
(Binary files differ)
Property changes on: labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/war/resources_cxf/WEB-INF/classes/bob.jks
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/war/resources_cxf/WEB-INF/classes/bob.properties
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/war/resources_cxf/WEB-INF/classes/bob.properties (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/war/resources_cxf/WEB-INF/classes/bob.properties 2010-07-30 09:45:21 UTC (rev 34410)
@@ -0,0 +1,5 @@
+org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin
+org.apache.ws.security.crypto.merlin.keystore.type=jks
+org.apache.ws.security.crypto.merlin.keystore.password=password
+org.apache.ws.security.crypto.merlin.keystore.alias=bob
+org.apache.ws.security.crypto.merlin.file=bob.jks
\ No newline at end of file
Added: labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/war/resources_cxf/WEB-INF/jboss-web.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/war/resources_cxf/WEB-INF/jboss-web.xml (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/war/resources_cxf/WEB-INF/jboss-web.xml 2010-07-30 09:45:21 UTC (rev 34410)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jboss-web>
+ <context-root>/Quickstart_webservice_wssecurity</context-root>
+</jboss-web>
+
Added: labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/war/resources_cxf/WEB-INF/jbossws-cxf.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/war/resources_cxf/WEB-INF/jbossws-cxf.xml (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/war/resources_cxf/WEB-INF/jbossws-cxf.xml 2010-07-30 09:45:21 UTC (rev 34410)
@@ -0,0 +1,60 @@
+<beans
+ xmlns='http://www.springframework.org/schema/beans'
+ xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
+ xmlns:beans='http://www.springframework.org/schema/beans'
+ xmlns:jaxws='http://cxf.apache.org/jaxws'
+ xsi:schemaLocation='http://cxf.apache.org/core
+ http://cxf.apache.org/schemas/core.xsd
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://cxf.apache.org/jaxws
+ http://cxf.apache.org/schemas/jaxws.xsd'>
+
+ <bean id="Sign_Request" class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
+ <constructor-arg>
+ <map>
+ <entry key="action" value="Timestamp Signature Encrypt"/>
+ <entry key="signaturePropFile" value="bob.properties"/>
+ <entry key="decryptionPropFile" value="bob.properties"/>
+ <entry key="passwordCallbackClass" value="org.jboss.test.ws.jaxws.samples.wssecurity.KeystorePasswordCallback"/>
+ </map>
+ </constructor-arg>
+ </bean>
+
+ <bean id="Sign_Response" class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor">
+ <constructor-arg>
+ <map>
+ <entry key="action" value="Timestamp Signature Encrypt"/>
+ <entry key="user" value="bob"/>
+ <entry key="signaturePropFile" value="bob.properties"/>
+ <entry key="encryptionPropFile" value="bob.properties"/>
+ <entry key="encryptionUser" value="Alice"/>
+ <entry key="signatureKeyIdentifier" value="DirectReference"/>
+ <entry key="passwordCallbackClass" value="org.jboss.test.ws.jaxws.samples.wssecurity.KeystorePasswordCallback"/>
+ <entry key="signatureParts" value="{Element}{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd}Timestamp;{Element}{http://schemas.xmlsoap.org/soap/envelope/}Body"/>
+ <entry key="encryptionParts" value="{Element}{http://www.w3.org/2000/09/xmldsig#}Signature;{Content}{http://schemas.xmlsoap.org/soap/envelope/}Body"/>
+ <entry key="encryptionKeyTransportAlgorithm" value="http://www.w3.org/2001/04/xmlenc#rsa-1_5"/>
+ <entry key="encryptionSymAlgorithm" value="http://www.w3.org/2001/04/xmlenc#tripledes-cbc"/>
+ </map>
+ </constructor-arg>
+ </bean>
+
+ <jaxws:endpoint
+ id='HelloJavaBean'
+ address='http://localhost:8080/Quickstart_webservice_wssecurity'
+ implementor='org.jboss.test.ws.jaxws.samples.wssecurity.HelloJavaBean'>
+ <jaxws:invoker>
+ <bean class='org.jboss.wsf.stack.cxf.InvokerJSE'/>
+ </jaxws:invoker>
+ <jaxws:outInterceptors>
+ <bean class="org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor"/>
+ <ref bean="Sign_Response"/>
+ </jaxws:outInterceptors>
+ <jaxws:inInterceptors>
+ <ref bean="Sign_Request"/>
+ <bean class="org.apache.cxf.binding.soap.saaj.SAAJInInterceptor"/>
+ </jaxws:inInterceptors>
+ </jaxws:endpoint>
+
+
+</beans>
Added: labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/war/resources_cxf/WEB-INF/web.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/war/resources_cxf/WEB-INF/web.xml (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/war/resources_cxf/WEB-INF/web.xml 2010-07-30 09:45:21 UTC (rev 34410)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+ version="2.4">
+
+ <servlet>
+ <servlet-name>HelloService</servlet-name>
+ <servlet-class>org.jboss.test.ws.jaxws.samples.wssecurity.HelloJavaBean</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>HelloService</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+</web-app>
+
More information about the jboss-svn-commits
mailing list