Author: alessio.soldano(a)jboss.com
Date: 2012-11-14 05:20:57 -0500 (Wed, 14 Nov 2012)
New Revision: 16981
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/EJBServiceImpl.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/sign/META-INF-server/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/sign/META-INF-server/bob.jks
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/sign/META-INF-server/bob.properties
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/sign/META-INF-server/jaxws-endpoint-config.xml
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/sign/META-INF-server/wsdl/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/sign/META-INF-server/wsdl/SecurityService.wsdl
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/sign/META-INF-server/wsdl/SecurityService_schema1.xsd
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-samples-jars-jaxws.xml
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/SignEncryptHelper.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/SignTestCase.java
Log:
Adding sample with ejb3 endpoint using @EndpointConfig and referencing wss4j props file to
show how to package prop files
Modified: stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-samples-jars-jaxws.xml
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-samples-jars-jaxws.xml 2012-11-14
09:44:40 UTC (rev 16980)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-samples-jars-jaxws.xml 2012-11-14
10:20:57 UTC (rev 16981)
@@ -255,6 +255,25 @@
</metainf>
</jar>
+ <!-- jaxws-samples-wsse-policy-sign-ejb -->
+ <jar
destfile="${tests.output.dir}/test-libs/jaxws-samples-wsse-policy-sign-ejb.jar">
+ <fileset dir="${tests.output.dir}/test-classes">
+ <include
name="org/jboss/test/ws/jaxws/samples/wsse/policy/basic/EJB*.class"/>
+ <include
name="org/jboss/test/ws/jaxws/samples/wsse/policy/basic/ServiceIface.class"/>
+ <include
name="org/jboss/test/ws/jaxws/samples/wsse/policy/jaxws/Say*.class"/>
+ <include
name="org/jboss/test/ws/jaxws/samples/wsse/policy/basic/KeystorePasswordCallback.class"/>
+ </fileset>
+ <metainf
dir="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/basic/sign/META-INF-server">
+ <include name="jaxws-endpoint-config.xml"/>
+ <include name="wsdl/*"/>
+ <include name="bob.properties" />
+ <include name="bob.jks" />
+ </metainf>
+ <manifest>
+ <attribute name="Dependencies"
value="org.apache.ws.security"/>
+ </manifest>
+ </jar>
+
<!-- jaxws-samples-wsse-policy-sign-encrypt -->
<war
warfile="${tests.output.dir}/test-libs/jaxws-samples-wsse-policy-sign-encrypt.war"
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/EJBServiceImpl.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/EJBServiceImpl.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/EJBServiceImpl.java 2012-11-14
10:20:57 UTC (rev 16981)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.wsse.policy.basic;
+
+import javax.ejb.Stateless;
+import javax.jws.WebService;
+
+import org.jboss.ws.api.annotation.EndpointConfig;
+
+@Stateless
+@WebService
+(
+ portName = "SecurityServicePort",
+ serviceName = "SecurityService",
+ wsdlLocation = "META-INF/wsdl/SecurityService.wsdl",
+ targetNamespace =
"http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy",
+ endpointInterface =
"org.jboss.test.ws.jaxws.samples.wsse.policy.basic.ServiceIface"
+)
+@EndpointConfig(configFile = "META-INF/jaxws-endpoint-config.xml", configName =
"Custom WS-Security Endpoint")
+public class EJBServiceImpl implements ServiceIface
+{
+ public String sayHello()
+ {
+ return "EJB Secure Hello World!";
+ }
+}
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/SignEncryptHelper.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/SignEncryptHelper.java 2012-11-14
09:44:40 UTC (rev 16980)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/SignEncryptHelper.java 2012-11-14
10:20:57 UTC (rev 16981)
@@ -33,7 +33,6 @@
import org.apache.cxf.BusFactory;
import org.apache.cxf.ws.security.SecurityConstants;
import org.jboss.ws.api.configuration.ClientConfigUtil;
-import org.jboss.ws.api.configuration.ClientConfigurer;
import org.jboss.wsf.test.ClientHelper;
public class SignEncryptHelper implements ClientHelper
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/SignTestCase.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/SignTestCase.java 2012-11-14
09:44:40 UTC (rev 16980)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/SignTestCase.java 2012-11-14
10:20:57 UTC (rev 16981)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2012, 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.
*
@@ -42,10 +42,11 @@
public final class SignTestCase extends JBossWSTest
{
private final String serviceURL = "http://" + getServerHost() +
":8080/jaxws-samples-wsse-policy-sign";
+ private final String serviceURLEJB = "http://" + getServerHost() +
":8080/jaxws-samples-wsse-policy-sign-ejb/SecurityService/EJBServiceImpl";
public static Test suite()
{
- return new JBossWSCXFTestSetup(SignTestCase.class,
"jaxws-samples-wsse-policy-sign-client.jar
jaxws-samples-wsse-policy-sign.war");
+ return new JBossWSCXFTestSetup(SignTestCase.class,
"jaxws-samples-wsse-policy-sign-client.jar jaxws-samples-wsse-policy-sign.war
jaxws-samples-wsse-policy-sign-ejb.jar");
}
public void test() throws Exception
@@ -58,6 +59,16 @@
assertEquals("Secure Hello World!", proxy.sayHello());
}
+ public void testEJB() throws Exception
+ {
+ QName serviceName = new
QName("http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy",
"SecurityService");
+ URL wsdlURL = new URL(serviceURLEJB + "?wsdl");
+ Service service = Service.create(wsdlURL, serviceName);
+ ServiceIface proxy = (ServiceIface)service.getPort(ServiceIface.class);
+ setupWsse(proxy);
+ assertEquals("EJB Secure Hello World!", proxy.sayHello());
+ }
+
private void setupWsse(ServiceIface proxy)
{
((BindingProvider)proxy).getRequestContext().put(SecurityConstants.CALLBACK_HANDLER, new
KeystorePasswordCallback());
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/sign/META-INF-server/bob.jks
===================================================================
(Binary files differ)
Property changes on:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/sign/META-INF-server/bob.jks
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/sign/META-INF-server/bob.properties
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/sign/META-INF-server/bob.properties
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/sign/META-INF-server/bob.properties 2012-11-14
10:20:57 UTC (rev 16981)
@@ -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=META-INF/bob.jks
\ No newline at end of file
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/sign/META-INF-server/jaxws-endpoint-config.xml
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/sign/META-INF-server/jaxws-endpoint-config.xml
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/sign/META-INF-server/jaxws-endpoint-config.xml 2012-11-14
10:20:57 UTC (rev 16981)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jaxws-config xmlns="urn:jboss:jbossws-jaxws-config:4.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:javaee="http://java.sun.com/xml/ns/javaee"
+ xsi:schemaLocation="urn:jboss:jbossws-jaxws-config:4.0
schema/jbossws-jaxws-config_4_0.xsd">
+
+ <endpoint-config>
+ <config-name>Custom WS-Security Endpoint</config-name>
+ <property>
+ <property-name>ws-security.signature.properties</property-name>
+ <property-value>META-INF/bob.properties</property-value>
+ </property>
+ <property> <!-- workaround CXF requiring this even if no encryption is
configured -->
+ <property-name>ws-security.encryption.properties</property-name>
+ <property-value>META-INF/bob.properties</property-value>
+ </property>
+ <property>
+ <property-name>ws-security.callback-handler</property-name>
+
<property-value>org.jboss.test.ws.jaxws.samples.wsse.policy.basic.KeystorePasswordCallback</property-value>
+ </property>
+ </endpoint-config>
+
+</jaxws-config>
\ No newline at end of file
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/sign/META-INF-server/wsdl/SecurityService.wsdl
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/sign/META-INF-server/wsdl/SecurityService.wsdl
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/sign/META-INF-server/wsdl/SecurityService.wsdl 2012-11-14
10:20:57 UTC (rev 16981)
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
+<definitions
targetNamespace="http://www.jboss.org/jbossws/ws-extensions/wssecuri...
name="SecurityService"
+
xmlns:tns="http://www.jboss.org/jbossws/ws-extensions/wssecuritypoli...
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+
xmlns="http://schemas.xmlsoap.org/wsdl/"
+
xmlns:wsp="http://www.w3.org/ns/ws-policy"
+
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-w...
+
xmlns:wsaws="http://www.w3.org/2005/08/addressing"
+
xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"...
+ <types>
+ <xsd:schema>
+ <xsd:import
namespace="http://www.jboss.org/jbossws/ws-extensions/wssecuritypoli...
schemaLocation="SecurityService_schema1.xsd"/>
+ </xsd:schema>
+ </types>
+ <message name="sayHello">
+ <part name="parameters" element="tns:sayHello"/>
+ </message>
+ <message name="sayHelloResponse">
+ <part name="parameters" element="tns:sayHelloResponse"/>
+ </message>
+ <portType name="ServiceIface">
+ <operation name="sayHello">
+ <input message="tns:sayHello"/>
+ <output message="tns:sayHelloResponse"/>
+ </operation>
+ </portType>
+ <binding name="SecurityServicePortBinding"
type="tns:ServiceIface">
+ <wsp:PolicyReference URI="#SecurityServiceSignPolicy"/>
+ <soap:binding
transport="http://schemas.xmlsoap.org/soap/http"
style="document"/>
+ <operation name="sayHello">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ </binding>
+ <service name="SecurityService">
+ <port name="SecurityServicePort"
binding="tns:SecurityServicePortBinding">
+ <soap:address
location="http://@jboss.bind.address@:8080/jaxws-samples-wsse-sign"/>
+ </port>
+ </service>
+
+ <wsp:Policy wsu:Id="SecurityServiceSignPolicy"
+
xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"...
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <sp:AsymmetricBinding
xmlns:sp='http://schemas.xmlsoap.org/ws/2005/07/securitypolicy'>
+ <wsp:Policy>
+ <sp:InitiatorToken>
+ <wsp:Policy>
+ <sp:X509Token
sp:IncludeToken='http://schemas.xmlsoap.org/ws/2005/07/securitypolicy...
+ <wsp:Policy>
+ <sp:WssX509V3Token10 />
+ </wsp:Policy>
+ </sp:X509Token>
+ </wsp:Policy>
+ </sp:InitiatorToken>
+ <sp:RecipientToken>
+ <wsp:Policy>
+ <sp:X509Token
sp:IncludeToken='http://schemas.xmlsoap.org/ws/2005/07/securitypolicy...
+ <wsp:Policy>
+ <sp:WssX509V3Token10 />
+ </wsp:Policy>
+ </sp:X509Token>
+ </wsp:Policy>
+ </sp:RecipientToken>
+ <sp:AlgorithmSuite>
+ <wsp:Policy>
+ <sp:Basic256 />
+ </wsp:Policy>
+ </sp:AlgorithmSuite>
+ <sp:Layout>
+ <wsp:Policy>
+ <sp:Strict />
+ </wsp:Policy>
+ </sp:Layout>
+ <sp:OnlySignEntireHeadersAndBody />
+ </wsp:Policy>
+ </sp:AsymmetricBinding>
+ <sp:Wss10
xmlns:sp='http://schemas.xmlsoap.org/ws/2005/07/securitypolicy'>
+ <wsp:Policy>
+ <sp:MustSupportRefEmbeddedToken />
+ </wsp:Policy>
+ </sp:Wss10>
+ <sp:SignedParts
xmlns:sp='http://schemas.xmlsoap.org/ws/2005/07/securitypolicy'>
+ <sp:Body />
+ </sp:SignedParts>
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+</definitions>
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/sign/META-INF-server/wsdl/SecurityService_schema1.xsd
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/sign/META-INF-server/wsdl/SecurityService_schema1.xsd
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/sign/META-INF-server/wsdl/SecurityService_schema1.xsd 2012-11-14
10:20:57 UTC (rev 16981)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
+<xs:schema version="1.0"
targetNamespace="http://www.jboss.org/jbossws/ws-extensions/wssecuri...
xmlns:tns="http://www.jboss.org/jbossws/ws-extensions/wssecuritypoli...
xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <xs:element name="sayHello" type="tns:sayHello"/>
+
+ <xs:element name="sayHelloResponse"
type="tns:sayHelloResponse"/>
+
+ <xs:complexType name="sayHello">
+ <xs:sequence/>
+ </xs:complexType>
+
+ <xs:complexType name="sayHelloResponse">
+ <xs:sequence>
+ <xs:element name="return" type="xs:string"
minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:schema>
+