Package com.sodius.oslc.client.oauth
Class OAuthStore
java.lang.Object
com.sodius.oslc.client.oauth.OAuthStore
Stores OAuth tokens approved by a user.
One OAuthStore instance is to use for each end-user requesting OAuth connection.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classSerializable equivalent for OAuth Store to support clustered environments -
Constructor Summary
ConstructorsConstructorDescriptionOAuthStore(FriendProvider friendProvider) Instantiates a store which uses the specified provider to grant access to some friend applications.OAuthStore(String identifier, FriendProvider friendProvider) Instantiates a store which uses the specified provider to grant access to some friend applications.OAuthStore(String identifier, FriendProvider friendProvider, OAuthStore.OAuthStoreSerializable oAuthStoreSerializable) Instantiates a store which uses the specified provider to grant access to some friend applications. -
Method Summary
Modifier and TypeMethodDescriptionvoidclearAuthorization(URI resourceUri) Revokes any authorization obtained for the specified resource.getAuthorization(String httpMethod, URI resourceUri, OAuthHandler handler) Triggers the OAuth connection to the specified target resource.getExistingAuthorization(String httpMethod, URI resourceUri) Returns the known Authorization header to use for accessing specified target resource, if any.Get the serializable OAuth Store to support clustered environmentsReturns the store identifier.static voidsetVerifier(String verifierId, String verifier) Associates a verifier to an ID to approve the OAuth connection.static voidvalidate(Friend friend, RootServices rootServices) Verifies an OAuth connection can be realized for the specified friend and root services.
-
Constructor Details
-
OAuthStore
Instantiates a store which uses the specified provider to grant access to some friend applications.- Parameters:
friendProvider- provides access to friend applications.
-
OAuthStore
Instantiates a store which uses the specified provider to grant access to some friend applications.- Parameters:
identifier- the store identifier.friendProvider- provides access to friend applications.- Since:
- 2.1.0
-
OAuthStore
public OAuthStore(String identifier, FriendProvider friendProvider, OAuthStore.OAuthStoreSerializable oAuthStoreSerializable) Instantiates a store which uses the specified provider to grant access to some friend applications.- Parameters:
identifier- the store identifier.friendProvider- provides access to friend applications.oAuthStoreSerializable- OAuth Store serializable- Since:
- 2.1.0
-
-
Method Details
-
setVerifier
Associates a verifier to an ID to approve the OAuth connection. This method is typically to invoke when the OAuth callback URL has been invoked by the target application.- Parameters:
verifierId- the ID of the verifierverifier- the verifier value sent within the callback URL- See Also:
-
getAuthorization
Triggers the OAuth connection to the specified target resource. Reuses the approved OAuth connection of the target application, if any.- Parameters:
httpMethod- the HTTP method use to connect to the resource (one of "GET", "PUT", "POST" or "DELETE")resourceUri- the location of the target resourcehandler- the handler helping the realization of the OAuth connection, if the connection is not yet approved.- Returns:
- the OAuth message content to set as Authorization header in the HTTP request to access the target resource.
- Throws:
ClientRuntimeException- if no friend matches the given resource, or an OAuth problem or an I/O exception occurs
-
getExistingAuthorization
Returns the known Authorization header to use for accessing specified target resource, if any.- Parameters:
httpMethod- the HTTP method use to connect to the resource (one of "GET", "PUT", "POST" or "DELETE")resourceUri- the location of the target resource- Returns:
- the OAuth message content to set as Authorization header in the HTTP request to access the target resource,
or
nullif the OAuth connection is not yet authorized. - Throws:
ClientRuntimeException- if no friend matches the given resource, or an OAuth problem or an I/O exception occurs- Since:
- 3.4.0
-
clearAuthorization
Revokes any authorization obtained for the specified resource. This method shall be called to restart the OAuth connection on the target application.- Parameters:
resourceUri- the location of a target resource.
-
validate
public static void validate(Friend friend, RootServices rootServices) throws net.oauth.OAuthException, URISyntaxException, IOException Verifies an OAuth connection can be realized for the specified friend and root services. This method is notably useful to verify the consumer information stored in the friend are valid and recognized by the target application.- Parameters:
friend- the friend to validate.rootServices- the root services declaring the application on which the validation shall be performed.- Throws:
net.oauth.OAuthException- if the OAuth information is invalid.URISyntaxException- if a URI is invalid.IOException- if an error occurs when exchanging bytes with the application.
-
getIdentifier
Returns the store identifier.- Returns:
- the store identifier
- Since:
- 2.1.0
-
getExternalizable
Get the serializable OAuth Store to support clustered environments- Returns:
- OAuth Store Serializable
-