Package org.forgerock.http.oauth2
Class OAuth2Context
- java.lang.Object
-
- org.forgerock.services.context.AbstractContext
-
- org.forgerock.http.oauth2.OAuth2Context
-
- All Implemented Interfaces:
Context
public class OAuth2Context extends AbstractContext
AnOAuth2Context
could be used to store and retrieve anAccessTokenInfo
.Once a
ResourceServerFilter
has authorized an OAuth2 request and obtained the access token's state, the access token can be stored in theOAuth2Context
in order to influence subsequent processing of the request.For example, the information provided in the AccessToken may be used for additional fine-grained authorization.
The following code illustrates how an application may store/retrieve an access token:
AccessToken accessToken = ...; Context parentContext = ...; // Create the OAuth2 context and store the access token OAuth2Context context = new OAuth2Context(parentContext, accessToken); [...] AccessToken myToken = context.asContext(OAuth2Context.class).getAccessToken();
-
-
Field Summary
-
Fields inherited from class org.forgerock.services.context.AbstractContext
data
-
-
Constructor Summary
Constructors Constructor Description OAuth2Context(JsonValue savedContext, ClassLoader classLoader)
Creates a new context from the JSON representation of a previously persisted context.OAuth2Context(Context parent, AccessTokenInfo accessToken)
Creates a new OAuth2 context with the providedAccessTokenInfo
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AccessTokenInfo
getAccessToken()
Returns the access token associated with this OAuth2 context.-
Methods inherited from class org.forgerock.services.context.AbstractContext
as, asContext, containsContext, containsContext, get, getContext, getContextName, getId, getParent, getRootId, isRootContext, toJsonValue, toString
-
-
-
-
Constructor Detail
-
OAuth2Context
public OAuth2Context(Context parent, AccessTokenInfo accessToken)
Creates a new OAuth2 context with the providedAccessTokenInfo
.- Parameters:
parent
- The parent context.accessToken
- The access token to store.
-
OAuth2Context
public OAuth2Context(JsonValue savedContext, ClassLoader classLoader)
Creates a new context from the JSON representation of a previously persisted context.- Parameters:
savedContext
- The JSON representation from which this context's attributes should be parsed.classLoader
- The ClassLoader which can properly resolve the persisted class-name.
-
-
Method Detail
-
getAccessToken
public AccessTokenInfo getAccessToken()
Returns the access token associated with this OAuth2 context.- Returns:
- the access token associated with this OAuth2 context.
-
-