Class DefaultOpenIdConnectClient
java.lang.Object
com.aquima.web.boot.security.openid.DefaultOpenIdConnectClient
- All Implemented Interfaces:
OpenIdConnectClient
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultOpenIdConnectClient
(org.springframework.web.client.RestTemplate restTemplate, OpenIdConnectSettings openIdConnectSettings) -
Method Summary
Modifier and TypeMethodDescriptionexchangeCodeForToken
(String authorizationCode, String redirectUri) Performs the exchange step in the OpenID Connect Authorization Code flow: exchanges an authorization code for id, access and (optionally) refresh tokens.getToken()
Obtains an access token and (optionally) a refresh token using the OpenID Connect Client Credentials flow.getUserInfo
(String encodedAccessToken) Obtains information about the user for whom the given access token was granted.
-
Constructor Details
-
DefaultOpenIdConnectClient
public DefaultOpenIdConnectClient(org.springframework.web.client.RestTemplate restTemplate, OpenIdConnectSettings openIdConnectSettings)
-
-
Method Details
-
exchangeCodeForToken
public TokenResponse exchangeCodeForToken(String authorizationCode, String redirectUri) throws OpenIdConnectException, IOException Description copied from interface:OpenIdConnectClient
Performs the exchange step in the OpenID Connect Authorization Code flow: exchanges an authorization code for id, access and (optionally) refresh tokens.- Specified by:
exchangeCodeForToken
in interfaceOpenIdConnectClient
- Parameters:
authorizationCode
- the authorization code to be exchanged for tokensredirectUri
- the redirect_uri parameter that was used to obtain the authorization code- Returns:
- the tokens returned by the identity provider
- Throws:
OpenIdConnectException
- when the identity provider returns an errorIOException
- when there is an error communicating with the identity provider
-
getToken
Description copied from interface:OpenIdConnectClient
Obtains an access token and (optionally) a refresh token using the OpenID Connect Client Credentials flow.This method uses the configured client id and client secret to authenticate with the identity provider. The client must be authorized to use the client credentials flow.
- Specified by:
getToken
in interfaceOpenIdConnectClient
- Returns:
- the tokens returned by the identity provider
- Throws:
OpenIdConnectException
- when the identity provider returns an errorIOException
- when there us an error communicating with the identity provider
-
getUserInfo
public UserInfoResponse getUserInfo(String encodedAccessToken) throws OpenIdConnectException, IOException Description copied from interface:OpenIdConnectClient
Obtains information about the user for whom the given access token was granted.- Specified by:
getUserInfo
in interfaceOpenIdConnectClient
- Parameters:
encodedAccessToken
- an encoded access token- Returns:
- information about the user, as provided by the OpenID Connect Identity Provider
- Throws:
OpenIdConnectException
- when the identity provider returns an errorIOException
- when there is an error communicating with the identity provider
-