cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject [2/2] cxf git commit: Make it easier to specify additional claims to return in the UserInfoService
Date Wed, 20 Jul 2016 13:41:58 GMT
Make it easier to specify additional claims to return in the UserInfoService


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

Branch: refs/heads/master
Commit: ce2d945bf62d77b8263790c8c8d7c4cdd36c0176
Parents: 689632b
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Wed Jul 20 14:39:55 2016 +0100
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Wed Jul 20 14:41:52 2016 +0100

----------------------------------------------------------------------
 .../rs/security/oidc/idp/UserInfoService.java   | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/ce2d945b/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/idp/UserInfoService.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/idp/UserInfoService.java
b/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/idp/UserInfoService.java
index 7c4ec07..5b83a7b 100644
--- a/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/idp/UserInfoService.java
+++ b/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/idp/UserInfoService.java
@@ -18,6 +18,9 @@
  */
 package org.apache.cxf.rs.security.oidc.idp;
 
+import java.util.Collections;
+import java.util.List;
+
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
@@ -39,6 +42,7 @@ import org.apache.cxf.rs.security.oidc.common.UserInfo;
 public class UserInfoService extends OAuthServerJoseJwtProducer {
     private UserInfoProvider userInfoProvider;
     private OAuthDataProvider oauthDataProvider;
+    private List<String> additionalClaims = Collections.emptyList();
     
     @Context
     private MessageContext mc;
@@ -101,6 +105,15 @@ public class UserInfoService extends OAuthServerJoseJwtProducer {
         if (idToken.getNickName() != null) {
             userInfo.setNickName(idToken.getNickName());
         }
+        
+        if (additionalClaims != null && !additionalClaims.isEmpty()) {
+            for (String additionalClaim : additionalClaims) {
+                if (idToken.containsProperty(additionalClaim)) {
+                    userInfo.setClaim(additionalClaim, idToken.getClaim(additionalClaim));
+                }
+            }
+        }
+        
         //etc
         return userInfo;
     }
@@ -112,4 +125,11 @@ public class UserInfoService extends OAuthServerJoseJwtProducer {
     public void setOauthDataProvider(OAuthDataProvider oauthDataProvider) {
         this.oauthDataProvider = oauthDataProvider;
     }
+
+    /**
+     * Set additional claims to return (if they exist in the IdToken).
+     */
+    public void setAdditionalClaims(List<String> additionalClaims) {
+        this.additionalClaims = additionalClaims;
+    }
 }


Mime
View raw message