cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1517500 - in /cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2: common/UserSubject.java utils/OAuthContextUtils.java
Date Mon, 26 Aug 2013 11:35:58 GMT
Author: sergeyb
Date: Mon Aug 26 11:35:58 2013
New Revision: 1517500

URL: http://svn.apache.org/r1517500
Log:
[CXF-5179] adding an optional id property to OAuth user subject, applying a patch on behalf
of Thorsten Hoeger

Modified:
    cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/common/UserSubject.java
    cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/OAuthContextUtils.java

Modified: cxf/trunk/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/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/common/UserSubject.java?rev=1517500&r1=1517499&r2=1517500&view=diff
==============================================================================
--- cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/common/UserSubject.java
(original)
+++ cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/common/UserSubject.java
Mon Aug 26 11:35:58 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/trunk/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/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/OAuthContextUtils.java?rev=1517500&r1=1517499&r2=1517500&view=diff
==============================================================================
--- cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/OAuthContextUtils.java
(original)
+++ cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/OAuthContextUtils.java
Mon Aug 26 11:35:58 2013
@@ -35,6 +35,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
      */



Mime
View raw message