Module one.jpro.platform.auth.core
Class OAuth2AuthenticationProvider
java.lang.Object
one.jpro.platform.auth.core.oauth2.OAuth2AuthenticationProvider
- All Implemented Interfaces:
AuthenticationProvider<Credentials>
- Direct Known Subclasses:
OpenIDAuthenticationProvider
public class OAuth2AuthenticationProvider
extends Object
implements AuthenticationProvider<Credentials>
Base class for creating an OAuth2 authentication provider.
-
Constructor Summary
ConstructorsConstructorDescriptionOAuth2AuthenticationProvider(@Nullable javafx.stage.Stage stage, @NotNull OAuth2API api) Creates an OAuth2 authentication provider.OAuth2AuthenticationProvider(@Nullable javafx.stage.Stage stage, @NotNull OAuth2Options options) Creates an OAuth2 authentication provider. -
Method Summary
Modifier and TypeMethodDescriptionauthenticate(@NotNull Credentials credentials) Authenticate a user with the given credentials.authorizeUrl(@NotNull OAuth2Credentials credentials) The client sends the end-user's browser to the authorization endpoint.discover()Creates a OAuth2 authentication provider for OpenID Connect Discovery.final @NotNull OAuth2OptionsReturns the options used to configure this provider.CompletableFuture<org.json.JSONObject> introspect(User user, String tokenType) Determine the active state of an OAuth 2.0 token.Logout the user from this OAuth2 provider.Refreshes the user's access token.Revokes an obtained access or refresh token.CompletableFuture<org.json.JSONObject> Retrieve user information and other attributes for a logged-in end-user.
-
Constructor Details
-
OAuth2AuthenticationProvider
public OAuth2AuthenticationProvider(@Nullable @Nullable javafx.stage.Stage stage, @NotNull @NotNull OAuth2API api) Creates an OAuth2 authentication provider.- Parameters:
stage- the JavaFX application stageapi- the OAuth2 api
-
OAuth2AuthenticationProvider
public OAuth2AuthenticationProvider(@Nullable @Nullable javafx.stage.Stage stage, @NotNull @NotNull OAuth2Options options) Creates an OAuth2 authentication provider.- Parameters:
stage- the JavaFX application stageoptions- the OAuth2 options
-
-
Method Details
-
getOptions
Returns the options used to configure this provider.- Returns:
- an OAuth2 options object
-
authorizeUrl
The client sends the end-user's browser to the authorization endpoint. This endpoint is where the user signs in and grants access. End-user interaction is required.- Parameters:
credentials- the credentials to authenticate- Returns:
- a
CompletableFuturethat will complete with the authorization URL once the HTTP server is ready to handle the callback, or with an exception if an error occurs during the process.
-
authenticate
Authenticate a user with the given credentials.- Specified by:
authenticatein interfaceAuthenticationProvider<Credentials>- Parameters:
credentials- the credentials to authenticate- Returns:
- a future that will complete with the authenticated user
-
discover
Creates a OAuth2 authentication provider for OpenID Connect Discovery. The discovery will use the given site in the configuration options and attempt to load the well-known descriptor.- Returns:
- an
OAuth2AuthenticationProviderinstance.
-
introspect
Determine the active state of an OAuth 2.0 token.- Parameters:
user- the usertokenType- the token type to introspect- Returns:
- a
CompletableFuturewith the introspection response information in JSON format.
-
refresh
Refreshes the user's access token.- Parameters:
user- the user- Returns:
- a new user instance with the refreshed access token
- Throws:
IllegalStateException- if the user does not have a refresh token
-
revoke
Revokes an obtained access or refresh token. More info at RFC 7009.- Parameters:
user- the user to revoketokenType- the token type (eitheraccess_tokenorrefresh_token)- Returns:
- a
CompletableFuturethat completes when the token is revoked.
-
userInfo
Retrieve user information and other attributes for a logged-in end-user.- Parameters:
user- the user (access token) to fetch the user information.- Returns:
- a
CompletableFuturewith the user information in JSON format. - See Also:
-
logout
Logout the user from this OAuth2 provider.- Parameters:
user- the user to logout- Returns:
- a
CompletableFuturethat completes when the user is logged out.
-