You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by ul...@apache.org on 2007/07/30 23:35:24 UTC
svn commit: r561135 - in /incubator/cxf/trunk:
api/src/main/java/org/apache/cxf/headers/
rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/
rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/
systests/ systests/src/test/jav...
Author: ulhasbhole
Date: Mon Jul 30 14:35:22 2007
New Revision: 561135
URL: http://svn.apache.org/viewvc?view=rev&rev=561135
Log:
* Fix for JIRA https://issues.apache.org/jira/browse/CXF-790 related to soap headers getting copied back into response.
Added:
incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapHeaderOutFilterInterceptor.java (with props)
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/GreeterImpl.java (with props)
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/KeystorePasswordCallback.java (with props)
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/Server.java (with props)
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/WSSecurityClientTest.java (with props)
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/alice.properties (with props)
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/bob.properties (with props)
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/client.xml (with props)
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/hello_world.wsdl (with props)
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/logging.properties (with props)
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/server.xml (with props)
Modified:
incubator/cxf/trunk/api/src/main/java/org/apache/cxf/headers/Header.java
incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
incubator/cxf/trunk/systests/pom.xml
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/outofband/header/OOBHdrServiceImpl.java
Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/headers/Header.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/headers/Header.java?view=diff&rev=561135&r1=561134&r2=561135
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/headers/Header.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/headers/Header.java Mon Jul 30 14:35:22 2007
@@ -23,11 +23,19 @@
import org.apache.cxf.databinding.DataBinding;
public class Header {
+ public static final int DIRECTION_IN = 0;
+ public static final int DIRECTION_OUT = 1;
+ public static final int DIRECTION_INOUT = 2;
public static final String HEADER_LIST = Header.class.getName() + ".list";
+
private DataBinding dataBinding;
private QName name;
private Object object;
+// private boolean inbound;
+ private enum Direction { DIRECTION_IN, DIRECTION_OUT, DIRECTION_INOUT }
+
+ private Direction direction = Header.Direction.DIRECTION_OUT;
public Header(QName q, Object o) {
this(q, o, null);
@@ -56,6 +64,36 @@
}
public void setObject(Object object) {
this.object = object;
+ }
+
+ public void setDirection(int hdrDirection) {
+ //this.inbound = true;
+ switch (hdrDirection) {
+ case DIRECTION_IN:
+ this.direction = Header.Direction.DIRECTION_IN;
+ break;
+ case DIRECTION_INOUT:
+ this.direction = Header.Direction.DIRECTION_INOUT;
+ break;
+ default:
+ this.direction = Header.Direction.DIRECTION_OUT;
+ }
+ }
+
+ public int getDirection() {
+ int retval;
+ switch (this.direction) {
+ case DIRECTION_IN:
+ retval = Header.DIRECTION_IN;
+ break;
+ case DIRECTION_INOUT:
+ retval = Header.DIRECTION_INOUT;
+ break;
+ default:
+ retval = Header.DIRECTION_OUT;
+ }
+
+ return retval;
}
}
Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java?view=diff&rev=561135&r1=561134&r2=561135
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java (original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java Mon Jul 30 14:35:22 2007
@@ -50,6 +50,7 @@
import org.apache.cxf.binding.soap.interceptor.SoapActionInInterceptor;
import org.apache.cxf.binding.soap.interceptor.SoapActionOutInterceptor;
import org.apache.cxf.binding.soap.interceptor.SoapHeaderInterceptor;
+import org.apache.cxf.binding.soap.interceptor.SoapHeaderOutFilterInterceptor;
import org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor;
import org.apache.cxf.binding.soap.interceptor.SoapPreProtocolOutInterceptor;
import org.apache.cxf.binding.soap.model.SoapBindingInfo;
@@ -338,6 +339,7 @@
sb.getOutInterceptors().add(new SoapActionOutInterceptor());
sb.getOutInterceptors().add(new AttachmentOutInterceptor());
sb.getOutInterceptors().add(new StaxOutInterceptor());
+ sb.getOutInterceptors().add(new SoapHeaderOutFilterInterceptor());
if (SoapConstants.BINDING_STYLE_RPC.equalsIgnoreCase(bindingStyle)) {
sb.getInInterceptors().add(new RPCInInterceptor());
Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java?view=diff&rev=561135&r1=561134&r2=561135
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java (original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java Mon Jul 30 14:35:22 2007
@@ -163,6 +163,9 @@
shead.setActor(act);
shead.setMustUnderstand(Boolean.valueOf(mu) || "1".equals(mu));
+ //mark header as inbound header.(for distinguishing between the direction to
+ //avoid piggybacking of headers from request->server->response.
+ shead.setDirection(SoapHeader.DIRECTION_IN);
message.getHeaders().add(shead);
}
}
Added: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapHeaderOutFilterInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapHeaderOutFilterInterceptor.java?view=auto&rev=561135
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapHeaderOutFilterInterceptor.java (added)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapHeaderOutFilterInterceptor.java Mon Jul 30 14:35:22 2007
@@ -0,0 +1,48 @@
+/**
+ * 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.binding.soap.interceptor;
+
+import java.util.Iterator;
+
+import org.apache.cxf.binding.soap.SoapMessage;
+import org.apache.cxf.headers.Header;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.phase.Phase;
+
+public class SoapHeaderOutFilterInterceptor extends AbstractSoapInterceptor {
+
+ public SoapHeaderOutFilterInterceptor() {
+ super(Phase.PRE_LOGICAL);
+ }
+
+ public void handleMessage(SoapMessage message) throws Fault {
+ // TODO Auto-generated method stub
+ Iterator<Header> iter = message.getHeaders().iterator();
+
+ while (iter.hasNext()) {
+ Header hdr = (Header) iter.next();
+ //ubhole: Only remove inbound marked headers..
+ if (hdr.getDirection() == Header.DIRECTION_IN) {
+ iter.remove();
+ }
+ }
+ }
+
+}
Propchange: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapHeaderOutFilterInterceptor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapHeaderOutFilterInterceptor.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/cxf/trunk/systests/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/pom.xml?view=diff&rev=561135&r1=561134&r2=561135
==============================================================================
--- incubator/cxf/trunk/systests/pom.xml (original)
+++ incubator/cxf/trunk/systests/pom.xml Mon Jul 30 14:35:22 2007
@@ -285,6 +285,11 @@
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-ws-security</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
<artifactId>cxf-integration-jca</artifactId>
<version>${project.version}</version>
</dependency>
Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/outofband/header/OOBHdrServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/outofband/header/OOBHdrServiceImpl.java?view=diff&rev=561135&r1=561134&r2=561135
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/outofband/header/OOBHdrServiceImpl.java (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/outofband/header/OOBHdrServiceImpl.java Mon Jul 30 14:35:22 2007
@@ -19,7 +19,6 @@
package org.apache.cxf.systest.outofband.header;
-import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -34,6 +33,7 @@
import org.w3c.dom.Node;
import org.apache.cxf.headers.Header;
+import org.apache.cxf.helpers.CastUtils;
import org.apache.cxf.jaxb.JAXBDataBinding;
import org.apache.cxf.outofband.header.ObjectFactory;
import org.apache.cxf.outofband.header.OutofBandHeader;
@@ -79,10 +79,10 @@
new QName(OOBHeaderTest.TEST_HDR_NS, OOBHeaderTest.TEST_HDR_RESPONSE_ELEM),
job,
new JAXBDataBinding(ob.getClass()));
- List<Header> hdrList = new ArrayList<Header>();
- hdrList.add(hdr);
+ List<Header> hdrList = CastUtils.cast((List<?>) ctx.get(Header.HEADER_LIST));
+ hdrList.add((Header) hdr);
//Add headerHolder to requestContext.
- ctx.put(Header.HEADER_LIST, hdrList);
+// ctx.put(Header.HEADER_LIST, hdrList);
//System.out.println("Completed adding list to context");
} catch (Exception ex) {
ex.printStackTrace();
@@ -100,7 +100,7 @@
boolean success = false;
MessageContext ctx = context == null ? null : context.getMessageContext();
if (ctx.containsKey(Header.HEADER_LIST)) {
- List oobHdr = (List) ctx.remove(Header.HEADER_LIST);
+ List oobHdr = (List) ctx.get(Header.HEADER_LIST);
if (oobHdr instanceof List) {
Iterator iter = oobHdr.iterator();
Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/GreeterImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/GreeterImpl.java?view=auto&rev=561135
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/GreeterImpl.java (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/GreeterImpl.java Mon Jul 30 14:35:22 2007
@@ -0,0 +1,38 @@
+/**
+ * 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;
+
+
+@javax.jws.WebService(
+ serviceName = "SOAPServiceWSSecurity",
+ portName = "TimestampSignEncrypt",
+ endpointInterface = "org.apache.hello_world_soap_http.Greeter",
+ targetNamespace = "http://apache.org/hello_world_soap_http",
+ wsdlLocation = "org/apache/cxf/systest/ws/security/hello_world.wsdl"
+)
+public class GreeterImpl
+ extends org.apache.hello_world_soap_http.GreeterImpl {
+
+ public String greetMe(String me) {
+ System.out.println("\n\n*** GreetMe called with: " + me + "***\n\n");
+ return "Hello " + me;
+ }
+
+}
Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/GreeterImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/GreeterImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/KeystorePasswordCallback.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/KeystorePasswordCallback.java?view=auto&rev=561135
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/KeystorePasswordCallback.java (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/KeystorePasswordCallback.java Mon Jul 30 14:35:22 2007
@@ -0,0 +1,68 @@
+/**
+ * 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;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+import org.apache.ws.security.WSPasswordCallback;
+
+/**
+ */
+
+public class KeystorePasswordCallback implements CallbackHandler {
+
+ private Map<String, String> passwords =
+ new HashMap<String, String>();
+
+ public KeystorePasswordCallback() {
+ passwords.put("Alice", "abcd!1234");
+ passwords.put("alice", "abcd!1234");
+ passwords.put("Bob", "abcd!1234");
+ passwords.put("bob", "abcd!1234");
+ }
+
+ /**
+ * It attempts to get the password from the private
+ * alias/passwords map.
+ */
+ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
+ for (int i = 0; i < callbacks.length; i++) {
+ WSPasswordCallback pc = (WSPasswordCallback)callbacks[i];
+
+ String pass = passwords.get(pc.getIdentifer());
+ if (pass != null) {
+ pc.setPassword(pass);
+ return;
+ }
+ }
+ }
+
+ /**
+ * Add an alias/password pair to the callback mechanism.
+ */
+ public void setAliasPassword(String alias, String password) {
+ passwords.put(alias, password);
+ }
+}
Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/KeystorePasswordCallback.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/KeystorePasswordCallback.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/Server.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/Server.java?view=auto&rev=561135
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/Server.java (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/Server.java Mon Jul 30 14:35:22 2007
@@ -0,0 +1,57 @@
+/**
+ * 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;
+
+import javax.xml.ws.Endpoint;
+
+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 {
+
+ protected void run() {
+ SpringBusFactory factory = new SpringBusFactory();
+ Bus bus = factory.createBus(
+ "org/apache/cxf/systest/ws/security/server.xml"
+ );
+ BusFactory.setDefaultBus(bus);
+ setBus(bus);
+ GreeterImpl implementor = new GreeterImpl();
+
+ Endpoint.publish(
+ "http://localhost:9000/SOAPServiceWSSecurity/TimestampSignEncrypt",
+ implementor
+ );
+ }
+
+ 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!");
+ }
+ }
+}
Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/Server.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/Server.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/WSSecurityClientTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/WSSecurityClientTest.java?view=auto&rev=561135
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/WSSecurityClientTest.java (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/WSSecurityClientTest.java Mon Jul 30 14:35:22 2007
@@ -0,0 +1,83 @@
+/**
+ * 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;
+
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.hello_world_soap_http.Greeter;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class WSSecurityClientTest extends AbstractBusClientServerTestBase {
+
+ private static final java.net.URL WSDL_LOC;
+ static {
+ java.net.URL tmp = null;
+ try {
+ tmp = WSSecurityClientTest.class.getClassLoader().getResource(
+ "org/apache/cxf/systest/ws/security/hello_world.wsdl"
+ );
+ } catch (final Exception e) {
+ e.printStackTrace();
+ }
+ WSDL_LOC = tmp;
+ }
+
+ @BeforeClass
+ public static void startServers() throws Exception {
+ assertTrue(
+ "Server failed to launch",
+ // run the server in the same process
+ // set this to false to fork
+ launchServer(Server.class, true)
+ );
+ }
+
+ @Test
+ @Ignore
+ public void testTimestampSignEncrypt() {
+ BusFactory.setDefaultBus(
+ new SpringBusFactory().createBus(
+ "org/apache/cxf/systest/ws/security/client.xml"
+ )
+ );
+ final javax.xml.ws.Service svc = javax.xml.ws.Service.create(
+ WSDL_LOC,
+ new javax.xml.namespace.QName(
+ "http://apache.org/hello_world_soap_http",
+ "SOAPServiceWSSecurity"
+ )
+ );
+ final Greeter greeter = svc.getPort(
+ new javax.xml.namespace.QName(
+ "http://apache.org/hello_world_soap_http",
+ "TimestampSignEncrypt"
+ ),
+ Greeter.class
+ );
+ greeter.sayHi();
+ }
+}
Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/WSSecurityClientTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/WSSecurityClientTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/alice.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/alice.properties?view=auto&rev=561135
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/alice.properties (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/alice.properties Mon Jul 30 14:35:22 2007
@@ -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=password
+org.apache.ws.security.crypto.merlin.keystore.alias=Alice
+org.apache.ws.security.crypto.merlin.file=src/test/java/org/apache/cxf/systest/ws/security/alice.jks
Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/alice.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/alice.properties
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/alice.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/bob.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/bob.properties?view=auto&rev=561135
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/bob.properties (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/bob.properties Mon Jul 30 14:35:22 2007
@@ -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=password
+org.apache.ws.security.crypto.merlin.keystore.alias=Bob
+org.apache.ws.security.crypto.merlin.file=src/test/java/org/apache/cxf/systest/ws/security/bob.jks
Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/bob.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/bob.properties
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/bob.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/client.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/client.xml?view=auto&rev=561135
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/client.xml (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/client.xml Mon Jul 30 14:35:22 2007
@@ -0,0 +1,89 @@
+<?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:jaxws="http://cxf.apache.org/jaxws"
+ xsi:schemaLocation="
+ 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
+ ">
+
+ <jaxws:client name="{http://apache.org/hello_world_soap_http}TimestampSignEncrypt" createdFromAPI="true">
+ <jaxws:features>
+ <bean class="org.apache.cxf.feature.LoggingFeature"/>
+ </jaxws:features>
+ <jaxws:outInterceptors>
+ <bean class="org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor"/>
+ <ref bean="TimestampSignEncrypt_Request"/>
+ </jaxws:outInterceptors>
+ <jaxws:inInterceptors>
+ <ref bean="TimestampSignEncrypt_Response"/>
+ <bean class="org.apache.cxf.binding.soap.saaj.SAAJInInterceptor"/>
+ </jaxws:inInterceptors>
+ </jaxws:client>
+
+ <!-- -->
+ <!-- This bean is an Out interceptor which will add a Timestamp, -->
+ <!-- sign the Timstamp and Body, and then encrypt the Timestamp -->
+ <!-- and Body. It uses 3DES as the symmetric key algorithm. -->
+ <!-- -->
+ <bean
+ class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor"
+ id="TimestampSignEncrypt_Request">
+ <constructor-arg>
+ <map>
+ <entry key="action" value="Timestamp Signature Encrypt"/>
+ <!-- <entry key="action" value="Timestamp Signature"/> -->
+ <entry key="user" value="Alice"/>
+ <entry key="signaturePropFile" value="org/apache/cxf/systest/ws/security/alice.properties"/>
+ <entry key="encryptionPropFile" value="org/apache/cxf/systest/ws/security/bob.properties"/>
+ <entry key="encryptionUser" value="Bob"/>
+ <entry key="signatureKeyIdentifier" value="DirectReference"/>
+ <entry key="passwordCallbackClass" value="org.apache.cxf.systest.ws.security.KeystorePasswordCallback"/>
+ <entry key="signatureParts" value="{Element}{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd}Timestamp;{Element}{http://schemas.xmlsoap.org/soap/envelope/}Body"/>
+ <!-- -->
+ <!-- Recommendation: signatures should be encrypted -->
+ <!-- -->
+ <entry key="encryptionParts" value="{Element}{http://www.w3.org/2000/09/xmldsig#}Signature;{Content}{http://schemas.xmlsoap.org/soap/envelope/}Body"/>
+ <!-- <entry key="encryptionKeyTransportAlgorithm" value="RSA15"/> -->
+ <entry key="encryptionSymAlgorithm" value="http://www.w3.org/2001/04/xmlenc#tripledes-cbc"/>
+ </map>
+ </constructor-arg>
+ </bean>
+
+ <!-- -->
+ <!-- This bean is an In interceptor which validated a signed, -->
+ <!-- encrypted resposne, and timestamped. -->
+ <!-- -->
+ <!-- -->
+ <bean
+ class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor"
+ id="TimestampSignEncrypt_Response">
+ <constructor-arg>
+ <map>
+ <entry key="action" value="Signature Encrypt Timestamp"/>
+ <entry key="signaturePropFile" value="org/apache/cxf/systest/ws/security/bob.properties"/>
+ <entry key="decryptionPropFile" value="org/apache/cxf/systest/ws/security/alice.properties"/>
+ <entry key="passwordCallbackClass" value="org.apache.cxf.systest.ws.security.KeystorePasswordCallback"/>
+ </map>
+ </constructor-arg>
+ </bean>
+
+</beans>
Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/client.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/client.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/client.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/hello_world.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/hello_world.wsdl?view=auto&rev=561135
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/hello_world.wsdl (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/hello_world.wsdl Mon Jul 30 14:35:22 2007
@@ -0,0 +1,43 @@
+<?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.
+-->
+<wsdl:definitions
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://apache.org/hello_world_soap_http"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ targetNamespace="http://apache.org/hello_world_soap_http"
+ name="WSSecurity"
+ >
+
+ <wsdl:import
+ namespace="http://apache.org/hello_world_soap_http"
+ location="wsdl/hello_world.wsdl"
+ />
+
+ <wsdl:service name="SOAPServiceWSSecurity">
+ <wsdl:port
+ name="TimestampSignEncrypt"
+ binding="tns:Greeter_SOAPBinding">
+ <soap:address location="http://localhost:9000/SOAPServiceWSSecurity/TimestampSignEncrypt"/>
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
+
Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/hello_world.wsdl
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/hello_world.wsdl
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/hello_world.wsdl
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/logging.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/logging.properties?view=auto&rev=561135
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/logging.properties (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/logging.properties Mon Jul 30 14:35:22 2007
@@ -0,0 +1,78 @@
+#
+# Copyright (c) 1993-2007 IONA Technologies PLC.
+# All Rights Reserved.
+#
+
+# 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.
+
+############################################################
+# Default Logging Configuration File
+#
+# You can use a different file by specifying a filename
+# with the java.util.logging.config.file system property.
+# For example java -Djava.util.logging.config.file=myfile
+############################################################
+
+############################################################
+# Global properties
+############################################################
+
+# "handlers" specifies a comma separated list of log Handler
+# classes. These handlers will be installed during VM startup.
+# Note that these classes must be on the system classpath.
+# By default we only configure a ConsoleHandler, which will only
+# show messages at the WARNING and above levels.
+handlers= java.util.logging.ConsoleHandler
+
+# To also add the FileHandler, use the following line instead.
+#handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler
+
+# Default global logging level.
+# This specifies which kinds of events are logged across
+# all loggers. For any given facility this global level
+# can be overriden by a facility specific level
+# Note that the ConsoleHandler also has a separate level
+# setting to limit messages printed to the console.
+.level= FINEST
+
+############################################################
+# Handler specific properties.
+# Describes specific configuration info for Handlers.
+############################################################
+
+# default file output is in user's home directory.
+java.util.logging.FileHandler.pattern = %h/java%u.log
+java.util.logging.FileHandler.limit = 50000
+java.util.logging.FileHandler.count = 1
+java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter
+
+# Limit the message that are printed on the console to INFO and above.
+# java.util.logging.ConsoleHandler.level = INFO
+java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
+
+
+############################################################
+# Facility specific properties.
+# Provides extra control for each logger.
+############################################################
+
+# For example, set the com.xyz.foo logger to only log SEVERE
+# messages:
+# com.xyz.foo.level = SEVERE
+# com.iona.cxf.security.level=INFO
+org.apache.cxf.level=FINEST
Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/logging.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/logging.properties
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/logging.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/server.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/server.xml?view=auto&rev=561135
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/server.xml (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/server.xml Mon Jul 30 14:35:22 2007
@@ -0,0 +1,81 @@
+<?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:jaxws="http://cxf.apache.org/jaxws"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+ ">
+
+ <jaxws:endpoint name="{http://apache.org/hello_world_soap_http}TimestampSignEncrypt" createdFromAPI="true">
+ <jaxws:features>
+ <bean class="org.apache.cxf.feature.LoggingFeature"/>
+ </jaxws:features>
+ <jaxws:outInterceptors>
+ <bean class="org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor"/>
+ <ref bean="TimestampSignEncrypt_Response"/>
+ </jaxws:outInterceptors>
+ <jaxws:inInterceptors>
+ <ref bean="TimestampSignEncrypt_Request"/>
+ <bean class="org.apache.cxf.binding.soap.saaj.SAAJInInterceptor"/>
+ </jaxws:inInterceptors>
+ </jaxws:endpoint>
+
+ <bean
+ class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor"
+ id="TimestampSignEncrypt_Response">
+ <constructor-arg>
+ <map>
+ <entry key="action" value="Signature Encrypt"/>
+ <entry key="user" value="Bob"/>
+ <entry key="signaturePropFile" value="org/apache/cxf/systest/ws/security/bob.properties"/>
+ <entry key="encryptionPropFile" value="org/apache/cxf/systest/ws/security/alice.properties"/>
+ <entry key="encryptionUser" value="Alice"/>
+ <entry key="signatureKeyIdentifier" value="DirectReference"/>
+ <entry key="passwordCallbackClass" value="org.apache.cxf.systest.ws.security.KeystorePasswordCallback"/>
+ <entry key="signatureParts" value="{Element}{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd}Timestamp;{Element}{http://schemas.xmlsoap.org/soap/envelope/}Body"/>
+ <!-- -->
+ <!-- Recommendation: signatures should be encrypted -->
+ <!-- -->
+ <entry key="encryptionParts" value="{Element}{http://www.w3.org/2000/09/xmldsig#}Signature;{Content}{http://schemas.xmlsoap.org/soap/envelope/}Body"/>
+ <!-- <entry key="encryptionKeyTransportAlgorithm" value="RSA15"/> -->
+ <entry key="encryptionSymAlgorithm" value="http://www.w3.org/2001/04/xmlenc#tripledes-cbc"/>
+ </map>
+ </constructor-arg>
+ </bean>
+ <bean
+ class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor"
+ id="TimestampSignEncrypt_Request">
+ <constructor-arg>
+ <map>
+ <!-- Use this action order for local clients -->
+ <entry key="action" value="Timestamp Signature Encrypt"/>
+ <!-- Use this action spec for WCF clients
+ <entry key="action" value="Signature Encrypt Timestamp"/>
+ -->
+ <entry key="signaturePropFile" value="org/apache/cxf/systest/ws/security/alice.properties"/>
+ <entry key="decryptionPropFile" value="org/apache/cxf/systest/ws/security/bob.properties"/>
+ <entry key="passwordCallbackClass" value="org.apache.cxf.systest.ws.security.KeystorePasswordCallback"/>
+ </map>
+ </constructor-arg>
+ </bean>
+
+</beans>
Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/server.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/server.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/server.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Re: svn commit: r561135 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/headers/ rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/ rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ systests/ systests/src/test/jav...
Posted by Daniel Kulp <dk...@apache.org>.
Glen,
Hmm... just realized I spelled your name wrong in my commit. I
apologize for that.
On Monday 30 July 2007 20:12, Glen Mazza wrote:
> Can we make the Direction enum above public, so it can be used
> externally--that way, we would not need to define DIRECTION_IN, _OUT,
> _INOUT static integers at the top? (Or is it that the callee can not
> work with enums--if so, can we just work with the static ints then?)
> Having both enum constants and static integers with the same name is a
> little bit confusing, if we could just work with one of the two I
> think that would be better.
Agreed. I just took care of that.
> > + public void handleMessage(SoapMessage message) throws Fault {
> > + // TODO Auto-generated method stub
> > + Iterator<Header> iter = message.getHeaders().iterator();
>
> (I don't know the code here. Is there any chance the iterator above
> could be null -- i.e., if there are no headers? If so, the above line
> of code will NPE.)
No. SoapMessage.getHeaders() creates a new list if one isn't yet
present.
> > + public KeystorePasswordCallback() {
> > + passwords.put("Alice", "abcd!1234");
> > + passwords.put("alice", "abcd!1234");
> > + passwords.put("Bob", "abcd!1234");
> > + passwords.put("bob", "abcd!1234");
> > + }
> > +
>
> What is the point of adding both Alice and alice here? Bob and bob?
> If you're trying to make user entry case-insensitive (not really
> necessary IMHO), I don't think that will work, because people could
> still enter "BOB", "bOB", etc., and the above would fail anyway.
I'll let Ulhas or Fred comment on this. I have no idea.
> > + 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!");
> > + }
> > + }
>
> I think this needs fixing. The purpose of the finally is "run this
> code whether or not there was an exception", but that is circumvented
> with the System.exit(-1) in the catch {} block. I think either the
> System.exit(-1) line has to be removed, or the finally block removed,
> with its single statement placed at the end of the try{} block.
Hmm... very good point. That said, I think a TON of our system tests
probably have the same problem. I'm willing to bet this is a copy/paste
from one of the others. :-( I suppose I could argue that there are
throwables that aren't exceptions that could invoke the finally (like
OutOfMemoryErrors and the like), but I'd really just be stretching for
an excuse.
--
J. Daniel Kulp
Principal Engineer
IONA
P: 781-902-8727 C: 508-380-7194
daniel.kulp@iona.com
http://www.dankulp.com/blog
Re: svn commit: r561135 - in /incubator/cxf/trunk:
api/src/main/java/org/apache/cxf/headers/
rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/
rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/
systests/ systests/src/test/jav...
Posted by Glen Mazza <gl...@verizon.net>.
Am Montag, den 30.07.2007, 21:35 +0000 schrieb ulhasbhole@apache.org:
> Author: ulhasbhole
> Date: Mon Jul 30 14:35:22 2007
> New Revision: 561135
> ==============================================================================
> --- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/headers/Header.java (original)
> +++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/headers/Header.java Mon Jul 30 14:35:22 2007
> @@ -23,11 +23,19 @@
> import org.apache.cxf.databinding.DataBinding;
>
> public class Header {
> + public static final int DIRECTION_IN = 0;
> + public static final int DIRECTION_OUT = 1;
> + public static final int DIRECTION_INOUT = 2;
Hmmm...see below...
> public static final String HEADER_LIST = Header.class.getName() + ".list";
> +
>
> private DataBinding dataBinding;
> private QName name;
> private Object object;
> +// private boolean inbound;
> + private enum Direction { DIRECTION_IN, DIRECTION_OUT, DIRECTION_INOUT }
> +
Can we make the Direction enum above public, so it can be used
externally--that way, we would not need to define DIRECTION_IN, _OUT,
_INOUT static integers at the top? (Or is it that the callee can not
work with enums--if so, can we just work with the static ints then?)
Having both enum constants and static integers with the same name is a
little bit confusing, if we could just work with one of the two I think
that would be better.
> + private Direction direction = Header.Direction.DIRECTION_OUT;
>
> public Header(QName q, Object o) {
> this(q, o, null);
> @@ -56,6 +64,36 @@
> }
> public void setObject(Object object) {
> this.object = object;
> + }
> +
> + public void setDirection(int hdrDirection) {
> + //this.inbound = true;
> + switch (hdrDirection) {
> + case DIRECTION_IN:
> + this.direction = Header.Direction.DIRECTION_IN;
> + break;
> + case DIRECTION_INOUT:
> + this.direction = Header.Direction.DIRECTION_INOUT;
> + break;
> + default:
> + this.direction = Header.Direction.DIRECTION_OUT;
> + }
> + }
> +
> + public int getDirection() {
> + int retval;
> + switch (this.direction) {
> + case DIRECTION_IN:
> + retval = Header.DIRECTION_IN;
> + break;
> + case DIRECTION_INOUT:
> + retval = Header.DIRECTION_INOUT;
> + break;
> + default:
> + retval = Header.DIRECTION_OUT;
> + }
> +
> + return retval;
> }
These two methods above can get quite simple if we can collapse the
enums and static ints into one set.
> Added: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapHeaderOutFilterInterceptor.java
> URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapHeaderOutFilterInterceptor.java?view=auto&rev=561135
> ==============================================================================
> --- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapHeaderOutFilterInterceptor.java (added)
> +++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapHeaderOutFilterInterceptor.java Mon Jul 30 14:35:22 2007
> @@ -0,0 +1,48 @@
> +/**
> + * 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.binding.soap.interceptor;
> +
> +import java.util.Iterator;
> +
> +import org.apache.cxf.binding.soap.SoapMessage;
> +import org.apache.cxf.headers.Header;
> +import org.apache.cxf.interceptor.Fault;
> +import org.apache.cxf.phase.Phase;
> +
> +public class SoapHeaderOutFilterInterceptor extends AbstractSoapInterceptor {
> +
> + public SoapHeaderOutFilterInterceptor() {
> + super(Phase.PRE_LOGICAL);
> + }
> +
> + public void handleMessage(SoapMessage message) throws Fault {
> + // TODO Auto-generated method stub
> + Iterator<Header> iter = message.getHeaders().iterator();
(I don't know the code here. Is there any chance the iterator above
could be null -- i.e., if there are no headers? If so, the above line
of code will NPE.)
> +
> + while (iter.hasNext()) {
> + Header hdr = (Header) iter.next();
> + //ubhole: Only remove inbound marked headers..
> + if (hdr.getDirection() == Header.DIRECTION_IN) {
> + iter.remove();
> + }
> + }
> + }
> +
> +}
>
> Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/KeystorePasswordCallback.java
> URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/KeystorePasswordCallback.java?view=auto&rev=561135
> ==============================================================================
> --- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/KeystorePasswordCallback.java (added)
> +++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/KeystorePasswordCallback.java Mon Jul 30 14:35:22 2007
> @@ -0,0 +1,68 @@
> +/**
> + * 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;
> +
> +import java.io.IOException;
> +import java.util.HashMap;
> +import java.util.Map;
> +
> +import javax.security.auth.callback.Callback;
> +import javax.security.auth.callback.CallbackHandler;
> +import javax.security.auth.callback.UnsupportedCallbackException;
> +
> +import org.apache.ws.security.WSPasswordCallback;
> +
> +/**
> + */
> +
> +public class KeystorePasswordCallback implements CallbackHandler {
> +
> + private Map<String, String> passwords =
> + new HashMap<String, String>();
> +
> + public KeystorePasswordCallback() {
> + passwords.put("Alice", "abcd!1234");
> + passwords.put("alice", "abcd!1234");
> + passwords.put("Bob", "abcd!1234");
> + passwords.put("bob", "abcd!1234");
> + }
> +
What is the point of adding both Alice and alice here? Bob and bob? If
you're trying to make user entry case-insensitive (not really necessary
IMHO), I don't think that will work, because people could still enter
"BOB", "bOB", etc., and the above would fail anyway.
> + /**
> + * It attempts to get the password from the private
> + * alias/passwords map.
> + */
> + public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
> + for (int i = 0; i < callbacks.length; i++) {
> + WSPasswordCallback pc = (WSPasswordCallback)callbacks[i];
> +
> + String pass = passwords.get(pc.getIdentifer());
> + if (pass != null) {
> + pc.setPassword(pass);
> + return;
> + }
> + }
> + }
> +
> + /**
> + * Add an alias/password pair to the callback mechanism.
> + */
> + public void setAliasPassword(String alias, String password) {
> + passwords.put(alias, password);
> + }
> +}
>
> Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/Server.java
> URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/Server.java?view=auto&rev=561135
> ==============================================================================
> --- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/Server.java (added)
> +++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/Server.java Mon Jul 30 14:35:22 2007
> @@ -0,0 +1,57 @@
> +/**
> + * 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;
> +
> +import javax.xml.ws.Endpoint;
> +
> +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 {
> +
> + protected void run() {
> + SpringBusFactory factory = new SpringBusFactory();
> + Bus bus = factory.createBus(
> + "org/apache/cxf/systest/ws/security/server.xml"
> + );
> + BusFactory.setDefaultBus(bus);
> + setBus(bus);
> + GreeterImpl implementor = new GreeterImpl();
> +
> + Endpoint.publish(
> + "http://localhost:9000/SOAPServiceWSSecurity/TimestampSignEncrypt",
> + implementor
> + );
> + }
> +
> + 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!");
> + }
> + }
I think this needs fixing. The purpose of the finally is "run this code
whether or not there was an exception", but that is circumvented with
the System.exit(-1) in the catch {} block. I think either the
System.exit(-1) line has to be removed, or the finally block removed,
with its single statement placed at the end of the try{} block.
Regards,
Glen