cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-7201] Making it easier for custom UserInfo services to convert UserInfo to String
Date Fri, 30 Dec 2016 13:07:35 GMT
Repository: cxf
Updated Branches:
  refs/heads/master c8ee5ae67 -> d00cebe65


[CXF-7201] Making it easier for custom UserInfo services to convert UserInfo to String


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

Branch: refs/heads/master
Commit: d00cebe6578e109a6f7ca2e19066b0cb074b0ccf
Parents: c8ee5ae
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Fri Dec 30 13:05:35 2016 +0000
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Fri Dec 30 13:05:35 2016 +0000

----------------------------------------------------------------------
 .../apache/cxf/rs/security/oidc/idp/UserInfoService.java | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/d00cebe6/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 5b83a7b..4fa5df9 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
@@ -66,7 +66,7 @@ public class UserInfoService extends OAuthServerJoseJwtProducer {
             return Response.serverError().build();
         }
         
-        Object responseEntity = userInfo;
+        Object responseEntity = null;
         // UserInfo may be returned in a clear form as JSON
         if (super.isJwsRequired() || super.isJweRequired()) {
             Client client = null;
@@ -74,11 +74,20 @@ public class UserInfoService extends OAuthServerJoseJwtProducer {
                 client = oauthDataProvider.getClient(oauth.getClientId());
             }
             responseEntity = super.processJwt(new JwtToken(userInfo), client);
+        } else {
+            responseEntity = convertUserInfoToResponseEntity(userInfo);
         }
         return Response.ok(responseEntity).build();
         
     }
     
+    protected Object convertUserInfoToResponseEntity(UserInfo userInfo) {
+        // By default a JAX-RS MessageBodyWriter is expected to serialize UserInfo.
+        // Custom implementations of this method may further augment UserInfo or
+        // convert it to String: JwtUtils.claimsToJson(userInfo);
+        return userInfo;
+    }
+
     protected UserInfo createFromIdToken(IdToken idToken) {
         UserInfo userInfo = new UserInfo();
         userInfo.setSubject(idToken.getSubject());


Mime
View raw message