Author: ema
Date: Sun Jul 10 15:00:38 2011
New Revision: 1144870
URL: http://svn.apache.org/viewvc?rev=1144870&view=rev
Log:
[CXF-3639]:Duplicate soap body is appended when the endpoint is both configured
with soap handler and wsse enabled
Added:
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/Client_Encrypt.properties
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/Client_Sign.properties
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/HelloWorld.java
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/HelloWorldImpl.java
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/JAXWSHandler.java
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/Server.java
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/Server_Decrypt.properties
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/Server_SignVerf.properties
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/UsernamePasswordCallback.java
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/WSSecTest.java
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/WSSecTest.java~
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/client-keystore.jks
(with props)
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/client-truststore.jks
(with props)
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/client.xml
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/server-keystore.jks
(with props)
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/server-truststore.jks
(with props)
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/server.xml
Modified:
cxf/branches/2.2.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
Modified:
cxf/branches/2.2.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java?rev=1144870&r1=1144869&r2=1144870&view=diff
==============================================================================
---
cxf/branches/2.2.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
(original)
+++
cxf/branches/2.2.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
Sun Jul 10 15:00:38 2011
@@ -70,6 +70,7 @@ import org.apache.cxf.staxutils.W3CDOMSt
*/
public class SAAJInInterceptor extends AbstractSoapInterceptor {
private static final ResourceBundle BUNDLE =
BundleUtils.getBundle(SAAJInInterceptor.class);
+ private static final String BODY_FILLED_IN =
SAAJInInterceptor.class.getName() + ".BODY_DONE";
private MessageFactory factory11;
private MessageFactory factory12;
@@ -96,6 +97,11 @@ public class SAAJInInterceptor extends A
}
public void handleMessage(SoapMessage message) throws Fault {
+ Boolean bodySet = (Boolean)message.get(BODY_FILLED_IN);
+ if (bodySet != null && bodySet == Boolean.TRUE) {
+ return;
+ }
+ message.put(BODY_FILLED_IN, Boolean.TRUE);
try {
MessageFactory factory = getFactory(message);
SOAPMessage soapMessage = factory.createMessage();
Added:
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/Client_Encrypt.properties
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/Client_Encrypt.properties?rev=1144870&view=auto
==============================================================================
---
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/Client_Encrypt.properties
(added)
+++
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/Client_Encrypt.properties
Sun Jul 10 15:00:38 2011
@@ -0,0 +1,23 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+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=storepassword
+org.apache.ws.security.crypto.merlin.keystore.alias=serverx509v1
+org.apache.ws.security.crypto.merlin.file=org/apache/cxf/systest/ws/security/handler/client-truststore.jks
\ No newline at end of file
Added:
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/Client_Sign.properties
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/Client_Sign.properties?rev=1144870&view=auto
==============================================================================
---
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/Client_Sign.properties
(added)
+++
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/Client_Sign.properties
Sun Jul 10 15:00:38 2011
@@ -0,0 +1,24 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+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=storepassword
+org.apache.ws.security.crypto.merlin.keystore.alias=clientx509v1
+org.apache.ws.security.crypto.merlin.file=org/apache/cxf/systest/ws/security/handler/client-keystore.jks
+
Added:
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/HelloWorld.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/HelloWorld.java?rev=1144870&view=auto
==============================================================================
---
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/HelloWorld.java
(added)
+++
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/HelloWorld.java
Sun Jul 10 15:00:38 2011
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.systest.ws.security.handler;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebService;
+
+@WebService(name = "HelloWorld", targetNamespace =
"http://cxf.apache.org/wsse/handler/helloworld")
+public interface HelloWorld {
+ @WebMethod
+ String sayHello(@WebParam(name = "toWhom") String to);
+
+}
Added:
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/HelloWorldImpl.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/HelloWorldImpl.java?rev=1144870&view=auto
==============================================================================
---
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/HelloWorldImpl.java
(added)
+++
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/HelloWorldImpl.java
Sun Jul 10 15:00:38 2011
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.systest.ws.security.handler;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebService;
+
+@WebService(name = "HelloWorld", targetNamespace =
"http://cxf.apache.org/wsse/handler/helloworld",
+ endpointInterface =
"org.apache.cxf.systest.ws.security.handler.HelloWorld")
+public class HelloWorldImpl implements HelloWorld {
+ @WebMethod
+ public String sayHello(@WebParam(name = "toWhom") String toWhom) {
+ return "Hello " + toWhom;
+
+ }
+}
Added:
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/JAXWSHandler.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/JAXWSHandler.java?rev=1144870&view=auto
==============================================================================
---
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/JAXWSHandler.java
(added)
+++
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/JAXWSHandler.java
Sun Jul 10 15:00:38 2011
@@ -0,0 +1,91 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.systest.ws.security.handler;
+
+import java.io.PrintStream;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.soap.SOAPHandler;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+public class JAXWSHandler implements SOAPHandler<SOAPMessageContext> {
+
+ private PrintStream out;
+
+ public JAXWSHandler() {
+ setLogStream(System.out);
+ }
+
+ protected final void setLogStream(PrintStream ps) {
+ out = ps;
+ }
+
+ @SuppressWarnings("rawtypes")
+ public void init(Map c) {
+ }
+
+ public Set<QName> getHeaders() {
+ return null;
+ }
+
+ public boolean handleMessage(SOAPMessageContext smc) {
+ logToSystemOut(smc);
+ return true;
+ }
+
+ public boolean handleFault(SOAPMessageContext smc) {
+ logToSystemOut(smc);
+ return true;
+ }
+
+ public void close(MessageContext messageContext) {
+
+ }
+
+ public void destroy() {
+
+ }
+
+ protected void logToSystemOut(SOAPMessageContext smc) {
+ Boolean outboundProperty =
(Boolean)smc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
+
+ if (outboundProperty.booleanValue()) {
+ out.println("\nOutbound message:");
+ } else {
+ out.println("\nInbound message:");
+ }
+
+ SOAPMessage message = smc.getMessage();
+ try {
+ message.writeTo(out);
+ out.println();
+ } catch (Exception e) {
+ out.println("Exception in handler: " + e);
+ }
+
+ out.println("WSDL_SERVICE = " + smc.get(MessageContext.WSDL_SERVICE));
+ out.println("WSDL_INTERFACE = " +
smc.get(MessageContext.WSDL_INTERFACE));
+ out.println("WSDL_PORT = " + smc.get(MessageContext.WSDL_PORT));
+ out.println("WSDL_OPERATION = " +
smc.get(MessageContext.WSDL_OPERATION));
+ }
+}
Added:
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/Server.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/Server.java?rev=1144870&view=auto
==============================================================================
---
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/Server.java
(added)
+++
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/Server.java
Sun Jul 10 15:00:38 2011
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.systest.ws.security.handler;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+
+public class Server extends AbstractBusTestServerBase {
+ public static final String PORT = allocatePort(Server.class);
+
+ protected void run() {
+ SpringBusFactory factory = new SpringBusFactory();
+ Bus bus =
factory.createBus("org/apache/cxf/systest/ws/security/handler/server.xml");
+ BusFactory.setDefaultBus(bus);
+ setBus(bus);
+ }
+
+ public static void main(String[] args) {
+ try {
+ Server s = new Server();
+ s.start();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ System.exit(-1);
+ } finally {
+ System.out.println("done!");
+ }
+ }
+}
Added:
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/Server_Decrypt.properties
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/Server_Decrypt.properties?rev=1144870&view=auto
==============================================================================
---
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/Server_Decrypt.properties
(added)
+++
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/Server_Decrypt.properties
Sun Jul 10 15:00:38 2011
@@ -0,0 +1,23 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+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=storepassword
+org.apache.ws.security.crypto.merlin.keystore.alias=serverx509v1
+org.apache.ws.security.crypto.merlin.file=org/apache/cxf/systest/ws/security/handler/server-keystore.jks
Added:
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/Server_SignVerf.properties
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/Server_SignVerf.properties?rev=1144870&view=auto
==============================================================================
---
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/Server_SignVerf.properties
(added)
+++
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/Server_SignVerf.properties
Sun Jul 10 15:00:38 2011
@@ -0,0 +1,23 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+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=storepassword
+org.apache.ws.security.crypto.merlin.keystore.alias=clientx509v1
+org.apache.ws.security.crypto.merlin.file=org/apache/cxf/systest/ws/security/handler/server-truststore.jks
Added:
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/UsernamePasswordCallback.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/UsernamePasswordCallback.java?rev=1144870&view=auto
==============================================================================
---
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/UsernamePasswordCallback.java
(added)
+++
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/UsernamePasswordCallback.java
Sun Jul 10 15:00:38 2011
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.systest.ws.security.handler;
+
+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 UsernamePasswordCallback implements CallbackHandler {
+ private Map<String, String> passwords = new HashMap<String, String>();
+
+ public UsernamePasswordCallback() {
+ passwords.put("Alice", "ecilA");
+ passwords.put("abcd", "dcba");
+ passwords.put("clientx509v1", "storepassword");
+ passwords.put("serverx509v1", "storepassword");
+ }
+
+ /**
+ * Here, we attempt 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];
+
+ // System.out.println("**************** Server checking id:
"+pc.getIdentifer());
+
+ String pass = passwords.get(pc.getIdentifier());
+ if (pass != null) {
+ pc.setPassword(pass);
+ return;
+ }
+ }
+
+ //
+ // Password not found
+ //
+ throw new IOException();
+ }
+
+ /**
+ * Add an alias/password pair to the callback mechanism.
+ */
+ public void setAliasPassword(String alias, String password) {
+ passwords.put(alias, password);
+ }
+}
Added:
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/WSSecTest.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/WSSecTest.java?rev=1144870&view=auto
==============================================================================
---
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/WSSecTest.java
(added)
+++
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/WSSecTest.java
Sun Jul 10 15:00:38 2011
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.systest.ws.security.handler;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class WSSecTest extends AbstractBusClientServerTestBase {
+ public static final String PORT = allocatePort(Server.class);
+
+ @BeforeClass
+ public static void startServers() throws Exception {
+ assertTrue("Server failed to launch", launchServer(Server.class));
+ }
+
+ @Test
+ public void testClientServer() throws Exception {
+
+ Bus bus = new
SpringBusFactory().createBus("org/apache/cxf/systest/ws/security/handler/client.xml");
+
+ BusFactory.setDefaultBus(bus);
+ BusFactory.setThreadDefaultBus(bus);
+ Service service = Service.create(new URL("http://localhost:" + PORT +
"/wsse/HelloWorldWS?wsdl"),
+ new
QName("http://cxf.apache.org/wsse/handler/helloworld",
+ "HelloWorldImplService"));
+ QName portName = new
QName("http://cxf.apache.org/wsse/handler/helloworld", "HelloWorldPort");
+
+ HelloWorld port = service.getPort(portName, HelloWorld.class);
+ updateAddressPort(port, PORT);
+ assertEquals("Hello CXF", port.sayHello("CXF"));
+ }
+
+}
Added:
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/WSSecTest.java~
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/WSSecTest.java%7E?rev=1144870&view=auto
==============================================================================
---
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/WSSecTest.java~
(added)
+++
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/WSSecTest.java~
Sun Jul 10 15:00:38 2011
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.systest.ws.security.handler;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class WSSecTest extends AbstractBusClientServerTestBase {
+ public static final String PORT = allocatePort(Server.class);
+
+ @BeforeClass
+ public static void startServers() throws Exception {
+ assertTrue("Server failed to launch", launchServer(Server.class,
true));
+ }
+
+ @Test
+ public void testClientServer() throws Exception {
+
+ Bus bus = new
SpringBusFactory().createBus("org/apache/cxf/systest/ws/security/handler/client.xml");
+
+ BusFactory.setDefaultBus(bus);
+ BusFactory.setThreadDefaultBus(bus);
+ Service service = Service.create(new URL("http://localhost:" + PORT +
"/wsse/HelloWorldWS?wsdl"),
+ new
QName("http://cxf.apache.org/wsse/handler/helloworld",
+ "HelloWorldImplService"));
+ QName portName = new
QName("http://cxf.apache.org/wsse/handler/helloworld", "HelloWorldPort");
+
+ HelloWorld port = service.getPort(portName, HelloWorld.class);
+ updateAddressPort(port, PORT);
+ assertEquals("Hello CXF", port.sayHello("CXF"));
+ }
+
+}
Added:
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/client-keystore.jks
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/client-keystore.jks?rev=1144870&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/client-keystore.jks
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added:
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/client-truststore.jks
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/client-truststore.jks?rev=1144870&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/client-truststore.jks
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added:
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/client.xml
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/client.xml?rev=1144870&view=auto
==============================================================================
---
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/client.xml
(added)
+++
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/client.xml
Sun Jul 10 15:00:38 2011
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:cxf="http://cxf.apache.org/core"
+ xmlns:wsa="http://cxf.apache.org/ws/addressing"
+ xmlns:http="http://cxf.apache.org/transports/http/configuration"
+ xmlns:wsrm-policy="http://schemas.xmlsoap.org/ws/2005/02/rm/policy"
+ xmlns:wsrm-mgr="http://cxf.apache.org/ws/rm/manager"
+ xmlns:beans='http://www.springframework.org/schema/beans'
+ xmlns:jaxws='http://cxf.apache.org/jaxws'
+ xmlns:ns1='http://secure_invoke/helloworld'
+ xsi:schemaLocation="
+ http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
+ http://cxf.apache.org/transports/http/configuration
http://cxf.apache.org/schemas/configuration/http-conf.xsd
+ http://schemas.xmlsoap.org/ws/2005/02/rm/policy
http://schemas.xmlsoap.org/ws/2005/02/rm/wsrm-policy.xsd
+ http://cxf.apache.org/ws/rm/manager
http://cxf.apache.org/schemas/configuration/wsrm-manager.xsd
+ http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
+
+ <bean id="UsernameTokenSign_Request"
class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor"
+
name="http://cxf.apache.org/wsse/handler/helloworld}HelloWorldPort.Request" >
+ <constructor-arg>
+ <map>
+ <entry key="action" value="UsernameToken Timestamp Signature"/>
+ <entry key="passwordType" value="PasswordDigest"/>
+ <entry key="user" value="clientx509v1"/>
+ <entry key="passwordCallbackClass"
value="org.apache.cxf.systest.ws.security.handler.UsernamePasswordCallback"/>
+ <entry key="signaturePropFile"
value="org/apache/cxf/systest/ws/security/handler/Client_Sign.properties"/>
+ <entry key="signatureKeyIdentifier" value="DirectReference"/>
+ <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"/>
+ </map>
+ </constructor-arg>
+ </bean>
+
+ <bean id="UsernameTokenSign_Response"
class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor"
+
name="{http://cxf.apache.org/wsse/handler/helloworld}HelloWorldPort.Response" >
+ <constructor-arg>
+ <map>
+ <entry key="action" value="UsernameToken Timestamp Signature"/>
+ <entry key="passwordType" value="PasswordText"/>
+ <entry key="user" value="serverx509v1"/>
+ <entry key="passwordCallbackClass"
value="org.apache.cxf.systest.ws.security.handler.UsernamePasswordCallback"/>
+ <entry key="signaturePropFile"
value="org/apache/cxf/systest/ws/security/handler/Client_Encrypt.properties"/>
+ <entry key="signatureKeyIdentifier" value="DirectReference"/>
+ </map>
+ </constructor-arg>
+ </bean>
+
+
+ <cxf:bus>
+ <cxf:outInterceptors>
+ <ref bean="UsernameTokenSign_Request"/>
+ <bean class="org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor"/>
+ </cxf:outInterceptors>
+ <cxf:inInterceptors>
+ <ref bean="UsernameTokenSign_Response"/>
+ <bean class="org.apache.cxf.binding.soap.saaj.SAAJInInterceptor"/>
+ </cxf:inInterceptors>
+ </cxf:bus>
+
+</beans>
Added:
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/server-keystore.jks
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/server-keystore.jks?rev=1144870&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/server-keystore.jks
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added:
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/server-truststore.jks
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/server-truststore.jks?rev=1144870&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/server-truststore.jks
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added:
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/server.xml
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/server.xml?rev=1144870&view=auto
==============================================================================
---
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/server.xml
(added)
+++
cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/handler/server.xml
Sun Jul 10 15:00:38 2011
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<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
+
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
/>
+
+ <bean id="UsernameTokenSign_Request"
class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
+ <constructor-arg>
+ <map>
+ <entry key="action" value="UsernameToken
Timestamp Signature" />
+ <entry key="passwordType"
value="PasswordDigest" />
+ <entry key="user" value="serverx509v1" />
+ <entry key="passwordCallbackClass"
+
value="org.apache.cxf.systest.ws.security.handler.UsernamePasswordCallback" />
+ <entry key="signaturePropFile"
+
value="org/apache/cxf/systest/ws/security/handler/Server_SignVerf.properties" />
+ <entry key="signatureKeyIdentifier"
value="DirectReference" />
+ </map>
+ </constructor-arg>
+ </bean>
+
+ <bean id="UsernameTokenSign_Response"
class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor">
+ <constructor-arg>
+ <map>
+ <entry key="action" value="UsernameToken
Timestamp Signature" />
+ <entry key="passwordType" value="PasswordText"
/>
+ <entry key="user" value="serverx509v1" />
+ <entry key="passwordCallbackClass"
+
value="org.apache.cxf.systest.ws.security.handler.UsernamePasswordCallback" />
+ <entry key="signaturePropFile"
+
value="org/apache/cxf/systest/ws/security/handler/Server_Decrypt.properties" />
+ <entry key="signatureKeyIdentifier"
value="DirectReference" />
+ <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"
/>
+ </map>
+ </constructor-arg>
+ </bean>
+
+ <jaxws:endpoint id='HelloWorldWS'
+
address="http://localhost:${testutil.ports.Server}/wsse/HelloWorldWS"
+ wsdlLocation=""
+
implementor='org.apache.cxf.systest.ws.security.handler.HelloWorldImpl'>
+ <jaxws:inInterceptors>
+ <ref bean="UsernameTokenSign_Request" />
+ <bean
class="org.apache.cxf.binding.soap.saaj.SAAJInInterceptor" />
+ </jaxws:inInterceptors>
+ <jaxws:outInterceptors>
+ <ref bean="UsernameTokenSign_Response" />
+ <bean
class="org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor" />
+ </jaxws:outInterceptors>
+ <jaxws:handlers>
+ <bean
class="org.apache.cxf.systest.ws.security.handler.JAXWSHandler" />
+ </jaxws:handlers>
+ </jaxws:endpoint>
+
+
+</beans>