java.lang.Object
one.jpro.platform.auth.core.oauth2.OAuth2Options
All Implemented Interfaces:
Options

public class OAuth2Options extends Object implements Options
This class represents the configuration options for OAuth2 authentication and authorization. It encapsulates a variety of settings and parameters that are used during the OAuth2 flow, including client credentials, token and authorization endpoints, supported response types, and other custom configurations required for OAuth2 operations.

Instances of OAuth2Options can be customized to suit specific OAuth2 workflows, allowing for the setup of different authentication and authorization schemes, like authorization code flow, client credentials flow, or implicit flow. It also supports various advanced configurations such as custom headers, JWT options, and public/secret keys. To ensure that all necessary OAuth2 parameters are correctly configured, it provides utility methods to validate and adjust the configurations as needed.

  • Constructor Details

    • OAuth2Options

      public OAuth2Options()
      Default constructor.
    • OAuth2Options

      public OAuth2Options(OAuth2Options other)
      Copy constructor.
      Parameters:
      other - the OAuth2 options to copy
  • Method Details

    • getFlow

      public OAuth2Flow getFlow()
      Gets the OAuth2 flow type.
      Returns:
      the current OAuth2 flow
    • setFlow

      public OAuth2Options setFlow(OAuth2Flow flow)
      Sets the OAuth2 flow type.
      Parameters:
      flow - the OAuth2 flow to set
      Returns:
      the current instance of OAuth2Options for method chaining
    • getSupportedResponseTypes

      public List<String> getSupportedResponseTypes()
      Gets the supported response types.
      Returns:
      a list of supported response types
    • setSupportedResponseTypes

      public OAuth2Options setSupportedResponseTypes(List<String> supportedResponseTypes)
      Sets the supported response types.
      Parameters:
      supportedResponseTypes - a list of supported response types to set
      Returns:
      the current instance of OAuth2Options for method chaining
    • addSupportedResponseType

      public OAuth2Options addSupportedResponseType(String supportedResponseType)
      Adds a supported response type to the existing list.
      Parameters:
      supportedResponseType - a supported response type to add
      Returns:
      the current instance of OAuth2Options for method chaining
    • getSupportedResponseModes

      public List<String> getSupportedResponseModes()
      Gets the supported response modes.
      Returns:
      a list of supported response modes
    • setSupportedResponseModes

      public OAuth2Options setSupportedResponseModes(List<String> supportedResponseModes)
      Sets the supported response modes.
      Parameters:
      supportedResponseModes - a list of supported response modes to set
      Returns:
      the current instance of OAuth2Options for method chaining
    • addSupportedResponseMode

      public OAuth2Options addSupportedResponseMode(String supportedResponseMode)
      Adds a supported response mode to the existing list.
      Parameters:
      supportedResponseMode - a supported response mode to add
      Returns:
      the current instance of OAuth2Options for method chaining
    • getSupportedGrantTypes

      public List<String> getSupportedGrantTypes()
      Gets the supported grant types.
      Returns:
      a list of supported grant types
    • setSupportedGrantTypes

      public OAuth2Options setSupportedGrantTypes(List<String> supportedGrantTypes)
      Sets the supported grant types.
      Parameters:
      supportedGrantTypes - a list of supported grant types to set
      Returns:
      the current instance of OAuth2Options for method chaining
    • addSupportedGrantType

      public OAuth2Options addSupportedGrantType(String supportedGrantType)
      Adds a supported grant type to the existing list.
      Parameters:
      supportedGrantType - a supported grant type to add
      Returns:
      the current instance of OAuth2Options for method chaining
    • getSupportedSubjectTypes

      public List<String> getSupportedSubjectTypes()
      Gets the supported subject types.
      Returns:
      a list of supported subject types
    • setSupportedSubjectTypes

      public OAuth2Options setSupportedSubjectTypes(List<String> supportedSubjectTypes)
      Sets the supported subject types.
      Parameters:
      supportedSubjectTypes - a list of supported subject types to set
      Returns:
      the current instance of OAuth2Options for method chaining
    • addSupportedSubjectType

      public OAuth2Options addSupportedSubjectType(String supportedSubjectType)
      Adds a supported subject type to the existing list.
      Parameters:
      supportedSubjectType - a supported subject type to add
      Returns:
      the current instance of OAuth2Options for method chaining
    • getSupportedIdTokenSigningAlgValues

      public List<String> getSupportedIdTokenSigningAlgValues()
      Gets the supported ID token signing algorithm values.
      Returns:
      a list of supported ID token signing algorithm values
    • setSupportedIdTokenSigningAlgValues

      public OAuth2Options setSupportedIdTokenSigningAlgValues(List<String> supportedIdTokenSigningAlgValues)
      Sets the supported ID token signing algorithm values.
      Parameters:
      supportedIdTokenSigningAlgValues - a list of supported ID token signing algorithm values to set
      Returns:
      the current instance of OAuth2Options for method chaining
    • addSupportedIdTokenSigningAlgValue

      public OAuth2Options addSupportedIdTokenSigningAlgValue(String supportedIdTokenSigningAlgValue)
      Adds a supported ID token signing algorithm value to the existing list.
      Parameters:
      supportedIdTokenSigningAlgValue - a supported ID token signing algorithm value to add
      Returns:
      the current instance of OAuth2Options for method chaining
    • getSupportedScopes

      public List<String> getSupportedScopes()
      Gets the supported scopes.
      Returns:
      a list of supported scopes
    • setSupportedScopes

      public OAuth2Options setSupportedScopes(List<String> supportedScopes)
      Sets the supported scopes.
      Parameters:
      supportedScopes - a list of supported scopes to set
      Returns:
      the current instance of OAuth2Options for method chaining
    • addSupportedScope

      public OAuth2Options addSupportedScope(String supportedScope)
      Adds a supported scope to the existing list.
      Parameters:
      supportedScope - a supported scope to add
      Returns:
      the current instance of OAuth2Options for method chaining
    • getSupportedTokenEndpointAuthMethods

      public List<String> getSupportedTokenEndpointAuthMethods()
      Gets the supported token endpoint authentication methods.
      Returns:
      a list of supported token endpoint authentication methods
    • setSupportedTokenEndpointAuthMethods

      public OAuth2Options setSupportedTokenEndpointAuthMethods(List<String> supportedTokenEndpointAuthMethods)
      Sets the supported token endpoint authentication methods.
      Parameters:
      supportedTokenEndpointAuthMethods - a list of supported token endpoint authentication methods to set
      Returns:
      the current instance of OAuth2Options for method chaining
    • addSupportedTokenEndpointAuthMethod

      public OAuth2Options addSupportedTokenEndpointAuthMethod(String supportedTokenEndpointAuthMethod)
      Adds a supported token endpoint authentication method to the existing list.
      Parameters:
      supportedTokenEndpointAuthMethod - a supported token endpoint authentication method to add
      Returns:
      the current instance of OAuth2Options for method chaining
    • getSupportedClaims

      public List<String> getSupportedClaims()
      Gets the supported claims.
      Returns:
      a list of supported claims
    • setSupportedClaims

      public OAuth2Options setSupportedClaims(List<String> supportedClaims)
      Sets the supported claims.
      Parameters:
      supportedClaims - a list of supported claims to set
      Returns:
      the current instance of OAuth2Options for method chaining
    • addSupportedClaim

      public OAuth2Options addSupportedClaim(String supportedClaim)
      Adds a supported claim to the existing list.
      Parameters:
      supportedClaim - a supported claim to add
      Returns:
      the current instance of OAuth2Options for method chaining
    • getSupportedCodeChallengeMethods

      public List<String> getSupportedCodeChallengeMethods()
      Gets the supported code challenge methods.
      Returns:
      a list of supported code challenge methods
    • setSupportedCodeChallengeMethods

      public OAuth2Options setSupportedCodeChallengeMethods(List<String> supportedCodeChallengeMethods)
      Sets the supported code challenge methods.
      Parameters:
      supportedCodeChallengeMethods - a list of supported code challenge methods to set
      Returns:
      the current instance of OAuth2Options for method chaining
    • addSupportedCodeChallengeMethod

      public OAuth2Options addSupportedCodeChallengeMethod(String supportedCodeChallengeMethod)
      Adds a supported code challenge method to the existing list.
      Parameters:
      supportedCodeChallengeMethod - a supported code challenge method to add
      Returns:
      the current instance of OAuth2Options for method chaining
    • getSupportedIntrospectionEndpointAuthMethods

      public List<String> getSupportedIntrospectionEndpointAuthMethods()
      Gets the supported introspection endpoint authentication methods.
      Returns:
      a list of supported introspection endpoint authentication methods
    • setSupportedIntrospectionEndpointAuthMethods

      public OAuth2Options setSupportedIntrospectionEndpointAuthMethods(List<String> supportedIntrospectionEndpointAuthMethods)
      Sets the supported introspection endpoint authentication methods.
      Parameters:
      supportedIntrospectionEndpointAuthMethods - a list of supported introspection endpoint authentication methods to set
      Returns:
      the current instance of OAuth2Options for method chaining
    • addSupportedIntrospectionEndpointAuthMethod

      public OAuth2Options addSupportedIntrospectionEndpointAuthMethod(String supportedIntrospectionEndpointAuthMethod)
      Adds a supported introspection endpoint authentication method to the existing list.
      Parameters:
      supportedIntrospectionEndpointAuthMethod - a supported introspection endpoint authentication method to add
      Returns:
      the current instance of OAuth2Options for method chaining
    • getSupportedRevocationEndpointAuthMethods

      public List<String> getSupportedRevocationEndpointAuthMethods()
      Gets the supported revocation endpoint authentication methods.
      Returns:
      a list of supported revocation endpoint authentication methods
    • setSupportedRevocationEndpointAuthMethods

      public OAuth2Options setSupportedRevocationEndpointAuthMethods(List<String> supportedRevocationEndpointAuthMethods)
      Sets the supported revocation endpoint authentication methods.
      Parameters:
      supportedRevocationEndpointAuthMethods - a list of supported revocation endpoint authentication methods to set
      Returns:
      the current instance of OAuth2Options for method chaining
    • addSupportedRevocationEndpointAuthMethod

      public OAuth2Options addSupportedRevocationEndpointAuthMethod(String supportedRevocationEndpointAuthMethod)
      Adds a supported revocation endpoint authentication method to the existing list.
      Parameters:
      supportedRevocationEndpointAuthMethod - a supported revocation endpoint authentication method to add
      Returns:
      the current instance of OAuth2Options for method chaining
    • isSupportedRequestParameter

      public boolean isSupportedRequestParameter()
      Checks if the request parameter is supported.
      Returns:
      true if the request parameter is supported, otherwise false.
    • setSupportedRequestParameter

      public OAuth2Options setSupportedRequestParameter(boolean supportedRequestParameter)
      Sets whether the request parameter is supported.
      Parameters:
      supportedRequestParameter - a boolean indicating whether the request parameter is supported
      Returns:
      the current instance of OAuth2Options for method chaining
    • getSupportedRequestObjectSigningAlgValues

      public List<String> getSupportedRequestObjectSigningAlgValues()
      Gets the supported request object signing algorithm values.
      Returns:
      a list of supported request object signing algorithm values
    • setSupportedRequestObjectSigningAlgValues

      public OAuth2Options setSupportedRequestObjectSigningAlgValues(List<String> supportedRequestObjectSigningAlgValues)
      Sets the supported request object signing algorithm values.
      Parameters:
      supportedRequestObjectSigningAlgValues - a list of supported request object signing algorithm values to set
      Returns:
      the current instance of OAuth2Options for method chaining
    • addSupportedRequestObjectSigningAlgValue

      public OAuth2Options addSupportedRequestObjectSigningAlgValue(String supportedRequestObjectSigningAlgValue)
      Adds a supported request object signing algorithm value to the existing list.
      Parameters:
      supportedRequestObjectSigningAlgValue - a supported request object signing algorithm value to add
      Returns:
      the current instance of OAuth2Options for method chaining
    • getAuthorizationPath

      public String getAuthorizationPath()
      Returns the URL of the authorization server's authorization endpoint.
      Returns:
      a URL as a string
    • setAuthorizationPath

      public OAuth2Options setAuthorizationPath(String authorizationPath)
      Sets the URL of the authorization server's authorization endpoint.
      Parameters:
      authorizationPath - a URL as a string
    • getTokenPath

      public String getTokenPath()
      Returns the URL of the authorization server's token endpoint.
      Returns:
      a URL as a string
    • setTokenPath

      public OAuth2Options setTokenPath(String tokenPath)
      Sets the URL of the authorization server's token endpoint.
      Parameters:
      tokenPath - a URL as a string
    • getRevocationPath

      public String getRevocationPath()
      Returns the URL of the authorization server's revocation endpoint.
      Returns:
      a URL as a string
    • setRevocationPath

      public OAuth2Options setRevocationPath(String revocationPath)
      Sets the URL of the authorization server's revocation endpoint.
      Parameters:
      revocationPath - a URL as a string
    • getScopeSeparator

      public String getScopeSeparator()
      Gets the scope separator used in OAuth2 requests.
      Returns:
      the scope separator as a string
    • setScopeSeparator

      public OAuth2Options setScopeSeparator(String scopeSeparator)
      Sets the scope separator to be used in OAuth2 requests.
      Parameters:
      scopeSeparator - the scope separator as a string
      Returns:
      the current instance of OAuth2Options for method chaining
    • isVerifyToken

      public boolean isVerifyToken()
      Checks if token verification is enabled.
      Returns:
      true if token verification is enabled, otherwise false.
    • setVerifyToken

      public OAuth2Options setVerifyToken(boolean verifyToken)
      Enables or disables token verification.
      Parameters:
      verifyToken - true to enable token verification, false to disable it
      Returns:
      the current instance of OAuth2Options for method chaining
    • isValidateIssuer

      public boolean isValidateIssuer()
      Checks if issuer validation is enabled.
      Returns:
      true if issuer validation is enabled, otherwise false
    • setValidateIssuer

      public OAuth2Options setValidateIssuer(boolean validateIssuer)
      Enables or disables issuer validation.
      Parameters:
      validateIssuer - true to enable issuer validation, false to disable it
      Returns:
      the current instance of OAuth2Options for method chaining
    • isUseLoopbackIpAddress

      public boolean isUseLoopbackIpAddress()
      Checks if loopback IP address is used.
      Returns:
      true if loopback IP address is used, otherwise false.
    • setUseLoopbackIpAddress

      public OAuth2Options setUseLoopbackIpAddress(boolean useLoopbackIpAddress)
      Sets whether to use loopback IP address.
      Parameters:
      useLoopbackIpAddress - true to use loopback IP address, false otherwise
      Returns:
      the current instance of OAuth2Options for method chaining
    • getLogoutPath

      public String getLogoutPath()
      Returns the URL of the authorization server's logout endpoint.
      Returns:
      a URL as a string.
    • setLogoutPath

      public OAuth2Options setLogoutPath(String logoutPath)
      Sets the URL of the authorization server's logout endpoint.
      Parameters:
      logoutPath - a URL as a string
      Returns:
      the current instance of OAuth2Options for method chaining
    • getUserInfoPath

      public String getUserInfoPath()
      Returns the URL of the authorization server's userinfo endpoint.
      Returns:
      a URL as a string.
    • setUserInfoPath

      public OAuth2Options setUserInfoPath(String userInfoPath)
      Sets the URL of the authorization server's userinfo endpoint.
      Parameters:
      userInfoPath - a URL as a string
      Returns:
      the current instance of OAuth2Options for method chaining
    • getUserInfoParams

      public org.json.JSONObject getUserInfoParams()
      Gets the user information parameters.
      Returns:
      a JSONObject containing user information parameters
    • setUserInfoParams

      public OAuth2Options setUserInfoParams(org.json.JSONObject userInfoParams)
      Sets the user information parameters.
      Parameters:
      userInfoParams - a JSONObject containing user information parameters
      Returns:
      the current instance of OAuth2Options for method chaining
    • getIntrospectionPath

      public String getIntrospectionPath()
      Returns the URL of the authorization server's introspection endpoint.
      Returns:
      a URL as a string
    • setIntrospectionPath

      public OAuth2Options setIntrospectionPath(String introspectionPath)
      Sets the URL of the authorization server's introspection endpoint.
      Parameters:
      introspectionPath - a URL as a string
      Returns:
      the current instance of OAuth2Options for method chaining
    • getJwkPath

      public String getJwkPath()
      Returns the URL of the authorization server's JSON Web Key Set (JWKS) endpoint.
      Returns:
      a URL as a string
    • setJwkPath

      public OAuth2Options setJwkPath(String jwkPath)
      Sets the URL of the authorization server's JSON Web Key Set (JWKS) endpoint.
      Parameters:
      jwkPath - a URL as a string
      Returns:
      the current instance of OAuth2Options for method chaining
    • getJwkMaxAge

      public long getJwkMaxAge()
      Gets the maximum age of the JWK set before it is refreshed.
      Returns:
      the maximum age in milliseconds
    • setJwkMaxAge

      public OAuth2Options setJwkMaxAge(long jwkMaxAge)
      Sets the maximum age of the JWK set before it needs to be refreshed.
      Parameters:
      jwkMaxAge - the maximum age in milliseconds
      Returns:
      the current instance of OAuth2Options for method chaining
    • getTenant

      public String getTenant()
      Gets the tenant identifier used in OAuth2 requests.
      Returns:
      the tenant identifier as a string
    • setTenant

      public OAuth2Options setTenant(String tenant)
      Sets the tenant identifier to be used in OAuth2 requests.
      Parameters:
      tenant - the tenant identifier as a string
      Returns:
      the current instance of OAuth2Options for method chaining
    • getSite

      public String getSite()
      Gets the site URL used in forming OAuth2 endpoints.
      Returns:
      the site URL as a string
    • setSite

      public OAuth2Options setSite(String site)
      Sets the site URL to be used in forming OAuth2 endpoints.
      Parameters:
      site - the site URL as a string
      Returns:
      the current instance of OAuth2Options for method chaining
    • getClientId

      public String getClientId()
      Gets the client ID used for OAuth2 authentication.
      Returns:
      the client ID as a string
    • setClientId

      public OAuth2Options setClientId(String clientId)
      Sets the client ID to be used for OAuth2 authentication.
      Parameters:
      clientId - the client ID as a string
      Returns:
      the current instance of OAuth2Options for method chaining
    • getClientSecret

      public String getClientSecret()
      Gets the client secret used for OAuth2 authentication.
      Returns:
      the client secret as a string
    • setClientSecret

      public OAuth2Options setClientSecret(String clientSecret)
      Sets the client secret to be used for OAuth2 authentication.
      Parameters:
      clientSecret - the client secret as a string
      Returns:
      the current instance of OAuth2Options for method chaining
    • getClientAssertionType

      public String getClientAssertionType()
      Gets the client assertion type used in OAuth2 authentication.
      Returns:
      the client assertion type as a string
    • setClientAssertionType

      public OAuth2Options setClientAssertionType(String clientAssertionType)
      Sets the client assertion type to be used in OAuth2 authentication.
      Parameters:
      clientAssertionType - the client assertion type as a string
      Returns:
      the current instance of OAuth2Options for method chaining
    • getClientAssertion

      public String getClientAssertion()
      Gets the client assertion used for OAuth2 authentication.
      Returns:
      the client assertion as a string
    • setClientAssertion

      public OAuth2Options setClientAssertion(String clientAssertion)
      Sets the client assertion to be used for OAuth2 authentication.
      Parameters:
      clientAssertion - the client assertion as a string
      Returns:
      the current instance of OAuth2Options for method chaining
    • getUserAgent

      public String getUserAgent()
      Gets the user agent string to be used in OAuth2 requests.
      Returns:
      the user agent string
    • setUserAgent

      public OAuth2Options setUserAgent(String userAgent)
      Sets the user agent string to be used in OAuth2 requests.
      Parameters:
      userAgent - the user agent string to set
      Returns:
      the current instance of OAuth2Options for method chaining
    • getHeaders

      public org.json.JSONObject getHeaders()
      Gets the custom headers to be sent in OAuth2 requests.
      Returns:
      a JSONObject containing the custom headers
    • setHeaders

      public OAuth2Options setHeaders(org.json.JSONObject headers)
      Sets custom headers to be sent in OAuth2 requests.
      Parameters:
      headers - a JSONObject containing the custom headers to set
      Returns:
      the current instance of OAuth2Options for method chaining
    • getPubSecKeys

      public List<PubSecKeyOptions> getPubSecKeys()
      Gets the public and secret key options used in OAuth2 authentication.
      Returns:
      a list of PubSecKeyOptions
    • setPubSecKeys

      public OAuth2Options setPubSecKeys(List<PubSecKeyOptions> pubSecKeys)
      Sets the public and secret key options to be used in OAuth2 authentication.
      Parameters:
      pubSecKeys - a list of PubSecKeyOptions to set
      Returns:
      the current instance of OAuth2Options for method chaining
    • addPubSecKeys

      public OAuth2Options addPubSecKeys(PubSecKeyOptions pubSecKey)
      Adds a public and secret key option to the existing list for OAuth2 authentication.
      Parameters:
      pubSecKey - a PubSecKeyOptions object to add
      Returns:
      the current instance of OAuth2Options for method chaining
    • getJWTOptions

      public JWTOptions getJWTOptions()
      Gets the JWT options used in OAuth2 authentication.
      Returns:
      a JWTOptions object representing the JWT options
    • setJWTOptions

      public OAuth2Options setJWTOptions(JWTOptions jwtOptions)
      Sets the JWT options to be used in OAuth2 authentication.
      Parameters:
      jwtOptions - a JWTOptions object representing the JWT options to set
      Returns:
      the current instance of OAuth2Options for method chaining
    • getExtraParams

      public org.json.JSONObject getExtraParams()
      Gets extra parameters to be sent in OAuth2 requests.
      Returns:
      a JSONObject containing the extra parameters
    • setExtraParams

      public OAuth2Options setExtraParams(org.json.JSONObject extraParams)
      Sets extra parameters to be included in OAuth2 requests.
      Parameters:
      extraParams - a JSONObject containing the extra parameters to set
      Returns:
      the current instance of OAuth2Options for method chaining
    • replaceVariables

      public String replaceVariables(@Nullable @Nullable String path)
      Replaces the tenant/realm variable in the given path.
      Parameters:
      path - the path with potential variables
      Returns:
      the path with the tenant/realm variable replaced
    • validate

      public void validate() throws IllegalStateException
      Validates the OAuth2 configuration for completeness and consistency.
      Throws:
      IllegalStateException - if the configuration is invalid
    • toJSON

      public org.json.JSONObject toJSON()
      Description copied from interface: Options
      Convert all configuration information to JSON format.
      Specified by:
      toJSON in interface Options
      Returns:
      a JSON object.