Author: darran.lofthouse(a)jboss.com
Date: 2008-04-14 08:58:16 -0400 (Mon, 14 Apr 2008)
New Revision: 6416
Added:
stack/native/branches/dlofthouse/JBWS-1316/src/test/java/org/jboss/test/ws/jaxrpc/jbws1316/JBWS1316CallTestCase.java
stack/native/branches/dlofthouse/JBWS-1316/src/test/java/org/jboss/test/ws/jaxrpc/jbws1316/TestEndpoint.java
stack/native/branches/dlofthouse/JBWS-1316/src/test/java/org/jboss/test/ws/jaxrpc/jbws1316/TestEndpointImpl.java
stack/native/branches/dlofthouse/JBWS-1316/src/test/java/org/jboss/test/ws/jaxrpc/jbws1316/TestSecurityHandler.java
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/META-INF/
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/META-INF/application-client.xml
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/META-INF/jboss-client.xml
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/WEB-INF/
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/WEB-INF/jaxrpc-mapping.xml
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/WEB-INF/jboss-wsse-server.xml
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/WEB-INF/web.xml
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/WEB-INF/webservices.xml
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/WEB-INF/wsdl/
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/WEB-INF/wsdl/TestService.wsdl
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/wstools-config.xml
Modified:
stack/native/branches/dlofthouse/JBWS-1316/ant-import-tests/build-jars-jaxrpc.xml
stack/native/branches/dlofthouse/JBWS-1316/src/main/java/org/jboss/ws/extensions/security/SecurityDecoder.java
stack/native/branches/dlofthouse/JBWS-1316/src/main/java/org/jboss/ws/extensions/security/WSSecurityDispatcher.java
stack/native/branches/dlofthouse/JBWS-1316/src/main/java/org/jboss/ws/extensions/security/operation/TimestampVerificationOperation.java
stack/native/branches/dlofthouse/JBWS-1316/src/main/java/org/jboss/ws/metadata/wsse/TimestampVerification.java
stack/native/branches/dlofthouse/JBWS-1316/src/test/java/org/jboss/test/ws/jaxrpc/jbws1316/JBWS1316ConfigurationTestCase.java
Log:
Added full message test case and completed implementation to make use of configuration.
Modified:
stack/native/branches/dlofthouse/JBWS-1316/ant-import-tests/build-jars-jaxrpc.xml
===================================================================
---
stack/native/branches/dlofthouse/JBWS-1316/ant-import-tests/build-jars-jaxrpc.xml 2008-04-14
12:13:40 UTC (rev 6415)
+++
stack/native/branches/dlofthouse/JBWS-1316/ant-import-tests/build-jars-jaxrpc.xml 2008-04-14
12:58:16 UTC (rev 6416)
@@ -2416,7 +2416,35 @@
<include name="jaxrpc-mapping.xml"/>
</metainf>
</jar>
-
+
+ <!-- jaxrpc-jbws1316 -->
+ <war warfile="${tests.output.dir}/libs/jaxrpc-jbws1316.war"
webxml="${tests.output.dir}/resources/jaxrpc/jbws1316/WEB-INF/web.xml">
+ <classes dir="${tests.output.dir}/classes">
+ <include name="org/jboss/test/ws/jaxrpc/jbws1316/*.class"/>
+ <exclude
name="org/jboss/test/ws/jaxrpc/jbws1316/*TestCase.class"/>
+ </classes>
+ <webinf
dir="${tests.output.dir}/resources/jaxrpc/jbws1316/WEB-INF">
+ <include name="webservices.xml"/>
+ <include name="jaxrpc-mapping.xml"/>
+ <include name="jboss-wsse-server.xml"/>
+ <include name="wsdl/**"/>
+ </webinf>
+ </war>
+ <jar destfile="${tests.output.dir}/libs/jaxrpc-jbws1316-client.jar">
+ <fileset dir="${tests.output.dir}/classes">
+ <include name="org/jboss/test/ws/jaxrpc/jbws1316/*.class"/>
+ <exclude
name="org/jboss/test/ws/jaxrpc/jbws1316/*TestCase.class"/>
+ </fileset>
+ <metainf
dir="${tests.output.dir}/resources/jaxrpc/jbws1316/META-INF">
+ <include name="application-client.xml"/>
+ <include name="jboss-client.xml"/>
+ </metainf>
+ <metainf
dir="${tests.output.dir}/resources/jaxrpc/jbws1316/WEB-INF">
+ <include name="wsdl/**"/>
+ <include name="jaxrpc-mapping.xml"/>
+ </metainf>
+ </jar>
+
<!-- jaxrpc-jbws1378 -->
<war warfile="${tests.output.dir}/libs/jaxrpc-jbws1378.war"
webxml="${tests.output.dir}/resources/jaxrpc/jbws1378/WEB-INF/web.xml">
<classes dir="${tests.output.dir}/classes">
Modified:
stack/native/branches/dlofthouse/JBWS-1316/src/main/java/org/jboss/ws/extensions/security/SecurityDecoder.java
===================================================================
---
stack/native/branches/dlofthouse/JBWS-1316/src/main/java/org/jboss/ws/extensions/security/SecurityDecoder.java 2008-04-14
12:13:40 UTC (rev 6415)
+++
stack/native/branches/dlofthouse/JBWS-1316/src/main/java/org/jboss/ws/extensions/security/SecurityDecoder.java 2008-04-14
12:58:16 UTC (rev 6416)
@@ -42,6 +42,7 @@
import org.jboss.ws.extensions.security.operation.RequireSignatureOperation;
import org.jboss.ws.extensions.security.operation.SignatureVerificationOperation;
import org.jboss.ws.extensions.security.operation.TimestampVerificationOperation;
+import org.jboss.ws.metadata.wsse.TimestampVerification;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -62,16 +63,19 @@
private NonceFactory nonceFactory;
private SecurityStore store;
+
+ private TimestampVerification timestampVerification;
private HashSet<String> signedIds = new HashSet<String>();
private HashSet<String> encryptedIds = new HashSet<String>();
- public SecurityDecoder(SecurityStore store, NonceFactory nonceFactory)
+ public SecurityDecoder(SecurityStore store, NonceFactory nonceFactory,
TimestampVerification timestampVerification)
{
org.apache.xml.security.Init.init();
this.store = store;
this.nonceFactory = nonceFactory;
+ this.timestampVerification = timestampVerification;
}
/**
@@ -81,9 +85,9 @@
* @param SecurityStore the security store that contains key and trust information
* @param now The timestamp to use as the current time when validating a message
expiration
*/
- public SecurityDecoder(SecurityStore store, Calendar now, NonceFactory nonceFactory)
+ public SecurityDecoder(SecurityStore store, Calendar now, NonceFactory nonceFactory,
TimestampVerification timestampVerification)
{
- this(store, nonceFactory);
+ this(store, nonceFactory, timestampVerification);
this.now = now;
}
@@ -110,7 +114,7 @@
if (timestamp != null)
{
TimestampVerificationOperation operation =
- (now == null) ? new TimestampVerificationOperation() : new
TimestampVerificationOperation(now);
+ (now == null) ? new TimestampVerificationOperation(timestampVerification) :
new TimestampVerificationOperation(now);
operation.process(message, timestamp);
}
Modified:
stack/native/branches/dlofthouse/JBWS-1316/src/main/java/org/jboss/ws/extensions/security/WSSecurityDispatcher.java
===================================================================
---
stack/native/branches/dlofthouse/JBWS-1316/src/main/java/org/jboss/ws/extensions/security/WSSecurityDispatcher.java 2008-04-14
12:13:40 UTC (rev 6415)
+++
stack/native/branches/dlofthouse/JBWS-1316/src/main/java/org/jboss/ws/extensions/security/WSSecurityDispatcher.java 2008-04-14
12:58:16 UTC (rev 6416)
@@ -214,7 +214,7 @@
SecurityStore securityStore = new SecurityStore(configuration.getKeyStoreURL(),
configuration.getKeyStoreType(), configuration.getKeyStorePassword(),
configuration.getKeyPasswords(), configuration.getTrustStoreURL(),
configuration.getTrustStoreType(), configuration.getTrustStorePassword());
NonceFactory factory = Util.loadFactory(NonceFactory.class,
configuration.getNonceFactory(), DefaultNonceFactory.class);
- SecurityDecoder decoder = new SecurityDecoder(securityStore, factory);
+ SecurityDecoder decoder = new SecurityDecoder(securityStore, factory,
configuration.getTimestampVerification());
decoder.decode(message.getSOAPPart(), secHeaderElement);
Modified:
stack/native/branches/dlofthouse/JBWS-1316/src/main/java/org/jboss/ws/extensions/security/operation/TimestampVerificationOperation.java
===================================================================
---
stack/native/branches/dlofthouse/JBWS-1316/src/main/java/org/jboss/ws/extensions/security/operation/TimestampVerificationOperation.java 2008-04-14
12:13:40 UTC (rev 6415)
+++
stack/native/branches/dlofthouse/JBWS-1316/src/main/java/org/jboss/ws/extensions/security/operation/TimestampVerificationOperation.java 2008-04-14
12:58:16 UTC (rev 6416)
@@ -23,18 +23,24 @@
import java.util.Calendar;
+import org.jboss.logging.Logger;
import org.jboss.ws.extensions.security.element.Timestamp;
import org.jboss.ws.extensions.security.exception.FailedCheckException;
import org.jboss.ws.extensions.security.exception.WSSecurityException;
+import org.jboss.ws.metadata.wsse.TimestampVerification;
import org.w3c.dom.Document;
-
public class TimestampVerificationOperation
{
+ private static final Logger log =
Logger.getLogger(TimestampVerificationOperation.class);
+
+ private TimestampVerification timestampVerification;
+
private Calendar now = null;
- public TimestampVerificationOperation()
+ public TimestampVerificationOperation(TimestampVerification timestampVerification)
{
+ this.timestampVerification = timestampVerification;
}
/**
@@ -50,14 +56,51 @@
public void process(Document message, Timestamp timestamp) throws WSSecurityException
{
- Calendar expired = timestamp.getExpires();
+ Calendar expires = timestamp.getExpires();
Calendar created = timestamp.getCreated();
+
Calendar now = (this.now == null) ? Calendar.getInstance() : this.now;
- if (created.after(now))
+ boolean rejectCreated = created.after(now);
+ if (rejectCreated && timestampVerification != null &&
timestampVerification.getCreatedTolerance() > 0)
+ {
+ Calendar tolerantCreatedNow = (Calendar)now.clone();
+ tolerantCreatedNow.add(Calendar.SECOND,
(int)timestampVerification.getCreatedTolerance());
+
+ rejectCreated = created.after(tolerantCreatedNow);
+
+ if (rejectCreated == false && timestampVerification.isWarnCreated())
+ {
+ log.warn("Accepting Timestamp with 'created' after now but
within configured tolerance.");
+ }
+ }
+
+ if (rejectCreated)
+ {
throw new WSSecurityException("Invalid timestamp, message claimed to be
created after now");
+ }
- if (expired != null && ! now.before(expired))
+ log.info("Now " + now);
+ log.info("Expires " + expires);
+ boolean rejectExpires = expires != null && !now.before(expires);
+ if (rejectExpires && timestampVerification != null &&
timestampVerification.getExpiresTolerance() > 0)
+ {
+ Calendar tolerantExpiresNow = (Calendar)now.clone();
+ tolerantExpiresNow.add(Calendar.SECOND,
(int)timestampVerification.getExpiresTolerance() * -1);
+ log.info("Toleran Expires Now " + tolerantExpiresNow);
+
+ rejectExpires = !tolerantExpiresNow.before(expires);
+
+ if (rejectExpires == false && timestampVerification.isWarnExpires())
+ {
+ log.warn("Accepting Timestamp with 'expires' in past but within
configured tolerance.");
+ }
+ }
+
+ if (rejectExpires)
+ {
throw new FailedCheckException("Expired message.");
+ }
+
}
}
Modified:
stack/native/branches/dlofthouse/JBWS-1316/src/main/java/org/jboss/ws/metadata/wsse/TimestampVerification.java
===================================================================
---
stack/native/branches/dlofthouse/JBWS-1316/src/main/java/org/jboss/ws/metadata/wsse/TimestampVerification.java 2008-04-14
12:13:40 UTC (rev 6415)
+++
stack/native/branches/dlofthouse/JBWS-1316/src/main/java/org/jboss/ws/metadata/wsse/TimestampVerification.java 2008-04-14
12:58:16 UTC (rev 6416)
@@ -29,6 +29,7 @@
*
* @author <a href="mailto:darran.lofthouse@jboss.com">Darran
Lofthouse</a>
* @version $Revision$
+ * @since Aril 14 2008
*/
public class TimestampVerification implements Serializable
{
Added:
stack/native/branches/dlofthouse/JBWS-1316/src/test/java/org/jboss/test/ws/jaxrpc/jbws1316/JBWS1316CallTestCase.java
===================================================================
---
stack/native/branches/dlofthouse/JBWS-1316/src/test/java/org/jboss/test/ws/jaxrpc/jbws1316/JBWS1316CallTestCase.java
(rev 0)
+++
stack/native/branches/dlofthouse/JBWS-1316/src/test/java/org/jboss/test/ws/jaxrpc/jbws1316/JBWS1316CallTestCase.java 2008-04-14
12:58:16 UTC (rev 6416)
@@ -0,0 +1,136 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, 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.jaxrpc.jbws1316;
+
+import java.rmi.RemoteException;
+
+import javax.naming.InitialContext;
+import javax.xml.rpc.Service;
+import javax.xml.rpc.Stub;
+
+import junit.framework.Test;
+
+import org.jboss.wsf.test.JBossWSTest;
+import org.jboss.wsf.test.JBossWSTestSetup;
+
+/**
+ * Test case to test reading the TimestampVerification configuration.
+ *
+ * @author <a href="mailto:darran.lofthouse@jboss.com">Darran
Lofthouse</a>
+ * @version $Revision$
+ * @since Aril 14 2008
+ */
+public class JBWS1316CallTestCase extends JBossWSTest
+{
+
+ private static final String MESSAGE = "Hello JBWS1316!!";
+
+ private static TestEndpoint port;
+
+ public static Test suite()
+ {
+ return new JBossWSTestSetup(JBWS1316CallTestCase.class, "jaxrpc-jbws1316.war,
jaxrpc-jbws1316-client.jar");
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ if (port == null)
+ {
+ InitialContext iniCtx = getInitialContext();
+ Service service =
(Service)iniCtx.lookup("java:comp/env/service/TestService");
+ port = (TestEndpoint)service.getPort(TestEndpoint.class);
+ }
+ }
+
+ /**
+ * Test that a message without a wsse:Security header is rejected.
+ *
+ * @throws Exception
+ */
+ public void testCall_NoSecurity() throws Exception
+ {
+ Stub stub = (Stub)port;
+ stub._setProperty(TestSecurityHandler.JBWS1316_CREATED, null);
+ stub._setProperty(TestSecurityHandler.JBWS1316_EXPIRES, null);
+
+ try
+ {
+ port.echoMessage(MESSAGE);
+ fail("Call should have failed due to no wsse:Security.");
+ }
+ catch (RemoteException e)
+ {
+ assertTrue(e.getMessage().contains("[InvalidSecurity]"));
+ }
+ }
+
+ public void testCall_ValidTimestamp() throws Exception
+ {
+ long started = System.currentTimeMillis();
+
+ Stub stub = (Stub)port;
+ stub._setProperty(TestSecurityHandler.JBWS1316_CREATED, Integer.valueOf(0));
+ stub._setProperty(TestSecurityHandler.JBWS1316_EXPIRES, Integer.valueOf(10));
+
+ String response = port.echoMessage(MESSAGE);
+ assertEquals("Expected Response", MESSAGE, response);
+
+ long finished = System.currentTimeMillis();
+ long duration = finished - started;
+ assertTrue("Execution time less than 10s", duration < 10000);
+ }
+
+ public void testCall_FutureTimestamp() throws Exception
+ {
+ long started = System.currentTimeMillis();
+
+ Stub stub = (Stub)port;
+ stub._setProperty(TestSecurityHandler.JBWS1316_CREATED, Integer.valueOf(10));
+ stub._setProperty(TestSecurityHandler.JBWS1316_EXPIRES, Integer.valueOf(20));
+
+ String response = port.echoMessage(MESSAGE);
+ assertEquals("Expected Response", MESSAGE, response);
+
+ long finished = System.currentTimeMillis();
+ long duration = finished - started;
+ assertTrue("Execution time less than 10s", duration < 10000);
+ }
+
+ public void testCall_PastExpires() throws Exception
+ {
+ long started = System.currentTimeMillis();
+
+ Stub stub = (Stub)port;
+ stub._setProperty(TestSecurityHandler.JBWS1316_CREATED, Integer.valueOf(0));
+ stub._setProperty(TestSecurityHandler.JBWS1316_EXPIRES, Integer.valueOf(-5));
+
+ String response = port.echoMessage(MESSAGE);
+ assertEquals("Expected Response", MESSAGE, response);
+
+ long finished = System.currentTimeMillis();
+ long duration = finished - started;
+ assertTrue("Execution time less than 10s", duration < 10000);
+ }
+
+}
Property changes on:
stack/native/branches/dlofthouse/JBWS-1316/src/test/java/org/jboss/test/ws/jaxrpc/jbws1316/JBWS1316CallTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
stack/native/branches/dlofthouse/JBWS-1316/src/test/java/org/jboss/test/ws/jaxrpc/jbws1316/JBWS1316ConfigurationTestCase.java
===================================================================
---
stack/native/branches/dlofthouse/JBWS-1316/src/test/java/org/jboss/test/ws/jaxrpc/jbws1316/JBWS1316ConfigurationTestCase.java 2008-04-14
12:13:40 UTC (rev 6415)
+++
stack/native/branches/dlofthouse/JBWS-1316/src/test/java/org/jboss/test/ws/jaxrpc/jbws1316/JBWS1316ConfigurationTestCase.java 2008-04-14
12:58:16 UTC (rev 6416)
@@ -35,6 +35,7 @@
*
* @author <a href="mailto:darran.lofthouse@jboss.com">Darran
Lofthouse</a>
* @version $Revision$
+ * @since Aril 14 2008
*/
public class JBWS1316ConfigurationTestCase extends JBossWSTest
{
Added:
stack/native/branches/dlofthouse/JBWS-1316/src/test/java/org/jboss/test/ws/jaxrpc/jbws1316/TestEndpoint.java
===================================================================
---
stack/native/branches/dlofthouse/JBWS-1316/src/test/java/org/jboss/test/ws/jaxrpc/jbws1316/TestEndpoint.java
(rev 0)
+++
stack/native/branches/dlofthouse/JBWS-1316/src/test/java/org/jboss/test/ws/jaxrpc/jbws1316/TestEndpoint.java 2008-04-14
12:58:16 UTC (rev 6416)
@@ -0,0 +1,40 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, 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.jaxrpc.jbws1316;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+/**
+ * Simple TestEndpoint to test the handling to WSSE timestamps.
+ *
+ * @author <a href="mailto:darran.lofthouse@jboss.com">Darran
Lofthouse</a>
+ * @version $Revision$
+ * @since Aril 14 2008
+ */
+public interface TestEndpoint extends Remote
+{
+
+ public String echoMessage(final String message) throws RemoteException;
+
+}
Property changes on:
stack/native/branches/dlofthouse/JBWS-1316/src/test/java/org/jboss/test/ws/jaxrpc/jbws1316/TestEndpoint.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/native/branches/dlofthouse/JBWS-1316/src/test/java/org/jboss/test/ws/jaxrpc/jbws1316/TestEndpointImpl.java
===================================================================
---
stack/native/branches/dlofthouse/JBWS-1316/src/test/java/org/jboss/test/ws/jaxrpc/jbws1316/TestEndpointImpl.java
(rev 0)
+++
stack/native/branches/dlofthouse/JBWS-1316/src/test/java/org/jboss/test/ws/jaxrpc/jbws1316/TestEndpointImpl.java 2008-04-14
12:58:16 UTC (rev 6416)
@@ -0,0 +1,40 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, 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.jaxrpc.jbws1316;
+
+/**
+ * Simple TestEndpoint to test the handling to WSSE timestamps.
+ *
+ * @author <a href="mailto:darran.lofthouse@jboss.com">Darran
Lofthouse</a>
+ * @version $Revision$
+ * @since Aril 14 2008
+ */
+public class TestEndpointImpl implements TestEndpoint
+{
+
+ public String echoMessage(String message)
+ {
+ return message;
+ }
+
+}
Property changes on:
stack/native/branches/dlofthouse/JBWS-1316/src/test/java/org/jboss/test/ws/jaxrpc/jbws1316/TestEndpointImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/native/branches/dlofthouse/JBWS-1316/src/test/java/org/jboss/test/ws/jaxrpc/jbws1316/TestSecurityHandler.java
===================================================================
---
stack/native/branches/dlofthouse/JBWS-1316/src/test/java/org/jboss/test/ws/jaxrpc/jbws1316/TestSecurityHandler.java
(rev 0)
+++
stack/native/branches/dlofthouse/JBWS-1316/src/test/java/org/jboss/test/ws/jaxrpc/jbws1316/TestSecurityHandler.java 2008-04-14
12:58:16 UTC (rev 6416)
@@ -0,0 +1,115 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, 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.jaxrpc.jbws1316;
+
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.TimeZone;
+
+import javax.xml.namespace.QName;
+import javax.xml.rpc.handler.GenericHandler;
+import javax.xml.rpc.handler.MessageContext;
+
+import org.jboss.ws.core.CommonMessageContext;
+import org.jboss.ws.core.soap.SOAPMessageImpl;
+import org.jboss.ws.extensions.security.Constants;
+import org.jboss.ws.extensions.security.Util;
+import org.jboss.xb.binding.SimpleTypeBindings;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * Simple handler to add wsse:Security and Timestamp to header in controlled
+ * way to test JBWS-1316 implementation.
+ *
+ * @author <a href="mailto:darran.lofthouse@jboss.com">Darran
Lofthouse</a>
+ * @version $Revision$
+ * @since Aril 14 2008
+ */
+public class TestSecurityHandler extends GenericHandler
+{
+
+ public static final String JBWS1316_CREATED = "jbws1316.created";
+
+ public static final String JBWS1316_EXPIRES = "jbws1316.expires";
+
+ @Override
+ public boolean handleRequest(MessageContext msgContext)
+ {
+ Integer createdValue = (Integer)msgContext.getProperty(JBWS1316_CREATED);
+ Integer expiresValue = (Integer)msgContext.getProperty(JBWS1316_EXPIRES);
+
+ // Created is bare minimum to add the header.
+ if (createdValue == null)
+ {
+ return super.handleRequest(msgContext);
+ }
+
+ Calendar baseCalendar = new
GregorianCalendar(TimeZone.getTimeZone("UTC"));
+
+ Calendar createdCalendar = (Calendar)baseCalendar.clone();
+ createdCalendar.add(Calendar.SECOND, createdValue);
+
+ Calendar expiresCalendar = null;
+
+ if (expiresValue != null)
+ {
+ expiresCalendar = (Calendar)baseCalendar.clone();
+ expiresCalendar.add(Calendar.SECOND, expiresValue);
+ }
+
+ CommonMessageContext ctx = (CommonMessageContext)msgContext;
+ SOAPMessageImpl soapMessage = (SOAPMessageImpl)ctx.getSOAPMessage();
+ Document message = soapMessage.getSOAPPart();
+
+ Element soapHeader = Util.findOrCreateSoapHeader(message.getDocumentElement());
+
+ Element wsseSecurityElement = message.createElementNS(Constants.WSSE_NS,
Constants.WSSE_HEADER);
+ Util.addNamespace(wsseSecurityElement, Constants.WSSE_PREFIX, Constants.WSSE_NS);
+ Util.addNamespace(wsseSecurityElement, Constants.WSU_PREFIX, Constants.WSU_NS);
+
+ Element wsseTimestampElement = message.createElementNS(Constants.WSU_NS,
Constants.WSU_PREFIX + ":" + "Timestamp");
+ wsseTimestampElement.setAttributeNS(Constants.WSU_NS, Constants.WSU_ID,
"timestamp");
+ Element child = message.createElementNS(Constants.WSU_NS, Constants.WSU_PREFIX +
":" + "Created");
+
child.appendChild(message.createTextNode(SimpleTypeBindings.marshalDateTime(createdCalendar)));
+ wsseTimestampElement.appendChild(child);
+ if (expiresCalendar != null)
+ {
+ child = message.createElementNS(Constants.WSU_NS, Constants.WSU_PREFIX +
":" + "Expires");
+
child.appendChild(message.createTextNode(SimpleTypeBindings.marshalDateTime(expiresCalendar)));
+ wsseTimestampElement.appendChild(child);
+ }
+ wsseSecurityElement.appendChild(wsseTimestampElement);
+
+ soapHeader.insertBefore(wsseSecurityElement, soapHeader.getFirstChild());
+
+ return true;
+ }
+
+ @Override
+ public QName[] getHeaders()
+ {
+ return null;
+ }
+
+}
Property changes on:
stack/native/branches/dlofthouse/JBWS-1316/src/test/java/org/jboss/test/ws/jaxrpc/jbws1316/TestSecurityHandler.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/META-INF/application-client.xml
===================================================================
---
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/META-INF/application-client.xml
(rev 0)
+++
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/META-INF/application-client.xml 2008-04-14
12:58:16 UTC (rev 6416)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<application-client
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/application-client_1_4.xsd"
+ version="1.4">
+
+ <display-name>HelloService</display-name>
+
+ <service-ref>
+ <service-ref-name>service/TestService</service-ref-name>
+ <service-interface>javax.xml.rpc.Service</service-interface>
+ <wsdl-file>META-INF/wsdl/TestService.wsdl</wsdl-file>
+ <jaxrpc-mapping-file>META-INF/jaxrpc-mapping.xml</jaxrpc-mapping-file>
+ <port-component-ref>
+
<service-endpoint-interface>org.jboss.test.ws.jaxrpc.jbws1316.TestEndpoint</service-endpoint-interface>
+ </port-component-ref>
+ <handler>
+ <handler-name>ClientHandler</handler-name>
+
<handler-class>org.jboss.test.ws.jaxrpc.jbws1316.TestSecurityHandler</handler-class>
+ </handler>
+ </service-ref>
+
+</application-client>
+
Property changes on:
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/META-INF/application-client.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/META-INF/jboss-client.xml
===================================================================
---
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/META-INF/jboss-client.xml
(rev 0)
+++
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/META-INF/jboss-client.xml 2008-04-14
12:58:16 UTC (rev 6416)
@@ -0,0 +1,13 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+
+<!DOCTYPE jboss-client PUBLIC "-//JBoss//DTD Application Client 4.0//EN"
"http://www.jboss.org/j2ee/dtd/jboss-client_4_0.dtd">
+
+<jboss-client>
+ <jndi-name>jbossws-client</jndi-name>
+
+ <service-ref>
+ <service-ref-name>service/TestService</service-ref-name>
+
<wsdl-override>http://@jboss.bind.address@:8080/jaxrpc-jbws1316?wsdl</wsdl-override>
+ </service-ref>
+
+</jboss-client>
Property changes on:
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/META-INF/jboss-client.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/WEB-INF/jaxrpc-mapping.xml
===================================================================
---
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/WEB-INF/jaxrpc-mapping.xml
(rev 0)
+++
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/WEB-INF/jaxrpc-mapping.xml 2008-04-14
12:58:16 UTC (rev 6416)
@@ -0,0 +1,37 @@
+<?xml version='1.0' encoding='UTF-8'?><java-wsdl-mapping
version='1.1'
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://www.ibm.com/webservices/xsd/j2ee_jaxrpc_mapping_1_1.xsd'>
+ <package-mapping>
+ <package-type>org.jboss.test.ws.jaxrpc.jbws1316</package-type>
+ <
namespaceURI>http://ws.test.jboss.org/jbws1316/types</namespaceURI>
+ </package-mapping>
+ <service-interface-mapping>
+
<service-interface>org.jboss.test.ws.jaxrpc.jbws1316.TestService</service-interface>
+ <wsdl-service-name
xmlns:serviceNS='http://ws.test.jboss.org/jbws1316'>serviceNS:...
+ <port-mapping>
+ <port-name>TestEndpointPort</port-name>
+ <java-port-name>TestEndpointPort</java-port-name>
+ </port-mapping>
+ </service-interface-mapping>
+ <service-endpoint-interface-mapping>
+
<service-endpoint-interface>org.jboss.test.ws.jaxrpc.jbws1316.TestEndpoint</service-endpoint-interface>
+ <wsdl-port-type
xmlns:portTypeNS='http://ws.test.jboss.org/jbws1316'>portTypeN...
+ <wsdl-binding
xmlns:bindingNS='http://ws.test.jboss.org/jbws1316'>bindingNS:...
+ <service-endpoint-method-mapping>
+ <java-method-name>echoMessage</java-method-name>
+ <wsdl-operation>echoMessage</wsdl-operation>
+ <method-param-parts-mapping>
+ <param-position>0</param-position>
+ <param-type>java.lang.String</param-type>
+ <wsdl-message-mapping>
+ <wsdl-message
xmlns:wsdlMsgNS='http://ws.test.jboss.org/jbws1316'>wsdlMsgNS:...
+ <wsdl-message-part-name>String_1</wsdl-message-part-name>
+ <parameter-mode>IN</parameter-mode>
+ </wsdl-message-mapping>
+ </method-param-parts-mapping>
+ <wsdl-return-value-mapping>
+ <method-return-value>java.lang.String</method-return-value>
+ <wsdl-message
xmlns:wsdlMsgNS='http://ws.test.jboss.org/jbws1316'>wsdlMsgNS:...
+ <wsdl-message-part-name>result</wsdl-message-part-name>
+ </wsdl-return-value-mapping>
+ </service-endpoint-method-mapping>
+ </service-endpoint-interface-mapping>
+</java-wsdl-mapping>
\ No newline at end of file
Property changes on:
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/WEB-INF/jaxrpc-mapping.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/WEB-INF/jboss-wsse-server.xml
===================================================================
---
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/WEB-INF/jboss-wsse-server.xml
(rev 0)
+++
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/WEB-INF/jboss-wsse-server.xml 2008-04-14
12:58:16 UTC (rev 6416)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jboss-ws-security
xmlns="http://www.jboss.com/ws-security/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://www.jboss.com/ws-security/config
http://www.jboss.com/ws-security/schema/jboss-ws-security_1_0.xsd">
+
+ <timestamp-verification createdTolerance="10"
expiresTolerance="10" />
+
+ <config>
+ <requires>
+ <timestamp ttl="30" />
+ </requires>
+ </config>
+
+</jboss-ws-security>
\ No newline at end of file
Property changes on:
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/WEB-INF/jboss-wsse-server.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/WEB-INF/web.xml
===================================================================
---
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/WEB-INF/web.xml
(rev 0)
+++
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/WEB-INF/web.xml 2008-04-14
12:58:16 UTC (rev 6416)
@@ -0,0 +1,23 @@
+<?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">
+
+ <context-param>
+ <param-name>jbossws-config-name</param-name>
+ <param-value>Standard WSSecurity Endpoint</param-value>
+ </context-param>
+
+ <servlet>
+ <servlet-name>TestEndpoint</servlet-name>
+
<servlet-class>org.jboss.test.ws.jaxrpc.jbws1316.TestEndpointImpl</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>TestEndpoint</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+</web-app>
+
Property changes on:
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/WEB-INF/web.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/WEB-INF/webservices.xml
===================================================================
---
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/WEB-INF/webservices.xml
(rev 0)
+++
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/WEB-INF/webservices.xml 2008-04-14
12:58:16 UTC (rev 6416)
@@ -0,0 +1,15 @@
+<webservices version='1.1'
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://www.ibm.com/webservices/xsd/j2ee_web_services_1_1.xsd'>
+ <webservice-description>
+ <webservice-description-name>TestService</webservice-description-name>
+ <wsdl-file>WEB-INF/wsdl/TestService.wsdl</wsdl-file>
+ <jaxrpc-mapping-file>WEB-INF/jaxrpc-mapping.xml</jaxrpc-mapping-file>
+ <port-component>
+ <port-component-name>TestEndpointPort</port-component-name>
+ <wsdl-port
xmlns:portNS='http://ws.test.jboss.org/jbws1316'>portNS:TestEn...
+
<service-endpoint-interface>org.jboss.test.ws.jaxrpc.jbws1316.TestEndpoint</service-endpoint-interface>
+ <service-impl-bean>
+ <servlet-link>TestEndpoint</servlet-link>
+ </service-impl-bean>
+ </port-component>
+ </webservice-description>
+</webservices>
\ No newline at end of file
Property changes on:
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/WEB-INF/webservices.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/WEB-INF/wsdl/TestService.wsdl
===================================================================
---
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/WEB-INF/wsdl/TestService.wsdl
(rev 0)
+++
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/WEB-INF/wsdl/TestService.wsdl 2008-04-14
12:58:16 UTC (rev 6416)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<definitions name='TestService'
targetNamespace='http://ws.test.jboss.org/jbws1316'
xmlns='http://schemas.xmlsoap.org/wsdl/'
xmlns:ns1='http://ws.test.jboss.org/jbws1316/types'
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:tns='http://ws.test.jboss.org/jbws1316'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
+ <types/>
+ <message name='TestEndpoint_echoMessage'>
+ <part name='String_1' type='xsd:string'/>
+ </message>
+ <message name='TestEndpoint_echoMessageResponse'>
+ <part name='result' type='xsd:string'/>
+ </message>
+ <portType name='TestEndpoint'>
+ <operation name='echoMessage' parameterOrder='String_1'>
+ <input message='tns:TestEndpoint_echoMessage'/>
+ <output message='tns:TestEndpoint_echoMessageResponse'/>
+ </operation>
+ </portType>
+ <binding name='TestEndpointBinding' type='tns:TestEndpoint'>
+ <soap:binding style='rpc'
transport='http://schemas.xmlsoap.org/soap/http'/>
+ <operation name='echoMessage'>
+ <soap:operation soapAction=''/>
+ <input>
+ <soap:body
namespace='http://ws.test.jboss.org/jbws1316'
use='literal'/>
+ </input>
+ <output>
+ <soap:body
namespace='http://ws.test.jboss.org/jbws1316'
use='literal'/>
+ </output>
+ </operation>
+ </binding>
+ <service name='TestService'>
+ <port binding='tns:TestEndpointBinding' name='TestEndpointPort'>
+ <soap:address location='REPLACE_WITH_ACTUAL_URL'/>
+ </port>
+ </service>
+</definitions>
\ No newline at end of file
Property changes on:
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/WEB-INF/wsdl/TestService.wsdl
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/wstools-config.xml
===================================================================
---
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/wstools-config.xml
(rev 0)
+++
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/wstools-config.xml 2008-04-14
12:58:16 UTC (rev 6416)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ wstools.sh -cp ../../../../../output/tests/classes -dest ./WEB-INF -config
wstools-config.xml
+-->
+
+<configuration
xmlns="http://www.jboss.org/jbossws-tools"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://www.jboss.org/jbossws-tools
http://www.jboss.org/jbossws-tools/schema/jbossws-tool_1_0.xsd">
+ <java-wsdl>
+ <service name="TestService"
endpoint="org.jboss.test.ws.jaxrpc.jbws1316.TestEndpoint"
style="rpc">
+ </service>
+ <namespaces
target-namespace="http://ws.test.jboss.org/jbws1316"
type-namespace="http://ws.test.jboss.org/jbws1316/types"/>
+ <mapping file="jaxrpc-mapping.xml"/>
+ <webservices servlet-link="TestEndpoint"/>
+ </java-wsdl>
+</configuration>
Property changes on:
stack/native/branches/dlofthouse/JBWS-1316/src/test/resources/jaxrpc/jbws1316/wstools-config.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF