cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1382112 - in /cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/claims: ClaimsAttributeStatementProvider.java CorrectedClaimsAttributeStatementProvider.java
Date Fri, 07 Sep 2012 18:22:48 GMT
Author: coheigea
Date: Fri Sep  7 18:22:48 2012
New Revision: 1382112

URL: http://svn.apache.org/viewvc?rev=1382112&view=rev
Log:
[CXF-4484] - Claims to SAML attribute encoding wrong

Added:
    cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/claims/CorrectedClaimsAttributeStatementProvider.java
      - copied, changed from r1381388, cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/claims/ClaimsAttributeStatementProvider.java
Modified:
    cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/claims/ClaimsAttributeStatementProvider.java

Modified: cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/claims/ClaimsAttributeStatementProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/claims/ClaimsAttributeStatementProvider.java?rev=1382112&r1=1382111&r2=1382112&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/claims/ClaimsAttributeStatementProvider.java
(original)
+++ cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/claims/ClaimsAttributeStatementProvider.java
Fri Sep  7 18:22:48 2012
@@ -31,6 +31,7 @@ import org.apache.ws.security.WSConstant
 import org.apache.ws.security.saml.ext.bean.AttributeBean;
 import org.apache.ws.security.saml.ext.bean.AttributeStatementBean;
 
+@Deprecated
 public class ClaimsAttributeStatementProvider implements AttributeStatementProvider {
 
     public AttributeStatementBean getStatement(TokenProviderParameters providerParameters)
{

Copied: cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/claims/CorrectedClaimsAttributeStatementProvider.java
(from r1381388, cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/claims/ClaimsAttributeStatementProvider.java)
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/claims/CorrectedClaimsAttributeStatementProvider.java?p2=cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/claims/CorrectedClaimsAttributeStatementProvider.java&p1=cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/claims/ClaimsAttributeStatementProvider.java&r1=1381388&r2=1382112&rev=1382112&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/claims/ClaimsAttributeStatementProvider.java
(original)
+++ cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/claims/CorrectedClaimsAttributeStatementProvider.java
Fri Sep  7 18:22:48 2012
@@ -30,8 +30,11 @@ import org.apache.cxf.sts.token.provider
 import org.apache.ws.security.WSConstants;
 import org.apache.ws.security.saml.ext.bean.AttributeBean;
 import org.apache.ws.security.saml.ext.bean.AttributeStatementBean;
+import org.apache.ws.security.saml.ext.builder.SAML2Constants;
 
-public class ClaimsAttributeStatementProvider implements AttributeStatementProvider {
+public class CorrectedClaimsAttributeStatementProvider implements AttributeStatementProvider
{
+    
+    private String nameFormat = SAML2Constants.ATTRNAME_FORMAT_UNSPECIFIED;
 
     public AttributeStatementBean getStatement(TokenProviderParameters providerParameters)
{
         // Handle Claims
@@ -77,14 +80,25 @@ public class ClaimsAttributeStatementPro
         while (claimIterator.hasNext()) {
             Claim claim = claimIterator.next();
             AttributeBean attributeBean = new AttributeBean();
-            URI name = claim.getNamespace().relativize(claim.getClaimType());
+            
+            URI claimType = claim.getClaimType();
             if (WSConstants.WSS_SAML2_TOKEN_TYPE.equals(tokenType)
                 || WSConstants.SAML2_NS.equals(tokenType)) {
-                attributeBean.setQualifiedName(name.toString());
-                attributeBean.setNameFormat(claim.getNamespace().toString());
+                attributeBean.setQualifiedName(claimType.toString());
+                attributeBean.setNameFormat(nameFormat);
             } else {
-                attributeBean.setSimpleName(name.toString());
-                attributeBean.setQualifiedName(claim.getNamespace().toString());
+                String uri = claimType.toString();
+                int lastSlash = uri.lastIndexOf("/");
+                if (lastSlash == (uri.length() - 1)) {
+                    uri = uri.substring(0, lastSlash);
+                    lastSlash = uri.lastIndexOf("/");
+                }
+
+                String namespace = uri.substring(0, lastSlash);
+                String name = uri.substring(lastSlash + 1, uri.length());
+                
+                attributeBean.setSimpleName(name);
+                attributeBean.setQualifiedName(namespace);
             }
             attributeBean.setAttributeValues(Collections.singletonList(claim.getValue()));
             attributeList.add(attributeBean);
@@ -94,5 +108,13 @@ public class ClaimsAttributeStatementPro
         return attrBean;
     }
 
+    public String getNameFormat() {
+        return nameFormat;
+    }
+
+    public void setNameFormat(String nameFormat) {
+        this.nameFormat = nameFormat;
+    }
+
 }
 



Mime
View raw message