cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1466447 - in /cxf/branches/wss4j2.0-port/rt/ws/security/src: main/java/org/apache/cxf/ws/security/wss4j/ test/java/org/apache/cxf/ws/security/wss4j/
Date Wed, 10 Apr 2013 12:36:57 GMT
Author: coheigea
Date: Wed Apr 10 12:36:57 2013
New Revision: 1466447

URL: http://svn.apache.org/r1466447
Log:
Added an InInterceptor for StaX WS-Security + lots of tests

Added:
    cxf/branches/wss4j2.0-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JStaxInInterceptor.java
    cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/DOMToStaxEncryptionIdentifierTest.java
    cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/DOMToStaxRoundTripTest.java
    cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/DOMToStaxSignatureIdentifierTest.java
Modified:
    cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/StaxRoundTripTest.java
    cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/StaxToDOMEncryptionIdentifierTest.java

Added: cxf/branches/wss4j2.0-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JStaxInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/wss4j2.0-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JStaxInInterceptor.java?rev=1466447&view=auto
==============================================================================
--- cxf/branches/wss4j2.0-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JStaxInInterceptor.java (added)
+++ cxf/branches/wss4j2.0-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JStaxInInterceptor.java Wed Apr 10 12:36:57 2013
@@ -0,0 +1,87 @@
+/**
+ * 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.ws.security.wss4j;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.cxf.binding.soap.SoapFault;
+import org.apache.cxf.binding.soap.SoapMessage;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.interceptor.StaxInInterceptor;
+import org.apache.cxf.phase.Phase;
+import org.apache.wss4j.common.ext.WSSecurityException;
+import org.apache.wss4j.stax.WSSec;
+import org.apache.wss4j.stax.ext.InboundWSSec;
+import org.apache.wss4j.stax.ext.WSSSecurityProperties;
+import org.apache.xml.security.stax.securityEvent.SecurityEvent;
+import org.apache.xml.security.stax.securityEvent.SecurityEventListener;
+
+public class WSS4JStaxInInterceptor extends AbstractWSS4JStaxInterceptor {
+    
+    private final InboundWSSec inboundWSSec;
+    
+    public WSS4JStaxInInterceptor(WSSSecurityProperties securityProperties) throws WSSecurityException {
+        super();
+        setPhase(Phase.POST_STREAM);
+        getAfter().add(StaxInInterceptor.class.getName());
+        
+        inboundWSSec = WSSec.getInboundWSSec(securityProperties);
+    }
+
+    @Override
+    public void handleMessage(SoapMessage soapMessage) throws Fault {
+
+        XMLStreamReader originalXmlStreamReader = soapMessage.getContent(XMLStreamReader.class);
+        XMLStreamReader newXmlStreamReader;
+
+        final List<SecurityEvent> incomingSecurityEventList = new LinkedList<SecurityEvent>();
+        SecurityEventListener securityEventListener = new SecurityEventListener() {
+            @Override
+            public void registerSecurityEvent(SecurityEvent securityEvent) throws WSSecurityException {
+                incomingSecurityEventList.add(securityEvent);
+            }
+        };
+        soapMessage.getExchange().put(SecurityEvent.class.getName() + ".in", incomingSecurityEventList);
+
+        try {
+            @SuppressWarnings("unchecked")
+            final List<SecurityEvent> requestSecurityEvents = 
+                (List<SecurityEvent>) soapMessage.getExchange().get(SecurityEvent.class.getName() + ".out");
+            newXmlStreamReader = 
+                inboundWSSec.processInMessage(originalXmlStreamReader, requestSecurityEvents, securityEventListener);
+            soapMessage.setContent(XMLStreamReader.class, newXmlStreamReader);
+
+            // Warning: The exceptions which can occur here are not security relevant exceptions
+            // but configuration-errors. To catch security relevant exceptions you have to catch 
+            // them e.g.in the FaultOutInterceptor. Why? Because we do streaming security. This 
+            // interceptor doesn't handle the ws-security stuff but just setup the relevant stuff
+            // for it. Exceptions will be thrown as a wrapped XMLStreamException during further
+            // processing in the WS-Stack.
+
+        } catch (WSSecurityException e) {
+            throw new SoapFault("unexpected service error", SoapFault.FAULT_CODE_SERVER);
+        } catch (XMLStreamException e) {
+            throw new SoapFault("unexpected service error", SoapFault.FAULT_CODE_SERVER);
+        }
+    }
+}

Added: cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/DOMToStaxEncryptionIdentifierTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/DOMToStaxEncryptionIdentifierTest.java?rev=1466447&view=auto
==============================================================================
--- cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/DOMToStaxEncryptionIdentifierTest.java (added)
+++ cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/DOMToStaxEncryptionIdentifierTest.java Wed Apr 10 12:36:57 2013
@@ -0,0 +1,234 @@
+/**
+ * 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.ws.security.wss4j;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.frontend.ClientProxy;
+import org.apache.cxf.interceptor.LoggingInInterceptor;
+import org.apache.cxf.interceptor.LoggingOutInterceptor;
+import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.transport.local.LocalTransportFactory;
+import org.apache.wss4j.common.crypto.CryptoFactory;
+import org.apache.wss4j.dom.handler.WSHandlerConstants;
+import org.apache.wss4j.stax.ext.WSSSecurityProperties;
+import org.junit.Test;
+
+
+/**
+ * In these test-cases, the client is using DOM and the service is using StaX. The tests are
+ * for different Encryption Key Identifier methods.
+ */
+public class DOMToStaxEncryptionIdentifierTest extends AbstractSecurityTest {
+    
+    @Test
+    public void testEncryptDirectReference() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        WSSSecurityProperties inProperties = new WSSSecurityProperties();
+        inProperties.setCallbackHandler(new TestPwdCallback());
+        Properties cryptoProperties = 
+            CryptoFactory.getProperties("insecurity.properties", this.getClass().getClassLoader());
+        inProperties.setDecryptionCryptoProperties(cryptoProperties);
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inProperties);
+        service.getInInterceptors().add(inhandler);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> properties = new HashMap<String, Object>();
+        properties.put(WSHandlerConstants.ACTION, WSHandlerConstants.ENCRYPT);
+        properties.put(WSHandlerConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        properties.put(WSHandlerConstants.ENC_PROP_FILE, "outsecurity.properties");
+        properties.put(WSHandlerConstants.USER, "myalias");
+        properties.put(WSHandlerConstants.ENC_KEY_ID, "DirectReference");
+        
+        WSS4JOutInterceptor ohandler = new WSS4JOutInterceptor(properties);
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    @Test
+    public void testEncryptIssuerSerial() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        WSSSecurityProperties inProperties = new WSSSecurityProperties();
+        inProperties.setCallbackHandler(new TestPwdCallback());
+        Properties cryptoProperties = 
+            CryptoFactory.getProperties("insecurity.properties", this.getClass().getClassLoader());
+        inProperties.setDecryptionCryptoProperties(cryptoProperties);
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inProperties);
+        service.getInInterceptors().add(inhandler);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> properties = new HashMap<String, Object>();
+        properties.put(WSHandlerConstants.ACTION, WSHandlerConstants.ENCRYPT);
+        properties.put(WSHandlerConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        properties.put(WSHandlerConstants.ENC_PROP_FILE, "outsecurity.properties");
+        properties.put(WSHandlerConstants.USER, "myalias");
+        properties.put(WSHandlerConstants.ENC_KEY_ID, "IssuerSerial");
+        
+        WSS4JOutInterceptor ohandler = new WSS4JOutInterceptor(properties);
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    @Test
+    public void testEncryptThumbprint() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        WSSSecurityProperties inProperties = new WSSSecurityProperties();
+        inProperties.setCallbackHandler(new TestPwdCallback());
+        Properties cryptoProperties = 
+            CryptoFactory.getProperties("insecurity.properties", this.getClass().getClassLoader());
+        inProperties.setDecryptionCryptoProperties(cryptoProperties);
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inProperties);
+        service.getInInterceptors().add(inhandler);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> properties = new HashMap<String, Object>();
+        properties.put(WSHandlerConstants.ACTION, WSHandlerConstants.ENCRYPT);
+        properties.put(WSHandlerConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        properties.put(WSHandlerConstants.ENC_PROP_FILE, "outsecurity.properties");
+        properties.put(WSHandlerConstants.USER, "myalias");
+        properties.put(WSHandlerConstants.ENC_KEY_ID, "Thumbprint");
+        
+        WSS4JOutInterceptor ohandler = new WSS4JOutInterceptor(properties);
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    @Test
+    public void testEncryptX509() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        WSSSecurityProperties inProperties = new WSSSecurityProperties();
+        inProperties.setCallbackHandler(new TestPwdCallback());
+        Properties cryptoProperties = 
+            CryptoFactory.getProperties("insecurity.properties", this.getClass().getClassLoader());
+        inProperties.setDecryptionCryptoProperties(cryptoProperties);
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inProperties);
+        service.getInInterceptors().add(inhandler);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> properties = new HashMap<String, Object>();
+        properties.put(WSHandlerConstants.ACTION, WSHandlerConstants.ENCRYPT);
+        properties.put(WSHandlerConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        properties.put(WSHandlerConstants.ENC_PROP_FILE, "outsecurity.properties");
+        properties.put(WSHandlerConstants.USER, "myalias");
+        properties.put(WSHandlerConstants.ENC_KEY_ID, "X509KeyIdentifier");
+        
+        WSS4JOutInterceptor ohandler = new WSS4JOutInterceptor(properties);
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    @Test
+    public void testEncryptEncryptedKeySHA1() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        WSSSecurityProperties inProperties = new WSSSecurityProperties();
+        inProperties.setCallbackHandler(new TestPwdCallback());
+        Properties cryptoProperties = 
+            CryptoFactory.getProperties("insecurity.properties", this.getClass().getClassLoader());
+        inProperties.setDecryptionCryptoProperties(cryptoProperties);
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inProperties);
+        service.getInInterceptors().add(inhandler);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> properties = new HashMap<String, Object>();
+        properties.put(WSHandlerConstants.ACTION, WSHandlerConstants.ENCRYPT);
+        properties.put(WSHandlerConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        properties.put(WSHandlerConstants.ENC_PROP_FILE, "outsecurity.properties");
+        properties.put(WSHandlerConstants.USER, "myalias");
+        properties.put(WSHandlerConstants.ENC_KEY_ID, "EncryptedKeySHA1");
+        
+        WSS4JOutInterceptor ohandler = new WSS4JOutInterceptor(properties);
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    private Service createService() {
+        // Create the Service
+        JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
+        factory.setServiceBean(new EchoImpl());
+        factory.setAddress("local://Echo");
+        factory.setTransportId(LocalTransportFactory.TRANSPORT_ID);
+        Server server = factory.create();
+        
+        Service service = server.getEndpoint().getService();
+        service.getInInterceptors().add(new LoggingInInterceptor());
+        service.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        return service;
+    }
+    
+    private Echo createClientProxy() {
+        JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean();
+        proxyFac.setServiceClass(Echo.class);
+        proxyFac.setAddress("local://Echo");
+        proxyFac.getClientFactoryBean().setTransportId(LocalTransportFactory.TRANSPORT_ID);
+        
+        return (Echo)proxyFac.create();
+    }
+}

Added: cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/DOMToStaxRoundTripTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/DOMToStaxRoundTripTest.java?rev=1466447&view=auto
==============================================================================
--- cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/DOMToStaxRoundTripTest.java (added)
+++ cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/DOMToStaxRoundTripTest.java Wed Apr 10 12:36:57 2013
@@ -0,0 +1,364 @@
+/**
+ * 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.ws.security.wss4j;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.frontend.ClientProxy;
+import org.apache.cxf.interceptor.LoggingInInterceptor;
+import org.apache.cxf.interceptor.LoggingOutInterceptor;
+import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.transport.local.LocalTransportFactory;
+import org.apache.wss4j.common.crypto.CryptoFactory;
+import org.apache.wss4j.dom.WSConstants;
+import org.apache.wss4j.dom.handler.WSHandlerConstants;
+import org.apache.wss4j.stax.ext.WSSConstants;
+import org.apache.wss4j.stax.ext.WSSSecurityProperties;
+import org.junit.Test;
+
+
+/**
+ * In these test-cases, the client is using DOM and the service is using StaX.
+ */
+public class DOMToStaxRoundTripTest extends AbstractSecurityTest {
+    
+    @Test
+    public void testUsernameTokenText() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        WSSSecurityProperties inProperties = new WSSSecurityProperties();
+        inProperties.setCallbackHandler(new TestPwdCallback());
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inProperties);
+        service.getInInterceptors().add(inhandler);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> properties = new HashMap<String, Object>();
+        properties.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
+        properties.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
+        properties.put(WSHandlerConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        properties.put(WSHandlerConstants.USER, "username");
+        
+        WSS4JOutInterceptor ohandler = new WSS4JOutInterceptor(properties);
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    @Test
+    public void testUsernameTokenDigest() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        WSSSecurityProperties inProperties = new WSSSecurityProperties();
+        inProperties.setCallbackHandler(new TestPwdCallback());
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inProperties);
+        service.getInInterceptors().add(inhandler);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> properties = new HashMap<String, Object>();
+        properties.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
+        properties.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_DIGEST);
+        properties.put(WSHandlerConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        properties.put(WSHandlerConstants.USER, "username");
+        
+        WSS4JOutInterceptor ohandler = new WSS4JOutInterceptor(properties);
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    @Test
+    public void testEncrypt() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        WSSSecurityProperties inProperties = new WSSSecurityProperties();
+        inProperties.setCallbackHandler(new TestPwdCallback());
+        Properties cryptoProperties = 
+            CryptoFactory.getProperties("insecurity.properties", this.getClass().getClassLoader());
+        inProperties.setDecryptionCryptoProperties(cryptoProperties);
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inProperties);
+        service.getInInterceptors().add(inhandler);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> properties = new HashMap<String, Object>();
+        properties.put(WSHandlerConstants.ACTION, WSHandlerConstants.ENCRYPT);
+        properties.put(WSHandlerConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        properties.put(WSHandlerConstants.ENC_PROP_FILE, "outsecurity.properties");
+        properties.put(WSHandlerConstants.USER, "myalias");
+        
+        WSS4JOutInterceptor ohandler = new WSS4JOutInterceptor(properties);
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    @Test
+    public void testEncryptUsernameToken() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        WSSSecurityProperties inProperties = new WSSSecurityProperties();
+        inProperties.setCallbackHandler(new TestPwdCallback());
+        Properties cryptoProperties = 
+            CryptoFactory.getProperties("insecurity.properties", this.getClass().getClassLoader());
+        inProperties.setDecryptionCryptoProperties(cryptoProperties);
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inProperties);
+        service.getInInterceptors().add(inhandler);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> properties = new HashMap<String, Object>();
+        properties.put(
+            WSHandlerConstants.ACTION, 
+            WSHandlerConstants.USERNAME_TOKEN + " " + WSHandlerConstants.ENCRYPT
+        );
+        properties.put(WSHandlerConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        properties.put(WSHandlerConstants.ENC_PROP_FILE, "outsecurity.properties");
+        properties.put(WSHandlerConstants.USER, "username");
+        properties.put(WSHandlerConstants.ENCRYPTION_USER, "myalias");
+        
+        WSS4JOutInterceptor ohandler = new WSS4JOutInterceptor(properties);
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    @Test
+    public void testSignature() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        WSSSecurityProperties inProperties = new WSSSecurityProperties();
+        inProperties.setCallbackHandler(new TestPwdCallback());
+        Properties cryptoProperties = 
+            CryptoFactory.getProperties("insecurity.properties", this.getClass().getClassLoader());
+        inProperties.setSignatureVerificationCryptoProperties(cryptoProperties);
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inProperties);
+        service.getInInterceptors().add(inhandler);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> properties = new HashMap<String, Object>();
+        properties.put(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE);
+        properties.put(WSHandlerConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        properties.put(WSHandlerConstants.SIG_PROP_FILE, "outsecurity.properties");
+        properties.put(WSHandlerConstants.USER, "myalias");
+        
+        WSS4JOutInterceptor ohandler = new WSS4JOutInterceptor(properties);
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    @Test
+    public void testTimestamp() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        WSSSecurityProperties inProperties = new WSSSecurityProperties();
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inProperties);
+        service.getInInterceptors().add(inhandler);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> properties = new HashMap<String, Object>();
+        properties.put(WSHandlerConstants.ACTION, WSHandlerConstants.TIMESTAMP);
+
+        WSS4JOutInterceptor ohandler = new WSS4JOutInterceptor(properties);
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    @Test
+    public void testSignatureTimestamp() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        WSSSecurityProperties inProperties = new WSSSecurityProperties();
+        inProperties.setCallbackHandler(new TestPwdCallback());
+        Properties cryptoProperties = 
+            CryptoFactory.getProperties("insecurity.properties", this.getClass().getClassLoader());
+        inProperties.setSignatureVerificationCryptoProperties(cryptoProperties);
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inProperties);
+        service.getInInterceptors().add(inhandler);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> properties = new HashMap<String, Object>();
+        properties.put(
+            WSHandlerConstants.ACTION, 
+            WSHandlerConstants.TIMESTAMP + " " + WSHandlerConstants.SIGNATURE
+        );
+        properties.put(
+            WSHandlerConstants.SIGNATURE_PARTS, 
+            "{}{" + WSSConstants.NS_WSU10 + "}Timestamp;"
+            + "{}{" + WSSConstants.NS_SOAP11 + "}Body;"
+        );
+        properties.put(WSHandlerConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        properties.put(WSHandlerConstants.SIG_PROP_FILE, "outsecurity.properties");
+        properties.put(WSHandlerConstants.USER, "myalias");
+        
+        WSS4JOutInterceptor ohandler = new WSS4JOutInterceptor(properties);
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    @Test
+    public void testSignaturePKI() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        WSSSecurityProperties inProperties = new WSSSecurityProperties();
+        inProperties.setCallbackHandler(new TestPwdCallback());
+        Properties cryptoProperties = 
+            CryptoFactory.getProperties("cxfca.properties", this.getClass().getClassLoader());
+        inProperties.setSignatureVerificationCryptoProperties(cryptoProperties);
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inProperties);
+        service.getInInterceptors().add(inhandler);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> properties = new HashMap<String, Object>();
+        properties.put(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE);
+        properties.put(WSHandlerConstants.PW_CALLBACK_REF, new KeystorePasswordCallback());
+        properties.put(WSHandlerConstants.SIG_PROP_FILE, "alice.properties");
+        properties.put(WSHandlerConstants.USER, "alice");
+        properties.put(WSHandlerConstants.USE_SINGLE_CERTIFICATE, "true");
+        properties.put(WSHandlerConstants.SIG_KEY_ID, "DirectReference");
+        
+        WSS4JOutInterceptor ohandler = new WSS4JOutInterceptor(properties);
+        client.getOutInterceptors().add(ohandler);
+        
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    @Test
+    public void testEncryptSignature() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        WSSSecurityProperties inProperties = new WSSSecurityProperties();
+        inProperties.setCallbackHandler(new TestPwdCallback());
+        Properties cryptoProperties = 
+            CryptoFactory.getProperties("insecurity.properties", this.getClass().getClassLoader());
+        inProperties.setSignatureVerificationCryptoProperties(cryptoProperties);
+        inProperties.setDecryptionCryptoProperties(cryptoProperties);
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inProperties);
+        service.getInInterceptors().add(inhandler);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> properties = new HashMap<String, Object>();
+        properties.put(
+            WSHandlerConstants.ACTION,
+            WSHandlerConstants.SIGNATURE + " " + WSHandlerConstants.ENCRYPT
+        );
+        properties.put(WSHandlerConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        properties.put(WSHandlerConstants.SIG_PROP_FILE, "outsecurity.properties");
+        properties.put(WSHandlerConstants.ENC_PROP_FILE, "outsecurity.properties");
+        properties.put(WSHandlerConstants.USER, "myalias");
+        
+        WSS4JOutInterceptor ohandler = new WSS4JOutInterceptor(properties);
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    private Service createService() {
+        // Create the Service
+        JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
+        factory.setServiceBean(new EchoImpl());
+        factory.setAddress("local://Echo");
+        factory.setTransportId(LocalTransportFactory.TRANSPORT_ID);
+        Server server = factory.create();
+        
+        Service service = server.getEndpoint().getService();
+        service.getInInterceptors().add(new LoggingInInterceptor());
+        service.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        return service;
+    }
+    
+    private Echo createClientProxy() {
+        JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean();
+        proxyFac.setServiceClass(Echo.class);
+        proxyFac.setAddress("local://Echo");
+        proxyFac.getClientFactoryBean().setTransportId(LocalTransportFactory.TRANSPORT_ID);
+        
+        return (Echo)proxyFac.create();
+    }
+}

Added: cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/DOMToStaxSignatureIdentifierTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/DOMToStaxSignatureIdentifierTest.java?rev=1466447&view=auto
==============================================================================
--- cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/DOMToStaxSignatureIdentifierTest.java (added)
+++ cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/DOMToStaxSignatureIdentifierTest.java Wed Apr 10 12:36:57 2013
@@ -0,0 +1,236 @@
+/**
+ * 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.ws.security.wss4j;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.frontend.ClientProxy;
+import org.apache.cxf.interceptor.LoggingInInterceptor;
+import org.apache.cxf.interceptor.LoggingOutInterceptor;
+import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.transport.local.LocalTransportFactory;
+import org.apache.wss4j.common.bsp.BSPRule;
+import org.apache.wss4j.common.crypto.CryptoFactory;
+import org.apache.wss4j.dom.handler.WSHandlerConstants;
+import org.apache.wss4j.stax.ext.WSSSecurityProperties;
+import org.junit.Test;
+
+
+/**
+ * In these test-cases, the client is using DOM and the service is using StaX. The tests are
+ * for different Signature Key Identifier methods.
+ */
+public class DOMToStaxSignatureIdentifierTest extends AbstractSecurityTest {
+    
+    @Test
+    public void testSignatureDirectReference() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        WSSSecurityProperties inProperties = new WSSSecurityProperties();
+        inProperties.setCallbackHandler(new TestPwdCallback());
+        Properties cryptoProperties = 
+            CryptoFactory.getProperties("insecurity.properties", this.getClass().getClassLoader());
+        inProperties.setSignatureVerificationCryptoProperties(cryptoProperties);
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inProperties);
+        service.getInInterceptors().add(inhandler);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> properties = new HashMap<String, Object>();
+        properties.put(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE);
+        properties.put(WSHandlerConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        properties.put(WSHandlerConstants.SIG_PROP_FILE, "outsecurity.properties");
+        properties.put(WSHandlerConstants.USER, "myalias");
+        properties.put(WSHandlerConstants.SIG_KEY_ID, "DirectReference");
+        
+        WSS4JOutInterceptor ohandler = new WSS4JOutInterceptor(properties);
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    @Test
+    public void testSignatureIssuerSerial() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        WSSSecurityProperties inProperties = new WSSSecurityProperties();
+        inProperties.setCallbackHandler(new TestPwdCallback());
+        Properties cryptoProperties = 
+            CryptoFactory.getProperties("insecurity.properties", this.getClass().getClassLoader());
+        inProperties.setSignatureVerificationCryptoProperties(cryptoProperties);
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inProperties);
+        service.getInInterceptors().add(inhandler);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> properties = new HashMap<String, Object>();
+        properties.put(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE);
+        properties.put(WSHandlerConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        properties.put(WSHandlerConstants.SIG_PROP_FILE, "outsecurity.properties");
+        properties.put(WSHandlerConstants.USER, "myalias");
+        properties.put(WSHandlerConstants.SIG_KEY_ID, "IssuerSerial");
+        
+        WSS4JOutInterceptor ohandler = new WSS4JOutInterceptor(properties);
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    @Test
+    public void testSignatureThumbprint() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        WSSSecurityProperties inProperties = new WSSSecurityProperties();
+        inProperties.setCallbackHandler(new TestPwdCallback());
+        Properties cryptoProperties = 
+            CryptoFactory.getProperties("insecurity.properties", this.getClass().getClassLoader());
+        inProperties.setSignatureVerificationCryptoProperties(cryptoProperties);
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inProperties);
+        service.getInInterceptors().add(inhandler);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> properties = new HashMap<String, Object>();
+        properties.put(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE);
+        properties.put(WSHandlerConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        properties.put(WSHandlerConstants.SIG_PROP_FILE, "outsecurity.properties");
+        properties.put(WSHandlerConstants.USER, "myalias");
+        properties.put(WSHandlerConstants.SIG_KEY_ID, "Thumbprint");
+        
+        WSS4JOutInterceptor ohandler = new WSS4JOutInterceptor(properties);
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    @Test
+    public void testSignatureX509() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        WSSSecurityProperties inProperties = new WSSSecurityProperties();
+        inProperties.setCallbackHandler(new TestPwdCallback());
+        Properties cryptoProperties = 
+            CryptoFactory.getProperties("insecurity.properties", this.getClass().getClassLoader());
+        inProperties.setSignatureVerificationCryptoProperties(cryptoProperties);
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inProperties);
+        service.getInInterceptors().add(inhandler);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> properties = new HashMap<String, Object>();
+        properties.put(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE);
+        properties.put(WSHandlerConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        properties.put(WSHandlerConstants.SIG_PROP_FILE, "outsecurity.properties");
+        properties.put(WSHandlerConstants.USER, "myalias");
+        properties.put(WSHandlerConstants.SIG_KEY_ID, "X509KeyIdentifier");
+        
+        WSS4JOutInterceptor ohandler = new WSS4JOutInterceptor(properties);
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    @Test
+    public void testSignatureKeyValue() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        WSSSecurityProperties inProperties = new WSSSecurityProperties();
+        inProperties.setCallbackHandler(new TestPwdCallback());
+        Properties cryptoProperties = 
+            CryptoFactory.getProperties("insecurity.properties", this.getClass().getClassLoader());
+        inProperties.setSignatureVerificationCryptoProperties(cryptoProperties);
+        inProperties.addIgnoreBSPRule(BSPRule.R5417);
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inProperties);
+        service.getInInterceptors().add(inhandler);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> properties = new HashMap<String, Object>();
+        properties.put(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE);
+        properties.put(WSHandlerConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        properties.put(WSHandlerConstants.SIG_PROP_FILE, "outsecurity.properties");
+        properties.put(WSHandlerConstants.USER, "myalias");
+        properties.put(WSHandlerConstants.SIG_KEY_ID, "KeyValue");
+        
+        WSS4JOutInterceptor ohandler = new WSS4JOutInterceptor(properties);
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+    }
+
+    private Service createService() {
+        // Create the Service
+        JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
+        factory.setServiceBean(new EchoImpl());
+        factory.setAddress("local://Echo");
+        factory.setTransportId(LocalTransportFactory.TRANSPORT_ID);
+        Server server = factory.create();
+        
+        Service service = server.getEndpoint().getService();
+        service.getInInterceptors().add(new LoggingInInterceptor());
+        service.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        return service;
+    }
+    
+    private Echo createClientProxy() {
+        JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean();
+        proxyFac.setServiceClass(Echo.class);
+        proxyFac.setAddress("local://Echo");
+        proxyFac.getClientFactoryBean().setTransportId(LocalTransportFactory.TRANSPORT_ID);
+        
+        return (Echo)proxyFac.create();
+    }
+}

Modified: cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/StaxRoundTripTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/StaxRoundTripTest.java?rev=1466447&r1=1466446&r2=1466447&view=diff
==============================================================================
--- cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/StaxRoundTripTest.java (original)
+++ cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/StaxRoundTripTest.java Wed Apr 10 12:36:57 2013
@@ -47,8 +47,13 @@ public class StaxRoundTripTest extends A
     @Test
     public void testUsernameTokenText() throws Exception {
         // Create + configure service
-        createService();
+        Service service = createService();
         
+        WSSSecurityProperties inProperties = new WSSSecurityProperties();
+        inProperties.setCallbackHandler(new TestPwdCallback());
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inProperties);
+        service.getInInterceptors().add(inhandler);
+
         // Create + configure client
         Echo echo = createClientProxy();
         
@@ -70,7 +75,12 @@ public class StaxRoundTripTest extends A
     @Test
     public void testUsernameTokenDigest() throws Exception {
         // Create + configure service
-        createService();
+        Service service = createService();
+        
+        WSSSecurityProperties inProperties = new WSSSecurityProperties();
+        inProperties.setCallbackHandler(new TestPwdCallback());
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inProperties);
+        service.getInInterceptors().add(inhandler);
         
         // Create + configure client
         Echo echo = createClientProxy();
@@ -91,10 +101,17 @@ public class StaxRoundTripTest extends A
     }
     
     @Test
-    @org.junit.Ignore
     public void testEncrypt() throws Exception {
         // Create + configure service
-        createService();
+        Service service = createService();
+        
+        WSSSecurityProperties inProperties = new WSSSecurityProperties();
+        inProperties.setCallbackHandler(new TestPwdCallback());
+        Properties cryptoProperties = 
+            CryptoFactory.getProperties("insecurity.properties", this.getClass().getClassLoader());
+        inProperties.setDecryptionCryptoProperties(cryptoProperties);
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inProperties);
+        service.getInInterceptors().add(inhandler);
         
         // Create + configure client
         Echo echo = createClientProxy();
@@ -107,9 +124,9 @@ public class StaxRoundTripTest extends A
         properties.setOutAction(new XMLSecurityConstants.Action[]{WSSConstants.ENCRYPT});
         properties.setEncryptionUser("myalias");
         
-        Properties cryptoProperties = 
+        Properties outCryptoProperties = 
             CryptoFactory.getProperties("outsecurity.properties", this.getClass().getClassLoader());
-        properties.setEncryptionCryptoProperties(cryptoProperties);
+        properties.setEncryptionCryptoProperties(outCryptoProperties);
         properties.setCallbackHandler(new TestPwdCallback());
         WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(properties);
         client.getOutInterceptors().add(ohandler);
@@ -120,7 +137,15 @@ public class StaxRoundTripTest extends A
     @Test
     public void testEncryptUsernameToken() throws Exception {
         // Create + configure service
-        createService();
+        Service service = createService();
+        
+        WSSSecurityProperties inProperties = new WSSSecurityProperties();
+        inProperties.setCallbackHandler(new TestPwdCallback());
+        Properties cryptoProperties = 
+            CryptoFactory.getProperties("insecurity.properties", this.getClass().getClassLoader());
+        inProperties.setDecryptionCryptoProperties(cryptoProperties);
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inProperties);
+        service.getInInterceptors().add(inhandler);
         
         // Create + configure client
         Echo echo = createClientProxy();
@@ -139,9 +164,9 @@ public class StaxRoundTripTest extends A
         properties.setEncryptionUser("myalias");
         properties.setTokenUser("username");
         
-        Properties cryptoProperties = 
+        Properties outCryptoProperties = 
             CryptoFactory.getProperties("outsecurity.properties", this.getClass().getClassLoader());
-        properties.setEncryptionCryptoProperties(cryptoProperties);
+        properties.setEncryptionCryptoProperties(outCryptoProperties);
         properties.setCallbackHandler(new TestPwdCallback());
         WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(properties);
         client.getOutInterceptors().add(ohandler);
@@ -152,7 +177,15 @@ public class StaxRoundTripTest extends A
     @Test
     public void testSignature() throws Exception {
         // Create + configure service
-        createService();
+        Service service = createService();
+        
+        WSSSecurityProperties inProperties = new WSSSecurityProperties();
+        inProperties.setCallbackHandler(new TestPwdCallback());
+        Properties cryptoProperties = 
+            CryptoFactory.getProperties("insecurity.properties", this.getClass().getClassLoader());
+        inProperties.setSignatureVerificationCryptoProperties(cryptoProperties);
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inProperties);
+        service.getInInterceptors().add(inhandler);
         
         // Create + configure client
         Echo echo = createClientProxy();
@@ -165,9 +198,9 @@ public class StaxRoundTripTest extends A
         properties.setOutAction(new XMLSecurityConstants.Action[]{WSSConstants.SIGNATURE});
         properties.setSignatureUser("myalias");
         
-        Properties cryptoProperties = 
+        Properties outCryptoProperties = 
             CryptoFactory.getProperties("outsecurity.properties", this.getClass().getClassLoader());
-        properties.setSignatureCryptoProperties(cryptoProperties);
+        properties.setSignatureCryptoProperties(outCryptoProperties);
         properties.setCallbackHandler(new TestPwdCallback());
         WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(properties);
         client.getOutInterceptors().add(ohandler);
@@ -178,7 +211,11 @@ public class StaxRoundTripTest extends A
     @Test
     public void testTimestamp() throws Exception {
         // Create + configure service
-        createService();
+        Service service = createService();
+        
+        WSSSecurityProperties inProperties = new WSSSecurityProperties();
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inProperties);
+        service.getInInterceptors().add(inhandler);
         
         // Create + configure client
         Echo echo = createClientProxy();
@@ -199,7 +236,15 @@ public class StaxRoundTripTest extends A
     @Test
     public void testSignatureTimestamp() throws Exception {
         // Create + configure service
-        createService();
+        Service service = createService();
+        
+        WSSSecurityProperties inProperties = new WSSSecurityProperties();
+        inProperties.setCallbackHandler(new TestPwdCallback());
+        Properties cryptoProperties = 
+            CryptoFactory.getProperties("insecurity.properties", this.getClass().getClassLoader());
+        inProperties.setSignatureVerificationCryptoProperties(cryptoProperties);
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inProperties);
+        service.getInInterceptors().add(inhandler);
         
         // Create + configure client
         Echo echo = createClientProxy();
@@ -213,16 +258,16 @@ public class StaxRoundTripTest extends A
             new XMLSecurityConstants.Action[]{WSSConstants.SIGNATURE, WSSConstants.TIMESTAMP}
         );
         properties.addSignaturePart(
-            new SecurePart(new QName(WSSConstants.NS_WSSE10, "Timestamp"), SecurePart.Modifier.Element)
+            new SecurePart(new QName(WSSConstants.NS_WSU10, "Timestamp"), SecurePart.Modifier.Element)
         );
         properties.addSignaturePart(
             new SecurePart(new QName(WSSConstants.NS_SOAP11, "Body"), SecurePart.Modifier.Element)
         );
         properties.setSignatureUser("myalias");
         
-        Properties cryptoProperties = 
+        Properties outCryptoProperties = 
             CryptoFactory.getProperties("outsecurity.properties", this.getClass().getClassLoader());
-        properties.setSignatureCryptoProperties(cryptoProperties);
+        properties.setSignatureCryptoProperties(outCryptoProperties);
         properties.setCallbackHandler(new TestPwdCallback());
         WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(properties);
         client.getOutInterceptors().add(ohandler);
@@ -233,7 +278,15 @@ public class StaxRoundTripTest extends A
     @Test
     public void testSignaturePKI() throws Exception {
         // Create + configure service
-        createService();
+        Service service = createService();
+        
+        WSSSecurityProperties inProperties = new WSSSecurityProperties();
+        inProperties.setCallbackHandler(new TestPwdCallback());
+        Properties cryptoProperties = 
+            CryptoFactory.getProperties("cxfca.properties", this.getClass().getClassLoader());
+        inProperties.setSignatureVerificationCryptoProperties(cryptoProperties);
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inProperties);
+        service.getInInterceptors().add(inhandler);
         
         // Create + configure client
         Echo echo = createClientProxy();
@@ -248,9 +301,9 @@ public class StaxRoundTripTest extends A
         );
         properties.setSignatureUser("alice");
         
-        Properties cryptoProperties = 
+        Properties outCryptoProperties = 
             CryptoFactory.getProperties("alice.properties", this.getClass().getClassLoader());
-        properties.setSignatureCryptoProperties(cryptoProperties);
+        properties.setSignatureCryptoProperties(outCryptoProperties);
         properties.setCallbackHandler(new KeystorePasswordCallback());
         properties.setUseSingleCert(true);
         properties.setSignatureKeyIdentifier(
@@ -264,10 +317,18 @@ public class StaxRoundTripTest extends A
     }
     
     @Test
-    @org.junit.Ignore
     public void testEncryptSignature() throws Exception {
         // Create + configure service
-        createService();
+        Service service = createService();
+        
+        WSSSecurityProperties inProperties = new WSSSecurityProperties();
+        inProperties.setCallbackHandler(new TestPwdCallback());
+        Properties cryptoProperties = 
+            CryptoFactory.getProperties("insecurity.properties", this.getClass().getClassLoader());
+        inProperties.setSignatureVerificationCryptoProperties(cryptoProperties);
+        inProperties.setDecryptionCryptoProperties(cryptoProperties);
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inProperties);
+        service.getInInterceptors().add(inhandler);
         
         // Create + configure client
         Echo echo = createClientProxy();
@@ -283,17 +344,17 @@ public class StaxRoundTripTest extends A
         properties.setEncryptionUser("myalias");
         properties.setSignatureUser("myalias");
         
-        Properties cryptoProperties = 
+        Properties outCryptoProperties = 
             CryptoFactory.getProperties("outsecurity.properties", this.getClass().getClassLoader());
-        properties.setEncryptionCryptoProperties(cryptoProperties);
-        properties.setSignatureCryptoProperties(cryptoProperties);
+        properties.setSignatureCryptoProperties(outCryptoProperties);
+        properties.setEncryptionCryptoProperties(outCryptoProperties);
         properties.setCallbackHandler(new TestPwdCallback());
         WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(properties);
         client.getOutInterceptors().add(ohandler);
 
         assertEquals("test", echo.echo("test"));
     }
-
+    
    /*
     * TODO
     @Test

Modified: cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/StaxToDOMEncryptionIdentifierTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/StaxToDOMEncryptionIdentifierTest.java?rev=1466447&r1=1466446&r2=1466447&view=diff
==============================================================================
--- cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/StaxToDOMEncryptionIdentifierTest.java (original)
+++ cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/StaxToDOMEncryptionIdentifierTest.java Wed Apr 10 12:36:57 2013
@@ -191,6 +191,44 @@ public class StaxToDOMEncryptionIdentifi
         assertEquals("test", echo.echo("test"));
     }
     
+    // TODO
+    @Test
+    @org.junit.Ignore
+    public void testEncryptEncryptedKeySHA1() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        Map<String, Object> inProperties = new HashMap<String, Object>();
+        inProperties.put(WSHandlerConstants.ACTION, WSHandlerConstants.ENCRYPT);
+        inProperties.put(WSHandlerConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        inProperties.put(WSHandlerConstants.DEC_PROP_FILE, "insecurity.properties");
+        WSS4JInInterceptor inInterceptor = new WSS4JInInterceptor(inProperties);
+        service.getInInterceptors().add(inInterceptor);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        WSSSecurityProperties properties = new WSSSecurityProperties();
+        properties.setOutAction(new XMLSecurityConstants.Action[]{WSSConstants.ENCRYPT});
+        properties.setEncryptionUser("myalias");
+        properties.setEncryptionKeyIdentifier(
+            WSSecurityTokenConstants.KeyIdentifier_EncryptedKey
+        );
+        
+        Properties cryptoProperties = 
+            CryptoFactory.getProperties("outsecurity.properties", this.getClass().getClassLoader());
+        properties.setEncryptionCryptoProperties(cryptoProperties);
+        properties.setCallbackHandler(new TestPwdCallback());
+        WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(properties);
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
     private Service createService() {
         // Create the Service
         JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();



Mime
View raw message