Author: sergeyb Date: Mon Aug 26 11:48:42 2013 New Revision: 1517506 URL: http://svn.apache.org/r1517506 Log: Merged revisions 1517504 via svnmerge from https://svn.apache.org/repos/asf/cxf/branches/2.7.x-fixes
................ r1517504 | sergeyb | 2013-08-26 12:42:00 +0100 (Mon, 26 Aug 2013) | 9 lines Merged revisions 1517500 via svnmerge from https://svn.apache.org/repos/asf/cxf/trunk ........ r1517500 | sergeyb | 2013-08-26 12:35:58 +0100 (Mon, 26 Aug 2013) | 1 line [CXF-5179] adding an optional id property to OAuth user subject, applying a patch on behalf of Thorsten Hoeger ........ ................ Modified: cxf/branches/2.6.x-fixes/ (props changed) cxf/branches/2.6.x-fixes/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/common/UserSubject.java cxf/branches/2.6.x-fixes/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/OAuthContextUtils.java Propchange: cxf/branches/2.6.x-fixes/ ------------------------------------------------------------------------------ Merged /cxf/branches/2.7.x-fixes:r1517504 Merged /cxf/trunk:r1517500 Propchange: cxf/branches/2.6.x-fixes/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: cxf/branches/2.6.x-fixes/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/common/UserSubject.java URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/common/UserSubject.java?rev=1517506&r1=1517505&r2=1517506&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/common/UserSubject.java (original) +++ cxf/branches/2.6.x-fixes/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/common/UserSubject.java Mon Aug 26 11:48:42 2013 @@ -31,6 +31,7 @@ import javax.xml.bind.annotation.XmlRoot public class UserSubject { private String login; + private String id; private List<String> roles = new LinkedList<String>(); private List<Property> properties = new LinkedList<Property>(); @@ -47,6 +48,17 @@ public class UserSubject { this.roles = roles; } + public UserSubject(String login, String id) { + this.login = login; + this.id = id; + } + + public UserSubject(String login, String id, List<String> roles) { + this.login = login; + this.id = id; + this.roles = roles; + } + /** * Return the user login name * @return the login name @@ -97,5 +109,20 @@ public class UserSubject { this.properties = properties; } - + /** + * Get the user's unique id + * @return the user's id + */ + public String getId() { + return this.id; + } + + /** + * Set the users unique id + * @param id the user's id + */ + public void setId(String id) { + this.id = id; + } + } Modified: cxf/branches/2.6.x-fixes/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/OAuthContextUtils.java URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/OAuthContextUtils.java?rev=1517506&r1=1517505&r2=1517506&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/OAuthContextUtils.java (original) +++ cxf/branches/2.6.x-fixes/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/OAuthContextUtils.java Mon Aug 26 11:48:42 2013 @@ -33,6 +33,16 @@ public final class OAuthContextUtils { /** * @param mc the {@link MessageContext} + * @return the id of the UserSubject of the logged in user or resource owner + * @throws WebApplicationException with Status 401 if not authenticated + */ + public static String resolveUserId(final MessageContext mc) { + final OAuthContext oauth = getContext(mc); + return oauth.getSubject().getId(); + } + + /** + * @param mc the {@link MessageContext} * @return the name of the UserSubject of the logged in user or resource owner * @throws WebApplicationException with Status 401 if not authenticated */
