From 6b334878380c5a6038a511314ade3256f362cd8f Mon Sep 17 00:00:00 2001 From: Tareq Abedrabbo Date: Tue, 15 Dec 2009 10:30:39 +0000 Subject: [PATCH] SWS-581 - allow for qualified password types by default --- .../security/wss4j/Wss4jSecurityInterceptor.java | 7 +++---- ...jMessageInterceptorUsernameTokenTestCase.java | 16 +--------------- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/security/src/main/java/org/springframework/ws/soap/security/wss4j/Wss4jSecurityInterceptor.java b/security/src/main/java/org/springframework/ws/soap/security/wss4j/Wss4jSecurityInterceptor.java index eef5307e..6d5f2a99 100755 --- a/security/src/main/java/org/springframework/ws/soap/security/wss4j/Wss4jSecurityInterceptor.java +++ b/security/src/main/java/org/springframework/ws/soap/security/wss4j/Wss4jSecurityInterceptor.java @@ -436,10 +436,6 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl handler.setOption(WSHandlerConstants.ADD_UT_ELEMENTS, securementUsernameTokenElements); } - public void setAllowQualifiedPasswordTypes(boolean allowQualifiedPasswordTypes) { - securityEngine.getWssConfig().setAllowNamespaceQualifiedPasswordTypes(allowQualifiedPasswordTypes); - } - public void afterPropertiesSet() throws Exception { Assert.isTrue(validationActions != null || securementActions != null, "validationActions or securementActions are required"); @@ -454,6 +450,9 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl } // securement actions are not to be validated at start up as they could // be configured dynamically via the message context + + // allow for qualified password types for .Net interoperability + securityEngine.getWssConfig().setAllowNamespaceQualifiedPasswordTypes(true); } protected void secureMessage(SoapMessage soapMessage, MessageContext messageContext) diff --git a/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorUsernameTokenTestCase.java b/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorUsernameTokenTestCase.java index bdc8d725..21c40ae0 100755 --- a/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorUsernameTokenTestCase.java +++ b/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorUsernameTokenTestCase.java @@ -51,28 +51,14 @@ public abstract class Wss4jMessageInterceptorUsernameTokenTestCase extends Wss4j assertValidateUsernameToken(message); } - public void testValidateUsernameTokenAcceptQualifiedType() throws Exception { + public void testValidateUsernameTokenWithQualifiedType() throws Exception { Wss4jSecurityInterceptor interceptor = prepareInterceptor("UsernameToken", true, false); - interceptor.setAllowQualifiedPasswordTypes(true); SoapMessage message = loadMessage("usernameTokenPlainTextQualifiedType-soap.xml"); MessageContext messageContext = new DefaultMessageContext(message, getMessageFactory()); interceptor.validateMessage(message, messageContext); assertValidateUsernameToken(message); } - public void testValidateUsernameTokenRejectQualifiedType() throws Exception { - Wss4jSecurityInterceptor interceptor = prepareInterceptor("UsernameToken", true, false); - interceptor.setAllowQualifiedPasswordTypes(false); - SoapMessage message = loadMessage("usernameTokenPlainTextQualifiedType-soap.xml"); - MessageContext messageContext = new DefaultMessageContext(message, getMessageFactory()); - try { - interceptor.validateMessage(message, messageContext); - fail("Qualified password type was not rejected"); - } catch (WsSecurityValidationException e) { - // expected - } - } - public void testAddUsernameTokenPlainText() throws Exception { Wss4jSecurityInterceptor interceptor = prepareInterceptor("UsernameToken", false, false); interceptor.setSecurementUsername("Bert");