Class DefaultOAuth1Provider.Token
- java.lang.Object
-
- org.glassfish.jersey.server.oauth1.DefaultOAuth1Provider.Token
-
- All Implemented Interfaces:
OAuth1Token
- Enclosing class:
- DefaultOAuth1Provider
public class DefaultOAuth1Provider.Token extends java.lang.Object implements OAuth1Token
Simple immutable implementation ofOAuth1Token.
-
-
Field Summary
Fields Modifier and Type Field Description private javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String>attribsprivate java.lang.StringcallbackUrlprivate java.lang.StringconsumerKeyprivate java.security.Principalprincipalprivate java.util.Set<java.lang.String>rolesprivate java.lang.Stringsecretprivate java.lang.Stringtoken
-
Constructor Summary
Constructors Modifier Constructor Description protectedToken(java.lang.String token, java.lang.String secret, java.lang.String consumerKey, java.lang.String callbackUrl, java.security.Principal principal, java.util.Set<java.lang.String> roles, javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> attributes)Token(java.lang.String token, java.lang.String secret, java.lang.String consumerKey, java.lang.String callbackUrl, java.util.Map<java.lang.String,java.util.List<java.lang.String>> attributes)Token(java.lang.String token, java.lang.String secret, DefaultOAuth1Provider.Token requestToken)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected DefaultOAuth1Provider.Tokenauthorize(java.security.Principal principal, java.util.Set<java.lang.String> roles)Authorizes this token - i.e.javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String>getAttributes()Returns additional custom attributes associated with the token.java.lang.StringgetCallbackUrl()Returns callback URL for this token (applicable just to request tokens)OAuth1ConsumergetConsumer()Returns consumer this token was issued for.java.security.PrincipalgetPrincipal()Returns aPrincipalobject containing the name of the user the request containing this token is authorized to act on behalf of.java.lang.StringgetSecret()Returns the token secret.java.lang.StringgetToken()Returns string representing the token.booleanisInRole(java.lang.String role)Returns a boolean indicating whether this token is authorized for the specified logical "role".
-
-
-
Field Detail
-
token
private final java.lang.String token
-
secret
private final java.lang.String secret
-
consumerKey
private final java.lang.String consumerKey
-
callbackUrl
private final java.lang.String callbackUrl
-
principal
private final java.security.Principal principal
-
roles
private final java.util.Set<java.lang.String> roles
-
attribs
private final javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> attribs
-
-
Constructor Detail
-
Token
protected Token(java.lang.String token, java.lang.String secret, java.lang.String consumerKey, java.lang.String callbackUrl, java.security.Principal principal, java.util.Set<java.lang.String> roles, javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> attributes)
-
Token
public Token(java.lang.String token, java.lang.String secret, java.lang.String consumerKey, java.lang.String callbackUrl, java.util.Map<java.lang.String,java.util.List<java.lang.String>> attributes)
-
Token
public Token(java.lang.String token, java.lang.String secret, DefaultOAuth1Provider.Token requestToken)
-
-
Method Detail
-
getToken
public java.lang.String getToken()
Description copied from interface:OAuth1TokenReturns string representing the token.- Specified by:
getTokenin interfaceOAuth1Token- Returns:
- string representing the token
-
getSecret
public java.lang.String getSecret()
Description copied from interface:OAuth1TokenReturns the token secret.- Specified by:
getSecretin interfaceOAuth1Token- Returns:
- token secret
-
getConsumer
public OAuth1Consumer getConsumer()
Description copied from interface:OAuth1TokenReturns consumer this token was issued for.- Specified by:
getConsumerin interfaceOAuth1Token- Returns:
- consumer this token was issued for.
-
getAttributes
public javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> getAttributes()
Description copied from interface:OAuth1TokenReturns additional custom attributes associated with the token. If this is a request token, this should be a the same set or a defined subset of parameters that were passed to theOAuth1Provider.newRequestToken(String, String, java.util.Map)method that created this request token. If this is an access token, this is any application defined set that will included as form parameters in a response to accessToken request.- Specified by:
getAttributesin interfaceOAuth1Token- Returns:
- immutable map of custom attributes
-
getPrincipal
public java.security.Principal getPrincipal()
Description copied from interface:OAuth1TokenReturns aPrincipalobject containing the name of the user the request containing this token is authorized to act on behalf of. When the oauth filter verifies the request with this token is properly authenticated, it injects this token into a security context which then delegatesSecurityContext.getUserPrincipal()to this method.- Specified by:
getPrincipalin interfaceOAuth1Token- Returns:
- Principal corresponding to this token, or null if the token is not authorized
-
isInRole
public boolean isInRole(java.lang.String role)
Description copied from interface:OAuth1TokenReturns a boolean indicating whether this token is authorized for the specified logical "role". When the oauth filter verifies the request with this token is properly authenticated, it injects this token into a security context which then delegatesSecurityContext.isUserInRole(String)to this method.- Specified by:
isInRolein interfaceOAuth1Token- Parameters:
role- aStringspecifying the name of the role- Returns:
- a
booleanindicating whether this token is authorized for a given role
-
getCallbackUrl
public java.lang.String getCallbackUrl()
Returns callback URL for this token (applicable just to request tokens)- Returns:
- callback url
-
authorize
protected DefaultOAuth1Provider.Token authorize(java.security.Principal principal, java.util.Set<java.lang.String> roles)
Authorizes this token - i.e. generates a clone with principal and roles set to the passed values.- Parameters:
principal- Principal to add to the token.roles- Roles to add to the token.- Returns:
- Cloned token with the principal and roles set.
-
-