java.lang.Object
overit.geocallapp.wfm.orchestrator.planning.utilities.rest.AuthManager

public class AuthManager extends Object
Manager for authentication strategies. This class provides factory methods for creating different authentication strategies and applies authentication to HTTP headers.
  • Field Details

  • Constructor Details

    • AuthManager

      public AuthManager(AuthenticationStrategy authStrategy)
      Creates a new authentication manager with the specified authentication strategy.
      Parameters:
      authStrategy - The authentication strategy to use
  • Method Details

    • withApiToken

      public static AuthManager withApiToken(String token)
      Creates a new authentication manager that uses API token authentication.
      Parameters:
      token - The API token to use for authentication
      Returns:
      A new authentication manager
    • withApiToken

      public static AuthManager withApiToken(String token, String prefix)
      Creates a new authentication manager that uses API token authentication with a custom prefix.
      Parameters:
      token - The API token to use for authentication
      prefix - The prefix to use before the token (e.g., "Bearer", "Token", "ApiKey")
      Returns:
      A new authentication manager
    • withUsernamePassword

      public static AuthManager withUsernamePassword(String authUrl, String username, String password)
      Creates a new authentication manager that uses username/password authentication with JWT token.
      Parameters:
      authUrl - The URL to use for authentication
      username - The username to use for authentication
      password - The password to use for authentication
      Returns:
      A new authentication manager
    • withBasicAuth

      public static AuthManager withBasicAuth(String username, String password)
      Creates a new authentication manager that uses HTTP Basic Authentication.
      Parameters:
      username - The username to use for authentication
      password - The password to use for authentication
      Returns:
      A new authentication manager
    • applyAuthentication

      public void applyAuthentication(org.springframework.http.HttpHeaders headers) throws DAValidateException
      Applies authentication to the provided HTTP headers.
      Parameters:
      headers - The HTTP headers to which authentication information should be added
      Throws:
      DAValidateException - if authentication fails
    • isValid

      public boolean isValid()
      Checks if the current authentication is valid.
      Returns:
      true if the authentication is valid, false otherwise
    • refreshAuthentication

      public void refreshAuthentication() throws DAValidateException
      Refreshes the authentication if needed.
      Throws:
      DAValidateException - if authentication refresh fails
    • getAuthStrategy

      public AuthenticationStrategy getAuthStrategy()
      Gets the underlying authentication strategy.
      Returns:
      The authentication strategy