Repository: cxf Updated Branches: refs/heads/master 4719a033d -> cd782fef1
Updating Dynamic reg service to check if the user credentials have been provided Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/cd782fef Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/cd782fef Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/cd782fef Branch: refs/heads/master Commit: cd782fef123d2147a6f5cb04fb6cdfe8cf0ac81a Parents: 4719a03 Author: Sergey Beryozkin <[email protected]> Authored: Thu Mar 9 17:28:36 2017 +0000 Committer: Sergey Beryozkin <[email protected]> Committed: Thu Mar 9 17:28:36 2017 +0000 ---------------------------------------------------------------------- .../security/oauth2/services/DynamicRegistrationService.java | 8 ++++++++ 1 file changed, 8 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/cd782fef/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/DynamicRegistrationService.java ---------------------------------------------------------------------- diff --git a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/DynamicRegistrationService.java b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/DynamicRegistrationService.java index 9b0d63f..7af9993 100644 --- a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/DynamicRegistrationService.java +++ b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/DynamicRegistrationService.java @@ -32,6 +32,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Context; import javax.ws.rs.core.Response; +import javax.ws.rs.core.SecurityContext; import javax.ws.rs.core.UriBuilder; import org.apache.cxf.common.util.Base64UrlUtility; @@ -39,6 +40,7 @@ import org.apache.cxf.common.util.StringUtils; import org.apache.cxf.jaxrs.ext.MessageContext; import org.apache.cxf.jaxrs.utils.ExceptionUtils; import org.apache.cxf.rs.security.oauth2.common.Client; +import org.apache.cxf.rs.security.oauth2.common.UserSubject; import org.apache.cxf.rs.security.oauth2.provider.ClientRegistrationProvider; import org.apache.cxf.rs.security.oauth2.utils.AuthorizationUtils; import org.apache.cxf.rs.security.oauth2.utils.OAuthConstants; @@ -261,6 +263,12 @@ public class DynamicRegistrationService { // Add more typed properties like tosUri, policyUri, etc to Client // or set them as Client extra properties + SecurityContext sc = mc.getSecurityContext(); + if (sc != null && sc.getUserPrincipal() != null && sc.getUserPrincipal().getName() != null) { + UserSubject subject = new UserSubject(sc.getUserPrincipal().getName()); + newClient.setResourceOwnerSubject(subject); + } + newClient.setRegisteredDynamically(true); return newClient; }
