Package com.guinetik.rr.auth
Class OAuth2ClientCredentialsStrategy
- java.lang.Object
-
- com.guinetik.rr.auth.AbstractOAuth2Strategy
-
- com.guinetik.rr.auth.OAuth2ClientCredentialsStrategy
-
- All Implemented Interfaces:
AuthStrategy,RocketSSL.SSLAware
public class OAuth2ClientCredentialsStrategy extends AbstractOAuth2Strategy
Authentication strategy that implements OAuth 2.0 client credentials flow. This strategy gets and refreshes OAuth 2.0 access tokens using client credentials.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.guinetik.rr.auth.AuthStrategy
AuthStrategy.AuthType
-
-
Field Summary
-
Fields inherited from class com.guinetik.rr.auth.AbstractOAuth2Strategy
accessToken, additionalParams, httpClient, isRefreshing, logger, oauthTokenUrl, tokenExpiryTime
-
-
Constructor Summary
Constructors Constructor Description OAuth2ClientCredentialsStrategy(String clientId, String clientSecret, String tokenUrl)Creates a new OAuth 2.0 client credentials strategy.OAuth2ClientCredentialsStrategy(String clientId, String clientSecret, String tokenUrl, Map<String,String> additionalParams)Creates a new OAuth 2.0 client credentials strategy with additional parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AuthStrategy.AuthTypegetType()Returns the auth type of this strategy.protected Map<String,String>prepareTokenRequestParams()Prepares the parameters for the token request.protected voidvalidateCredentials()Validates that all required credentials are present.-
Methods inherited from class com.guinetik.rr.auth.AbstractOAuth2Strategy
applyAuthHeaders, configureSsl, getAccessToken, getTokenExpiryTime, needsTokenRefresh, post, processTokenResponse, refreshCredentials
-
-
-
-
Constructor Detail
-
OAuth2ClientCredentialsStrategy
public OAuth2ClientCredentialsStrategy(String clientId, String clientSecret, String tokenUrl)
Creates a new OAuth 2.0 client credentials strategy.- Parameters:
clientId- the OAuth 2.0 client IDclientSecret- the OAuth 2.0 client secrettokenUrl- the OAuth 2.0 token endpoint URL
-
OAuth2ClientCredentialsStrategy
public OAuth2ClientCredentialsStrategy(String clientId, String clientSecret, String tokenUrl, Map<String,String> additionalParams)
Creates a new OAuth 2.0 client credentials strategy with additional parameters.- Parameters:
clientId- the OAuth 2.0 client IDclientSecret- the OAuth 2.0 client secrettokenUrl- the OAuth 2.0 token endpoint URLadditionalParams- additional parameters to include in the token request
-
-
Method Detail
-
getType
public AuthStrategy.AuthType getType()
Description copied from interface:AuthStrategyReturns the auth type of this strategy.- Returns:
- the authentication type
-
validateCredentials
protected void validateCredentials()
Validates that all required credentials are present.- Specified by:
validateCredentialsin classAbstractOAuth2Strategy- Throws:
TokenRefreshException- if the client ID or client secret is not provided.
-
prepareTokenRequestParams
protected Map<String,String> prepareTokenRequestParams()
Prepares the parameters for the token request.Prepares parameters for the client credentials grant type, including grant_type, client_id, and client_secret.
- Specified by:
prepareTokenRequestParamsin classAbstractOAuth2Strategy- Returns:
- map of parameters to include in the token request
-
-