You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2011/02/08 12:03:39 UTC

svn commit: r1068323 - in /cxf/branches/2.3.x-fixes: ./ rt/ws/security/src/main/java/org/apache/cxf/ws/security/ rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/ systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/wssec10/server/

Author: sergeyb
Date: Tue Feb  8 11:03:38 2011
New Revision: 1068323

URL: http://svn.apache.org/viewvc?rev=1068323&view=rev
Log:
Merged revisions 1068320 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1068320 | sergeyb | 2011-02-08 10:59:43 +0000 (Tue, 08 Feb 2011) | 1 line
  
  Removing undocumented ws-security property and updating UsernameTokenInterceptor to duplicate a WSS4J token as a CXF one
........

Added:
    cxf/branches/2.3.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JTokenConverter.java
      - copied unchanged from r1068320, cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JTokenConverter.java
Modified:
    cxf/branches/2.3.x-fixes/   (props changed)
    cxf/branches/2.3.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/SecurityConstants.java
    cxf/branches/2.3.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/UsernameTokenInterceptor.java
    cxf/branches/2.3.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JInInterceptor.java
    cxf/branches/2.3.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/wssec10/server/CustomUsernameTokenInterceptor.java

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
    svn:mergeinfo = /cxf/trunk:1068320

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.3.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/SecurityConstants.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/SecurityConstants.java?rev=1068323&r1=1068322&r2=1068323&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/SecurityConstants.java (original)
+++ cxf/branches/2.3.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/SecurityConstants.java Tue Feb  8 11:03:38 2011
@@ -30,7 +30,6 @@ import java.util.Set;
 public final class SecurityConstants {
     public static final String USERNAME = "ws-security.username";
     public static final String PASSWORD = "ws-security.password";
-    public static final String VALIDATE_PASSWORD = "ws-security.validate.password";
     public static final String USERNAME_TOKEN_NO_CALLBACKS = "ws-security.ut.no-callbacks";
     
     public static final String CALLBACK_HANDLER = "ws-security.callback-handler";

Modified: cxf/branches/2.3.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/UsernameTokenInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/UsernameTokenInterceptor.java?rev=1068323&r1=1068322&r2=1068323&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/UsernameTokenInterceptor.java (original)
+++ cxf/branches/2.3.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/UsernameTokenInterceptor.java Tue Feb  8 11:03:38 2011
@@ -141,6 +141,12 @@ public class UsernameTokenInterceptor ex
 
                         assertUsernameTokens(message, princ);
                         message.put(WSS4JInInterceptor.PRINCIPAL_RESULT, princ);                   
+                        
+                        boolean utWithCallbacks = !MessageUtils.getContextualBoolean(message, 
+                                 SecurityConstants.USERNAME_TOKEN_NO_CALLBACKS, false);
+                        if (!utWithCallbacks) {
+                            WSS4JTokenConverter.convertToken(message, princ);
+                        }
                         SecurityContext sc = message.get(SecurityContext.class);
                         if (sc == null || sc.getUserPrincipal() == null) {
                             Subject subject = createSubject(princ.getName(), princ.getPassword(),
@@ -161,12 +167,15 @@ public class UsernameTokenInterceptor ex
     protected WSUsernameTokenPrincipal getPrincipal(Element tokenElement, SoapMessage message)
         throws WSSecurityException {
         
-        Object validateProperty = message.getContextualProperty(SecurityConstants.VALIDATE_PASSWORD);
-        if (validateProperty == null || MessageUtils.isTrue(validateProperty)) {
+        boolean utWithCallbacks = 
+            !MessageUtils.getContextualBoolean(message, SecurityConstants.USERNAME_TOKEN_NO_CALLBACKS, false);
+        if (utWithCallbacks) {
             UsernameTokenProcessor p = new UsernameTokenProcessor();
             return p.handleUsernameToken(tokenElement, getCallback(message));
         } else {
-            return parseTokenAndCreatePrincipal(tokenElement);
+            WSUsernameTokenPrincipal principal = parseTokenAndCreatePrincipal(tokenElement);
+            WSS4JTokenConverter.convertToken(message, principal);
+            return principal;
         }
     }
     

Modified: cxf/branches/2.3.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JInInterceptor.java?rev=1068323&r1=1068322&r2=1068323&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JInInterceptor.java (original)
+++ cxf/branches/2.3.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JInInterceptor.java Tue Feb  8 11:03:38 2011
@@ -47,7 +47,6 @@ import org.apache.cxf.binding.soap.saaj.
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.common.security.UsernameToken;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.interceptor.Fault;
@@ -433,16 +432,8 @@ public class WSS4JInInterceptor extends 
             final Principal p = (Principal)o.get(WSSecurityEngineResult.TAG_PRINCIPAL);
             if (p != null) {
                 msg.put(PRINCIPAL_RESULT, p);
-                if (!utWithCallbacks && p instanceof WSUsernameTokenPrincipal) {
-                    WSUsernameTokenPrincipal utp = (WSUsernameTokenPrincipal)p;
-                    msg.put(org.apache.cxf.common.security.SecurityToken.class, 
-                            new UsernameToken(utp.getName(),
-                                              utp.getPassword(),
-                                              utp.getPasswordType(),
-                                              utp.isPasswordDigest(),
-                                              utp.getNonce(),
-                                              utp.getCreatedTime()));
-                    
+                if (!utWithCallbacks) {
+                    WSS4JTokenConverter.convertToken(msg, p);
                 }
                 SecurityContext sc = msg.get(SecurityContext.class);
                 if (sc == null || sc.getUserPrincipal() == null) {

Modified: cxf/branches/2.3.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/wssec10/server/CustomUsernameTokenInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/wssec10/server/CustomUsernameTokenInterceptor.java?rev=1068323&r1=1068322&r2=1068323&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/wssec10/server/CustomUsernameTokenInterceptor.java (original)
+++ cxf/branches/2.3.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/wssec10/server/CustomUsernameTokenInterceptor.java Tue Feb  8 11:03:38 2011
@@ -55,7 +55,7 @@ public class CustomUsernameTokenIntercep
     }
     
     public void handleMessage(SoapMessage message) throws Fault {
-        message.put(SecurityConstants.VALIDATE_PASSWORD, Boolean.FALSE);
+        message.put(SecurityConstants.USERNAME_TOKEN_NO_CALLBACKS, Boolean.TRUE);
         super.handleMessage(message);
     }