cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject [2/2] git commit: [CXF-5925] Adding multi-value role claim support to CustomClaimsHandler
Date Thu, 21 Aug 2014 16:29:27 GMT
[CXF-5925] Adding multi-value role claim support to CustomClaimsHandler


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/1805027c
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/1805027c
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/1805027c

Branch: refs/heads/master
Commit: 1805027c9ce9925fb875e92fc5314aa826632151
Parents: d1995a4
Author: Jan Bernhardt <jbernhardt@talend.com>
Authored: Mon Aug 11 22:31:05 2014 +0200
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Thu Aug 21 17:28:52 2014 +0100

----------------------------------------------------------------------
 .../apache/cxf/sts/common/CustomClaimsHandler.java   | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/1805027c/services/sts/sts-core/src/test/java/org/apache/cxf/sts/common/CustomClaimsHandler.java
----------------------------------------------------------------------
diff --git a/services/sts/sts-core/src/test/java/org/apache/cxf/sts/common/CustomClaimsHandler.java
b/services/sts/sts-core/src/test/java/org/apache/cxf/sts/common/CustomClaimsHandler.java
index 3f533dc..e1e312d 100644
--- a/services/sts/sts-core/src/test/java/org/apache/cxf/sts/common/CustomClaimsHandler.java
+++ b/services/sts/sts-core/src/test/java/org/apache/cxf/sts/common/CustomClaimsHandler.java
@@ -96,11 +96,18 @@ public class CustomClaimsHandler implements ClaimsHandler {
                     claim.addValue(attributeValue);
 
                 } else if (ROLE_CLAIM.equals(requestClaim.getClaimType())) {
-                    String requestedRole = (String)requestClaim.getValues().get(0);
-                    if (isUserInRole(parameters.getPrincipal(), requestedRole)) {
-                        claim.addValue(requestedRole);
+                    if (requestClaim.getValues().size() > 0) {
+                        for (Object requestedRole : requestClaim.getValues()) {
+                            if (isUserInRole(parameters.getPrincipal(), requestedRole.toString()))
{
+                                claim.addValue(requestedRole);
+                            }
+                        }
+                        if (claim.getValues().size() == 0) {
+                            continue;
+                        }
                     } else {
-                        continue;
+                        // If no specific role was requested return DUMMY role for user 
+                        claim.addValue("DUMMY");
                     }
                 }                
                 claimCollection.add(claim);


Mime
View raw message