Class ClientRegistration
- java.lang.Object
-
- org.forgerock.openig.filter.oauth2.client.ClientRegistration
-
public final class ClientRegistration extends Object
A configuration for an OpenID Connect Provider. Options:
Example of use:{ "clientId" : expression, [REQUIRED] "clientSecret" : expression, [REQUIRED] "issuer" : String / Issuer [REQUIRED - the issuer name, or its inlined declaration, "scopes" : [ expressions ], [OPTIONAL - specific scopes to use for this client registration. ] "registrationHandler" : handler [OPTIONAL - by default it uses the 'ClientHandler' provided in heap.] "tokenEndpointUseBasicAuth" : boolean [OPTIONAL - default is true, use Basic Authentication.] }
or, with inlined Issuer declaration:{ "name": "MyClientRegistration", "type": "ClientRegistration", "config": { "clientId": "OpenIG", "clientSecret": "password", "scopes": [ "openid", "profile" ], "issuer": "OpenAM" } }{ "name": "MyClientRegistration", "type": "ClientRegistration", "config": { "clientId": "OpenIG", "clientSecret": "password", "scopes": [ "openid", "profile" ], "tokenEndpointUseBasicAuth": true, "issuer": { "name": "myIssuer", "type": "Issuer", "config": { "wellKnownEndpoint": "http://server.com:8090/openam/oauth2/.well-known/openid-configuration" } } } }
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classClientRegistration.HeapletCreates and initializes a Client Registration object in a heap environment.
-
Constructor Summary
Constructors Constructor Description ClientRegistration(String name, org.forgerock.json.JsonValue config, Issuer issuer, org.forgerock.http.Handler registrationHandler)Creates a Client Registration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.forgerock.util.promise.Promise<org.forgerock.json.JsonValue,OAuth2ErrorException>getAccessToken(org.forgerock.services.context.Context context, String code, String callbackUri)Exchanges the authorization code for an access token and optional ID token, and then update the session state.StringgetClientId()Returns the client ID of this client registration.IssuergetIssuer()Returns theIssuerfor this client registration.StringgetName()Returns the name of this client registration.List<String>getScopes()Returns the list of scopes of this client registration.org.forgerock.util.promise.Promise<org.forgerock.json.JsonValue,OAuth2ErrorException>getUserInfo(org.forgerock.services.context.Context context, org.forgerock.openig.filter.oauth2.client.OAuth2Session session)Returns a Promise completed either with the json value of the user info obtained from the authorization server if the response from the authorization server has a status code of 200, or with an exception, meaning the access token may have expired.org.forgerock.util.promise.Promise<org.forgerock.json.JsonValue,OAuth2ErrorException>refreshAccessToken(org.forgerock.services.context.Context context, org.forgerock.openig.filter.oauth2.client.OAuth2Session session)Refreshes the actual access token, making a refresh request to the token end-point.ClientRegistrationsetTokenEndpointUseBasicAuth(boolean useBasicAuth)Sets the authentication method the token end-point should use.
-
-
-
Constructor Detail
-
ClientRegistration
public ClientRegistration(String name, org.forgerock.json.JsonValue config, Issuer issuer, org.forgerock.http.Handler registrationHandler)
Creates a Client Registration.- Parameters:
name- The name of this client registration. Can benull. If it isnullthe name is extracted from the configuration.config- The configuration of the client registration.issuer- TheIssuerof this Client.registrationHandler- The handler used to send request to the AS.
-
-
Method Detail
-
getName
public String getName()
Returns the name of this client registration.- Returns:
- the name of this client registration.
-
getAccessToken
public org.forgerock.util.promise.Promise<org.forgerock.json.JsonValue,OAuth2ErrorException> getAccessToken(org.forgerock.services.context.Context context, String code, String callbackUri)
Exchanges the authorization code for an access token and optional ID token, and then update the session state.- Parameters:
context- The current context.code- The authorization code.callbackUri- The callback URI.- Returns:
- A promise completed with either the json content of the response if status return code of the response is 200 OK or with an OAuth2ErrorException in case of errors.
-
getClientId
public String getClientId()
Returns the client ID of this client registration.- Returns:
- the client ID.
-
getIssuer
public Issuer getIssuer()
Returns theIssuerfor this client registration.- Returns:
- the
Issuerfor this client registration.
-
refreshAccessToken
public org.forgerock.util.promise.Promise<org.forgerock.json.JsonValue,OAuth2ErrorException> refreshAccessToken(org.forgerock.services.context.Context context, org.forgerock.openig.filter.oauth2.client.OAuth2Session session)
Refreshes the actual access token, making a refresh request to the token end-point.- Parameters:
context- The current context.session- The current session.- Returns:
- A promise completed either with the JSON content of the response if status return code of the response is 200 OK, or with an OAuth2ErrorException if an error occurs when contacting the authorization server or if the returned response status code is different than 200 OK.
-
getScopes
public List<String> getScopes()
Returns the list of scopes of this client registration.- Returns:
- the the list of scopes of this client registration.
-
getUserInfo
public org.forgerock.util.promise.Promise<org.forgerock.json.JsonValue,OAuth2ErrorException> getUserInfo(org.forgerock.services.context.Context context, org.forgerock.openig.filter.oauth2.client.OAuth2Session session)
Returns a Promise completed either with the json value of the user info obtained from the authorization server if the response from the authorization server has a status code of 200, or with an exception, meaning the access token may have expired.- Parameters:
context- The current context.session- The current session to use.- Returns:
- A promise completed either with a JsonValue containing the requested user info, or with an OAuth2ErrorException if an error occurs when contacting the authorization server or if the returned response status code is different than 200 OK (That may signify that the access token has expired).
-
setTokenEndpointUseBasicAuth
public ClientRegistration setTokenEndpointUseBasicAuth(boolean useBasicAuth)
Sets the authentication method the token end-point should use.truefor 'client_secret_basic',falsefor 'client_secret_post' (not recommended).- Parameters:
useBasicAuth-trueif the token end-point should use Basic authentication,falseif it should use client secret POST.- Returns:
- This client registration.
- See Also:
- RFC 6749, Section 2.3.1
-
-