[jbossws-commits] JBossWS SVN: r16905 - thirdparty/cxf/branches/cxf-2.4.6-patch-01_JBPAPP-10204/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Mon Oct 15 17:47:16 EDT 2012


Author: klape
Date: 2012-10-15 17:47:16 -0400 (Mon, 15 Oct 2012)
New Revision: 16905

Modified:
   thirdparty/cxf/branches/cxf-2.4.6-patch-01_JBPAPP-10204/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/UsernameTokenInterceptor.java
Log:
[JBPAPP-10205] One-off for EAP 6.0.0 of CXF-4561: Allow disabling WSI-BSP compliance in UsernameTokenInterceptor

Modified: thirdparty/cxf/branches/cxf-2.4.6-patch-01_JBPAPP-10204/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/UsernameTokenInterceptor.java
===================================================================
--- thirdparty/cxf/branches/cxf-2.4.6-patch-01_JBPAPP-10204/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/UsernameTokenInterceptor.java	2012-10-15 20:47:20 UTC (rev 16904)
+++ thirdparty/cxf/branches/cxf-2.4.6-patch-01_JBPAPP-10204/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/UsernameTokenInterceptor.java	2012-10-15 21:47:16 UTC (rev 16905)
@@ -170,6 +170,7 @@
     protected WSUsernameTokenPrincipal getPrincipal(Element tokenElement, final SoapMessage message)
         throws WSSecurityException {
         
+        boolean bspCompliant = isWsiBSPCompliant(message);
         boolean utWithCallbacks = 
             MessageUtils.getContextualBoolean(message, SecurityConstants.VALIDATE_TOKEN, true);
         if (utWithCallbacks) {
@@ -188,21 +189,23 @@
                     return (Validator)validator;
                 }
             };
-            data.setWssConfig(WSSConfig.getNewInstance());
+            WSSConfig config = WSSConfig.getNewInstance();
+            config.setWsiBSPCompliant(bspCompliant);
+            data.setWssConfig(config);
             List<WSSecurityEngineResult> results = 
                 p.handleToken(tokenElement, data, wsDocInfo);
             return (WSUsernameTokenPrincipal)results.get(0).get(WSSecurityEngineResult.TAG_PRINCIPAL);
         } else {
-            WSUsernameTokenPrincipal principal = parseTokenAndCreatePrincipal(tokenElement);
+            WSUsernameTokenPrincipal principal = parseTokenAndCreatePrincipal(tokenElement, bspCompliant);
             WSS4JTokenConverter.convertToken(message, principal);
             return principal;
         }
     }
     
-    protected WSUsernameTokenPrincipal parseTokenAndCreatePrincipal(Element tokenElement) 
+    protected WSUsernameTokenPrincipal parseTokenAndCreatePrincipal(Element tokenElement, boolean bspCompliant) 
         throws WSSecurityException {
         org.apache.ws.security.message.token.UsernameToken ut = 
-            new org.apache.ws.security.message.token.UsernameToken(tokenElement);
+            new org.apache.ws.security.message.token.UsernameToken(tokenElement, false, bspCompliant);
         
         WSUsernameTokenPrincipal principal = new WSUsernameTokenPrincipal(ut.getName(), ut.isHashed());
         principal.setNonce(ut.getNonce());
@@ -213,6 +216,12 @@
         return principal;
     }
     
+    protected boolean isWsiBSPCompliant(final SoapMessage message) {
+        String bspc = (String)message.getContextualProperty(SecurityConstants.IS_BSP_COMPLIANT);
+        // Default to WSI-BSP compliance enabled
+        return !("false".equals(bspc) || "0".equals(bspc));
+    }
+    
     protected SecurityContext createSecurityContext(final Principal p, Subject subject) {
         return new DefaultSecurityContext(p, subject);
     }



More information about the jbossws-commits mailing list