You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2013/06/10 17:11:10 UTC

svn commit: r1491486 - /cxf/trunk/rt/security/src/main/java/org/apache/cxf/rt/security/xacml/DefaultXACMLRequestBuilder.java

Author: coheigea
Date: Mon Jun 10 15:11:10 2013
New Revision: 1491486

URL: http://svn.apache.org/r1491486
Log:
Don't add null resources or roles to the request

Modified:
    cxf/trunk/rt/security/src/main/java/org/apache/cxf/rt/security/xacml/DefaultXACMLRequestBuilder.java

Modified: cxf/trunk/rt/security/src/main/java/org/apache/cxf/rt/security/xacml/DefaultXACMLRequestBuilder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/security/src/main/java/org/apache/cxf/rt/security/xacml/DefaultXACMLRequestBuilder.java?rev=1491486&r1=1491485&r2=1491486&view=diff
==============================================================================
--- cxf/trunk/rt/security/src/main/java/org/apache/cxf/rt/security/xacml/DefaultXACMLRequestBuilder.java (original)
+++ cxf/trunk/rt/security/src/main/java/org/apache/cxf/rt/security/xacml/DefaultXACMLRequestBuilder.java Mon Jun 10 15:11:10 2013
@@ -95,32 +95,36 @@ public class DefaultXACMLRequestBuilder 
         attributes.add(subjectIdAttribute);
         
         for (String role : roles) {
-            AttributeValueType subjectRoleAttributeValue = 
-                RequestComponentBuilder.createAttributeValueType(role);
-            AttributeType subjectRoleAttribute = 
-                RequestComponentBuilder.createAttributeType(
-                        XACMLConstants.SUBJECT_ROLE,
-                        XACMLConstants.XS_ANY_URI,
-                        issuer,
-                        Collections.singletonList(subjectRoleAttributeValue)
-                );
-            attributes.add(subjectRoleAttribute);
+            if (role != null) {
+                AttributeValueType subjectRoleAttributeValue = 
+                    RequestComponentBuilder.createAttributeValueType(role);
+                AttributeType subjectRoleAttribute = 
+                    RequestComponentBuilder.createAttributeType(
+                            XACMLConstants.SUBJECT_ROLE,
+                            XACMLConstants.XS_ANY_URI,
+                            issuer,
+                            Collections.singletonList(subjectRoleAttributeValue)
+                    );
+                attributes.add(subjectRoleAttribute);
+            }
         }
         SubjectType subjectType = RequestComponentBuilder.createSubjectType(attributes, null);
         
         // Resource
         attributes.clear();
         for (String resource : resources) {
-            AttributeValueType resourceAttributeValue = 
-                RequestComponentBuilder.createAttributeValueType(resource);
-            AttributeType resourceAttribute = 
-                RequestComponentBuilder.createAttributeType(
-                        XACMLConstants.RESOURCE_ID,
-                        XACMLConstants.XS_STRING,
-                        null,
-                        Collections.singletonList(resourceAttributeValue)
-                );
-            attributes.add(resourceAttribute);
+            if (resource != null) {
+                AttributeValueType resourceAttributeValue = 
+                    RequestComponentBuilder.createAttributeValueType(resource);
+                AttributeType resourceAttribute = 
+                    RequestComponentBuilder.createAttributeType(
+                            XACMLConstants.RESOURCE_ID,
+                            XACMLConstants.XS_STRING,
+                            null,
+                            Collections.singletonList(resourceAttributeValue)
+                    );
+                attributes.add(resourceAttribute);
+            }
         }
         ResourceType resourceType = RequestComponentBuilder.createResourceType(attributes, null);