Repository: cxf Updated Branches: refs/heads/3.1.x-fixes d83a99912 -> b0f9492ba
[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/b0f9492b Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/b0f9492b Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/b0f9492b Branch: refs/heads/3.1.x-fixes Commit: b0f9492ba1792247a9370f9ec132a646bf77e6e3 Parents: d83a999 Author: Sergey Beryozkin <[email protected]> Authored: Fri Dec 30 13:05:35 2016 +0000 Committer: Sergey Beryozkin <[email protected]> Committed: Fri Dec 30 13:08:38 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/b0f9492b/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());
