Interface RestAuthConfig

All Known Implementing Classes:
RestAuthConfig.ApiKeyAuth, RestAuthConfig.BasicAuth, RestAuthConfig.BearerAuth, RestAuthConfig.CustomAuth, RestAuthConfig.NoAuth, RestAuthConfig.OAuth2ClientCredentials, RestAuthConfig.OAuth2Password

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
  • Method Details

    • getAuthType

      RestAuthenticationType getAuthType()
      Gets the authentication type for this configuration.
      Returns:
      The authentication type
    • getAuthHeaders

      Map<String,String> getAuthHeaders()
      Generates the HTTP headers required for this authentication.
      Returns:
      Map of header name to header value
    • getAuthQueryParams

      default Map<String,String> getAuthQueryParams()
      Gets any query parameters required for this authentication.
      Returns:
      Map of parameter name to parameter value
    • none

      static RestAuthConfig.NoAuth none()
      Creates an empty/no authentication configuration.
      Returns:
      NoAuth instance
    • basic

      static RestAuthConfig.BasicAuth basic(String username, String password)
      Creates a basic authentication configuration.
      Parameters:
      username - The username
      password - The password
      Returns:
      BasicAuth instance
    • bearer

      static RestAuthConfig.BearerAuth bearer(String token)
      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/parameter
      keyValue - The API key value
      location - 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 URL
      clientId - The client ID
      clientSecret - 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 configuration
      logger - Optional logger for warnings
      Returns:
      The parsed RestAuthConfig