Author: coheigea
Date: Wed Jun  1 13:36:26 2011
New Revision: 1130149

URL: http://svn.apache.org/viewvc?rev=1130149&view=rev
Log:
[CXF-3521] - WebServiceContext.getUserPrincipal() is null for incoming SAML 
Token or transformed token
 - Upgrading to WSS4J 1.6.1-SNAPSHOT

Modified:
    cxf/trunk/parent/pom.xml
    
cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JInInterceptor.java
    
cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/saml/server/DoubleItImpl.java

Modified: cxf/trunk/parent/pom.xml
URL: 
http://svn.apache.org/viewvc/cxf/trunk/parent/pom.xml?rev=1130149&r1=1130148&r2=1130149&view=diff
==============================================================================
--- cxf/trunk/parent/pom.xml (original)
+++ cxf/trunk/parent/pom.xml Wed Jun  1 13:36:26 2011
@@ -89,7 +89,7 @@
         <cxf.jibx.version>1.2.3</cxf.jibx.version>
         <cxf.axiom.version>1.2.10</cxf.axiom.version>
         <cxf.jettison.version>1.3</cxf.jettison.version>
-        <cxf.wss4j.version>1.6.0</cxf.wss4j.version>
+        <cxf.wss4j.version>1.6.1-SNAPSHOT</cxf.wss4j.version>
         <cxf.joda.time.version>1.6.2</cxf.joda.time.version>
         <cxf.opensaml.version>2.4.1</cxf.opensaml.version>
         <cxf.opensamlws.version>1.4.1</cxf.opensamlws.version>

Modified: 
cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JInInterceptor.java
URL: 
http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JInInterceptor.java?rev=1130149&r1=1130148&r2=1130149&view=diff
==============================================================================
--- 
cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JInInterceptor.java
 (original)
+++ 
cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JInInterceptor.java
 Wed Jun  1 13:36:26 2011
@@ -60,6 +60,7 @@ import org.apache.cxf.staxutils.StaxUtil
 import org.apache.cxf.ws.security.SecurityConstants;
 import org.apache.cxf.ws.security.tokenstore.SecurityToken;
 import org.apache.cxf.ws.security.tokenstore.TokenStore;
+import org.apache.ws.security.CustomTokenPrincipal;
 import org.apache.ws.security.WSConstants;
 import org.apache.ws.security.WSDerivedKeyTokenPrincipal;
 import org.apache.ws.security.WSPasswordCallback;
@@ -422,11 +423,11 @@ public class WSS4JInInterceptor extends 
      */
     protected boolean isSecurityContextPrincipal(Principal p, 
List<WSSecurityEngineResult> wsResult) {
         boolean derivedKeyPrincipal = p instanceof WSDerivedKeyTokenPrincipal;
-        if (derivedKeyPrincipal) {
-            // If it is a derived key principal then let it be a 
SecurityContext
-            // principal only if no other principals are available.
-            // The derived key principal will still be visible to
-            // custom interceptors as part of the 
WSHandlerConstants.RECV_RESULTS value
+        if (derivedKeyPrincipal || p instanceof CustomTokenPrincipal) {
+            // If it is a derived key principal or a Custom Token Principal 
then let it 
+            // be a SecurityContext principal only if no other principals are 
available.
+            // The principal will still be visible to custom interceptors as 
part of the 
+            // WSHandlerConstants.RECV_RESULTS value
             return wsResult.size() > 1 ? false : true;
         } else {
             return true;

Modified: 
cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/saml/server/DoubleItImpl.java
URL: 
http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/saml/server/DoubleItImpl.java?rev=1130149&r1=1130148&r2=1130149&view=diff
==============================================================================
--- 
cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/saml/server/DoubleItImpl.java
 (original)
+++ 
cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/saml/server/DoubleItImpl.java
 Wed Jun  1 13:36:26 2011
@@ -20,18 +20,32 @@
 package org.apache.cxf.systest.ws.saml.server;
 
 import java.math.BigInteger;
+import java.security.Principal;
 
+import javax.annotation.Resource;
 import javax.jws.WebService;
+import javax.xml.ws.WebServiceContext;
+
 import org.apache.cxf.feature.Features;
+import org.junit.Assert;
+
 import wssec.saml.DoubleItPortType;
 
 @WebService(targetNamespace = "http://WSSec/saml";, 
             serviceName = "DoubleItService", 
             endpointInterface = "wssec.saml.DoubleItPortType")
 @Features(features = "org.apache.cxf.feature.LoggingFeature")              
-public class DoubleItImpl implements DoubleItPortType  {
+public class DoubleItImpl implements DoubleItPortType {
+    
+    @Resource
+    WebServiceContext wsContext;
 
     public java.math.BigInteger doubleIt(java.math.BigInteger numberToDouble) {
+        Principal pr = wsContext.getUserPrincipal();
+        
+        Assert.assertNotNull("Principal must not be null", pr);
+        Assert.assertNotNull("Principal.getName() must not return null", 
pr.getName());
+        
         return numberToDouble.multiply(BigInteger.valueOf(2));
     }
     


Reply via email to