Class HttpAuthenticationProvider

java.lang.Object
io.goobi.viewer.model.security.authentication.HttpAuthenticationProvider
All Implemented Interfaces:
IAuthenticationProvider
Direct Known Subclasses:
BibliothecaProvider, HttpHeaderProvider, LitteraProvider, OpenIdProvider, VuFindProvider

public abstract class HttpAuthenticationProvider extends Object implements IAuthenticationProvider
Authentication provider that delegates credential validation to an external HTTP endpoint.
Author:
Florian Alpers
  • Field Details

    • DEFAULT_EMAIL

      protected static final String DEFAULT_EMAIL
      Constant DEFAULT_EMAIL="{username}@nomail.com".
      See Also:
    • TYPE_USER_PASSWORD

      protected static final String TYPE_USER_PASSWORD
      Constant TYPE_USER_PASSWORD="userPassword".
      See Also:
    • connectionManager

      protected static org.apache.http.impl.conn.PoolingHttpClientConnectionManager connectionManager
      Constant connectionManager.
    • name

      protected final String name
    • label

      protected final String label
    • type

      protected final String type
    • image

      protected final String image
    • timeoutMillis

      protected final long timeoutMillis
    • addUserToGroups

      protected List<String> addUserToGroups
    • url

      protected String url
    • redirectUrl

      protected String redirectUrl
      URL to redirect to after successful login.
  • Constructor Details

    • HttpAuthenticationProvider

      protected HttpAuthenticationProvider(String name, String label, String type, String url, String image, long timeoutMillis)
      Creates a new HttpAuthenticationProvider instance.
      Parameters:
      name - unique identifier for this provider
      label - display label shown to the user
      type - provider type, e.g. userPassword
      url - remote authentication endpoint URL
      image - relative or absolute path to the provider logo
      timeoutMillis - HTTP connection and socket timeout in milliseconds
  • Method Details

    • getTimeoutMillis

      public long getTimeoutMillis()
      Getter for the field timeoutMillis.
      Returns:
      the timeout in milliseconds used for HTTP authentication requests
    • getName

      public String getName()
      Returns an unique name for the authentication provider implementation.
      Specified by:
      getName in interface IAuthenticationProvider
      Returns:
      The name of the provider
    • getLabel

      public String getLabel()
      Getter for the field label.
      Returns:
      the display label for this provider, falling back to the name if no label is set
    • getUrl

      public String getUrl()
      Getter for the field url.
      Returns:
      the endpoint URL used for authentication requests
    • getImage

      public String getImage()
      Getter for the field image.
      Returns:
      the image URL or path representing this authentication provider
    • getImageUrl

      public String getImageUrl()
      getImageUrl.
      Returns:
      the absolute URL to the authentication provider's image
    • getType

      public String getType()
      The provider type. This should either be "local", "userpassword" or "openId". This value is used to determine where this provider is displayed.

      Providers with the same type are displayed together

      Specified by:
      getType in interface IAuthenticationProvider
      Returns:
      The type of the provider
    • getAddUserToGroups

      public List<String> getAddUserToGroups()
      getAddUserToGroups.
      Specified by:
      getAddUserToGroups in interface IAuthenticationProvider
      Returns:
      list of group names to add the user to on login
    • setAddUserToGroups

      public void setAddUserToGroups(List<String> addUserToGroups)
      setAddUserToGroups.
      Specified by:
      setAddUserToGroups in interface IAuthenticationProvider
      Parameters:
      addUserToGroups - group names to assign new or returning users to
    • getRedirectUrl

      public String getRedirectUrl()
      Specified by:
      getRedirectUrl in interface IAuthenticationProvider
    • setRedirectUrl

      public void setRedirectUrl(String redirectUrl)
      Specified by:
      setRedirectUrl in interface IAuthenticationProvider
    • post

      protected String post(URI url, String requestEntity) throws WebApplicationException
      post.
      Parameters:
      url - target endpoint URI for the POST request
      requestEntity - JSON body to send in the POST request
      Returns:
      the HTTP response body as string
      Throws:
      WebApplicationException - if any.
    • get

      protected String get(URI url) throws WebApplicationException
      get.
      Parameters:
      url - target endpoint URI for the GET request
      Returns:
      the HTTP response body as string
      Throws:
      WebApplicationException - if any.