Interface RestAuthConfig
- All Known Implementing Classes:
RestAuthConfig.ApiKeyAuth,RestAuthConfig.BasicAuth,RestAuthConfig.BearerAuth,RestAuthConfig.CustomAuth,RestAuthConfig.NoAuth,RestAuthConfig.OAuth2ClientCredentials,RestAuthConfig.OAuth2Password
public sealed interface RestAuthConfig
permits RestAuthConfig.NoAuth, RestAuthConfig.BasicAuth, RestAuthConfig.BearerAuth, RestAuthConfig.ApiKeyAuth, RestAuthConfig.OAuth2ClientCredentials, RestAuthConfig.OAuth2Password, RestAuthConfig.CustomAuth
Sealed interface representing authentication configuration for REST services.
This interface defines the contract for all authentication configuration types.
Each implementation corresponds to a specific RestAuthenticationType.
- Since:
- 1.0
- Author:
- Bonitasoft
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordAPI Key authentication configuration.static final recordHTTP Basic Authentication configuration.static final recordBearer token authentication configuration.static final recordCustom authentication with user-defined headers.static final recordNo authentication configuration.static final recordOAuth 2.0 Client Credentials authentication configuration.static final recordOAuth 2.0 Resource Owner Password authentication configuration. -
Method Summary
Modifier and TypeMethodDescriptionstatic RestAuthConfig.ApiKeyAuthapiKey(String keyName, String keyValue, RestApiKeyLocation location) Creates an API key authentication configuration.static RestAuthConfig.BasicAuthCreates a basic authentication configuration.static RestAuthConfig.BearerAuthCreates a bearer token authentication configuration.static RestAuthConfigfromJson(com.fasterxml.jackson.databind.JsonNode authNode, org.slf4j.Logger logger) Parses authentication configuration from JSON.Generates the HTTP headers required for this authentication.Gets any query parameters required for this authentication.Gets the authentication type for this configuration.static RestAuthConfig.NoAuthnone()Creates an empty/no authentication configuration.oauth2ClientCredentials(String tokenUrl, String clientId, String clientSecret) Creates an OAuth2 Client Credentials configuration.
-
Method Details
-
getAuthType
RestAuthenticationType getAuthType()Gets the authentication type for this configuration.- Returns:
- The authentication type
-
getAuthHeaders
Generates the HTTP headers required for this authentication.- Returns:
- Map of header name to header value
-
getAuthQueryParams
Gets any query parameters required for this authentication.- Returns:
- Map of parameter name to parameter value
-
none
Creates an empty/no authentication configuration.- Returns:
- NoAuth instance
-
basic
Creates a basic authentication configuration.- Parameters:
username- The usernamepassword- The password- Returns:
- BasicAuth instance
-
bearer
Creates a bearer token authentication configuration.- Parameters:
token- The bearer token- Returns:
- BearerAuth instance
-
apiKey
static RestAuthConfig.ApiKeyAuth apiKey(String keyName, String keyValue, RestApiKeyLocation location) Creates an API key authentication configuration.- Parameters:
keyName- The name of the API key header/parameterkeyValue- The API key valuelocation- Where to send the key (HEADER or QUERY_PARAM)- Returns:
- ApiKeyAuth instance
-
oauth2ClientCredentials
static RestAuthConfig.OAuth2ClientCredentials oauth2ClientCredentials(String tokenUrl, String clientId, String clientSecret) Creates an OAuth2 Client Credentials configuration.- Parameters:
tokenUrl- The token endpoint URLclientId- The client IDclientSecret- The client secret- Returns:
- OAuth2ClientCredentials instance
-
fromJson
static RestAuthConfig fromJson(com.fasterxml.jackson.databind.JsonNode authNode, org.slf4j.Logger logger) Parses authentication configuration from JSON.- Parameters:
authNode- The JSON node containing auth configurationlogger- Optional logger for warnings- Returns:
- The parsed RestAuthConfig
-