You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2013/04/15 16:10:12 UTC
svn commit: r1468084 - in
/cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j:
CryptoCoverageCheckerTest.java DOMToStaxRoundTripTest.java
StaxToDOMRoundTripTest.java
Author: coheigea
Date: Mon Apr 15 14:10:12 2013
New Revision: 1468084
URL: http://svn.apache.org/r1468084
Log:
Added some encryption algorithm interop tests
Modified:
cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/CryptoCoverageCheckerTest.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/StaxToDOMRoundTripTest.java
Modified: cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/CryptoCoverageCheckerTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/CryptoCoverageCheckerTest.java?rev=1468084&r1=1468083&r2=1468084&view=diff
==============================================================================
--- cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/CryptoCoverageCheckerTest.java (original)
+++ cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/CryptoCoverageCheckerTest.java Mon Apr 15 14:10:12 2013
@@ -235,6 +235,7 @@ public class CryptoCoverageCheckerTest e
inHandler.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS,
TestPwdCallback.class.getName());
inHandler.setProperty(WSHandlerConstants.IS_BSP_COMPLIANT, "false");
+ inHandler.setProperty(WSHandlerConstants.ALLOW_RSA15_KEY_TRANSPORT_ALGORITHM, "true");
return inHandler;
}
Modified: 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=1468084&r1=1468083&r2=1468084&view=diff
==============================================================================
--- cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/DOMToStaxRoundTripTest.java (original)
+++ cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/DOMToStaxRoundTripTest.java Mon Apr 15 14:10:12 2013
@@ -170,6 +170,51 @@ public class DOMToStaxRoundTripTest exte
}
@Test
+ public void testEncryptionAlgorithms() 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_TRANSPORT, WSConstants.KEYTRANSPORT_RSA15);
+ properties.put(WSHandlerConstants.ENC_SYM_ALGO, WSConstants.TRIPLE_DES);
+
+ WSS4JOutInterceptor ohandler = new WSS4JOutInterceptor(properties);
+ client.getOutInterceptors().add(ohandler);
+
+ try {
+ echo.echo("test");
+ fail("Failure expected as RSA v1.5 is not allowed by default");
+ } catch (javax.xml.ws.soap.SOAPFaultException ex) {
+ // expected
+ }
+
+ inProperties.setAllowRSA15KeyTransportAlgorithm(true);
+ service.getInInterceptors().remove(inhandler);
+ inhandler = new WSS4JStaxInInterceptor(inProperties);
+ service.getInInterceptors().add(inhandler);
+ assertEquals("test", echo.echo("test"));
+ }
+
+ @Test
public void testEncryptUsernameToken() throws Exception {
// Create + configure service
Service service = createService();
@@ -236,7 +281,7 @@ public class DOMToStaxRoundTripTest exte
assertEquals("test", echo.echo("test"));
}
-
+
@Test
public void testTimestamp() throws Exception {
// Create + configure service
Modified: cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/StaxToDOMRoundTripTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/StaxToDOMRoundTripTest.java?rev=1468084&r1=1468083&r2=1468084&view=diff
==============================================================================
--- cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/StaxToDOMRoundTripTest.java (original)
+++ cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/StaxToDOMRoundTripTest.java Mon Apr 15 14:10:12 2013
@@ -173,6 +173,49 @@ public class StaxToDOMRoundTripTest exte
}
@Test
+ public void testEncryptionAlgorithms() 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 cryptoProperties =
+ CryptoFactory.getProperties("outsecurity.properties", this.getClass().getClassLoader());
+ properties.setEncryptionCryptoProperties(cryptoProperties);
+ properties.setCallbackHandler(new TestPwdCallback());
+ properties.setEncryptionKeyTransportAlgorithm("http://www.w3.org/2001/04/xmlenc#rsa-1_5");
+ properties.setEncryptionSymAlgorithm("http://www.w3.org/2001/04/xmlenc#tripledes-cbc");
+ WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(properties);
+ client.getOutInterceptors().add(ohandler);
+
+ try {
+ echo.echo("test");
+ fail("Failure expected as RSA v1.5 is not allowed by default");
+ } catch (javax.xml.ws.soap.SOAPFaultException ex) {
+ // expected
+ }
+
+ inProperties.put(WSHandlerConstants.ALLOW_RSA15_KEY_TRANSPORT_ALGORITHM, "true");
+ assertEquals("test", echo.echo("test"));
+ }
+
+ @Test
public void testEncryptUsernameToken() throws Exception {
// Create + configure service
Service service = createService();