Class OidcService
- Direct Known Subclasses:
GoogleService
This class implements an OpenID Connect client (core specification), which can be used to allow the user to be safely authenticated with your web application without needing to store or even handle his authorization credentials (such as a password).
OpenID Connect is a simple identity layer on top of the OAuth 2.0 protocol. It enables Clients to verify the identity of the End-User based on the authentication performed by an Authorization Server, as well as to obtain basic profile information about the End-User in an interoperable and REST-like manner.
This implementation only supports authentication using the Authorization Code Flow.
The configuration of this service is done by using the setters the service class exposes. Before the authentication process can be started these settings must be configured first and may not be changed afterwards.
The OpenID Connect protocol, including the subsequent use for authentication, consists of a
number of consecutive steps, some of which require user interaction, and some which require the
use of remote web services. The state machine for this process is implemented in an OidcProcess
. To use OpenID Connect, you need to create such a process and listen for state
changes.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncreateProcess
(String scope) Creates a new authentication process.Returns the scope needed for authentication.Returns the authorization endpoint URL.Returns the client ID.Returns the client secret.Returns the method to transfer the client secret.Returns the provider description.getName()
Returns the provider name.int
Returns the desired height of the popup window.int
Returns the desired width for the popup window.Returns the redirection endpoint URL.Returns the token endpoint URL.Returns the user info endpoint URL.void
setAuthEndpoint
(String url) Sets the authorization endpoint URL.void
setAuthenticationScope
(String scope) Sets the scope needed for authentication.void
setClientId
(String id) Sets the client ID.void
setClientSecret
(String secret) Sets the client secret.void
Sets the method to transfer the client secret.void
setDescription
(String description) Sets the provider description.void
Sets the provider name.void
setPopupHeight
(int height) Sets the desired height for the popup window.void
setPopupWidth
(int width) Sets the desired width for the popup window.void
Sets the redirection endpoint URL.void
setTokenEndpoint
(String url) Sets the token endpoint URL.void
Sets the user info endpoint URL.Methods inherited from class eu.webtoolkit.jwt.auth.OAuthService
configurationProperty, configureRedirectEndpoint, decodeState, encodeState, getBaseAuth, getGenerateRedirectEndpoint, getRedirectEndpointPath, getRedirectInternalPath, getTokenRequestMethod, isPopupEnabled, setPopupEnabled
-
Constructor Details
-
OidcService
Constructor.
-
-
Method Details
-
getName
Returns the provider name.This is a short identifier.
- Specified by:
getName
in classOAuthService
- See Also:
-
getDescription
Returns the provider description.This returns a description useful for e.g. tool tips on a login icon.
- Specified by:
getDescription
in classOAuthService
- See Also:
-
getPopupWidth
public int getPopupWidth()Returns the desired width for the popup window.Defaults to 670 pixels.
- Specified by:
getPopupWidth
in classOAuthService
- See Also:
-
getPopupHeight
public int getPopupHeight()Returns the desired height of the popup window.Defaults to 400 pixels.
- Specified by:
getPopupHeight
in classOAuthService
- See Also:
-
getAuthenticationScope
Returns the scope needed for authentication.This returns the scope that is needed (and sufficient) for obtaining identity information, and thus to authenticate the user.
This defaults to "openid".
- Specified by:
getAuthenticationScope
in classOAuthService
- See Also:
-
getRedirectEndpoint
Returns the redirection endpoint URL.This is the local URL to which the browser is redirect from the service provider, after the authorization process. You need to configure this URL with the third party authentication service.
A static resource will be deployed at this URL.
- Specified by:
getRedirectEndpoint
in classOAuthService
- See Also:
-
getAuthorizationEndpoint
Returns the authorization endpoint URL.This is a remote URL which hosts the OpenID Connect authorization user interface. This URL is loaded in the popup window at the start of an authorization process.
- Specified by:
getAuthorizationEndpoint
in classOAuthService
- See Also:
-
getTokenEndpoint
Returns the token endpoint URL.This is a remote URL which hosts a web-service that generates access and id tokens.
- Specified by:
getTokenEndpoint
in classOAuthService
- See Also:
-
getUserInfoEndpoint
Returns the user info endpoint URL.This is a remote URL which hosts a web-service that provides the claims that are associated with the requested scope.
- Overrides:
getUserInfoEndpoint
in classOAuthService
- See Also:
-
getClientId
Returns the client ID.This is the identification for this web application with the OpenID Connect provider.
- Specified by:
getClientId
in classOAuthService
- See Also:
-
getClientSecret
Returns the client secret.This is the secret credentials for this web application with the OpenID Connect provider.
- Specified by:
getClientSecret
in classOAuthService
- See Also:
-
getClientSecretMethod
Returns the method to transfer the client secret.The default implementation returns HttpAuthorizationBasic (the recommended method).
- Specified by:
getClientSecretMethod
in classOAuthService
-
createProcess
Creates a new authentication process.This creates a new authentication process for the indicated scope. Valid names for the scope are service provider dependent.
The service needs to be correctly configured before being able to call this function. configure() needs to be called first to check if the configuration is valid.
Note: The returned process will be an instance of
OidcService
- Specified by:
createProcess
in classOAuthService
- See Also:
-
setRedirectEndpoint
Sets the redirection endpoint URL. -
setClientId
Sets the client ID.This setting is required.
- See Also:
-
setClientSecret
Sets the client secret.This setting is required.
- See Also:
-
setAuthEndpoint
Sets the authorization endpoint URL.This setting is required.
- See Also:
-
setTokenEndpoint
Sets the token endpoint URL.This setting is required.
- See Also:
-
setUserInfoEndpoint
Sets the user info endpoint URL.This setting is required.
- See Also:
-
setAuthenticationScope
Sets the scope needed for authentication.This setting is required.
- See Also:
-
setName
Sets the provider name.- See Also:
-
setDescription
Sets the provider description.This setting is required.
- See Also:
-
setClientSecretMethod
Sets the method to transfer the client secret.- See Also:
-
setPopupWidth
public void setPopupWidth(int width) Sets the desired width for the popup window.- See Also:
-
setPopupHeight
public void setPopupHeight(int height) Sets the desired height for the popup window.- See Also:
-