Class StaticBearerTokenAuthenticator

java.lang.Object
org.eclipse.net4j.util.event.Notifier
org.eclipse.net4j.util.lifecycle.Lifecycle
org.eclipse.emf.cdo.server.spi.rest.StaticBearerTokenAuthenticator
All Implemented Interfaces:
CDORestAuthenticator, org.eclipse.net4j.util.event.INotifier, org.eclipse.net4j.util.event.INotifier.INotifier2, org.eclipse.net4j.util.lifecycle.IDeactivateable, org.eclipse.net4j.util.lifecycle.ILifecycle, org.eclipse.net4j.util.lifecycle.ILifecycle.DeferrableActivation

public final class StaticBearerTokenAuthenticator extends org.eclipse.net4j.util.lifecycle.Lifecycle implements CDORestAuthenticator
Authenticates opaque bearer tokens against an immutable mapping configured for one repository exposure.

Runtime validation stores only SHA-256 token digests and compares them with MessageDigest.isEqual(byte[], byte[]). Raw token strings are discarded when the authenticator is first activated. Tokens are operator-provided; this class does not issue, rotate, refresh, or manage credentials.

Author:
Eike Stepper
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.eclipse.net4j.util.event.Notifier

    org.eclipse.net4j.util.event.Notifier.Cancelation

    Nested classes/interfaces inherited from interface org.eclipse.net4j.util.lifecycle.ILifecycle

    org.eclipse.net4j.util.lifecycle.ILifecycle.DeferrableActivation

    Nested classes/interfaces inherited from interface org.eclipse.net4j.util.event.INotifier

    org.eclipse.net4j.util.event.INotifier.INotifier2
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Annotation-factory type for static bearer-token mappings.
    static final String
    Managed-container product group for REST request authenticators.

    Fields inherited from class org.eclipse.net4j.util.lifecycle.Lifecycle

    USE_LABEL
  • Constructor Summary

    Constructors
    Constructor
    Description
    StaticBearerTokenAuthenticator(org.eclipse.net4j.util.container.IManagedContainer container, org.eclipse.net4j.util.collection.Tree config)
    Creates an authenticator from a repository exposure tree.
  • Method Summary

    Modifier and Type
    Method
    Description
    authenticate(CDORestRequest request, IRepository repository)
    Authenticates one request for the addressed repository.
    protected void
     
    protected void
     
    Returns an optional HTTP authentication challenge for missing or invalid credentials.
    Returns an optional OpenAPI Security Scheme object for this authenticator.
    Returns an optional stable name for an OpenAPI security scheme supplied by this authenticator.

    Methods inherited from class org.eclipse.net4j.util.lifecycle.Lifecycle

    activate, checkActive, checkArg, checkArg, checkInactive, checkNull, checkState, checkState, deactivate, deferredActivate, doAfterActivate, doBeforeDeactivate, doCancelActivation, doDeactivate, dump, getLifecycleState, isActive, isDeferredActivation, toString

    Methods inherited from class org.eclipse.net4j.util.event.Notifier

    addListener, addUniqueListener, fireEvent, fireEvent, fireEvent, fireThrowable, firstListenerAdded, getListeners, getNotificationService, hasListener, hasListeners, lastListenerRemoved, listenerAdded, listenerRemoved, removeListener

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.eclipse.net4j.util.event.INotifier

    addListener, getListeners, hasListeners, removeListener
  • Field Details

    • PRODUCT_GROUP

      public static final String PRODUCT_GROUP
      Managed-container product group for REST request authenticators.
      See Also:
    • FACTORY_TYPE

      public static final String FACTORY_TYPE
      Annotation-factory type for static bearer-token mappings.
      See Also:
  • Constructor Details

    • StaticBearerTokenAuthenticator

      public StaticBearerTokenAuthenticator(org.eclipse.net4j.util.container.IManagedContainer container, org.eclipse.net4j.util.collection.Tree config)
      Creates an authenticator from a repository exposure tree. Each token child must define a value and a userID; both values support the existing CDO container string-conversion facilities.
      Parameters:
      container - the managed container used for string conversion
      config - the authenticator's XML tree
      Throws:
      IllegalArgumentException - if any token mapping is incomplete or empty
      NullPointerException - if the container or configuration is null
  • Method Details

    • authenticate

      public String authenticate(CDORestRequest request, IRepository repository)
      Description copied from interface: CDORestAuthenticator
      Authenticates one request for the addressed repository.
      Specified by:
      authenticate in interface CDORestAuthenticator
      Parameters:
      request - the transport-neutral request, including headers and any trusted transport principal
      repository - the repository selected by the request route
      Returns:
      the opaque CDO user ID associated with the authenticated caller
    • getChallenge

      public String getChallenge()
      Description copied from interface: CDORestAuthenticator
      Returns an optional HTTP authentication challenge for missing or invalid credentials.
      Specified by:
      getChallenge in interface CDORestAuthenticator
      Returns:
      a value suitable for WWW-Authenticate, or null when no challenge applies
    • getOpenAPISecuritySchemeName

      public String getOpenAPISecuritySchemeName()
      Description copied from interface: CDORestAuthenticator
      Returns an optional stable name for an OpenAPI security scheme supplied by this authenticator.
      Specified by:
      getOpenAPISecuritySchemeName in interface CDORestAuthenticator
      Returns:
      the scheme name, or null when this mechanism has no static OpenAPI representation
    • getOpenAPISecurityScheme

      public Map<String,Object> getOpenAPISecurityScheme()
      Description copied from interface: CDORestAuthenticator
      Returns an optional OpenAPI Security Scheme object for this authenticator. The returned map must contain only public scheme metadata and must never contain credentials or secret configuration.
      Specified by:
      getOpenAPISecurityScheme in interface CDORestAuthenticator
      Returns:
      an OpenAPI Security Scheme object, or null when this mechanism has no static representation
    • doBeforeActivate

      protected void doBeforeActivate() throws Exception
      Overrides:
      doBeforeActivate in class org.eclipse.net4j.util.lifecycle.Lifecycle
      Throws:
      Exception
    • doActivate

      protected void doActivate() throws Exception
      Overrides:
      doActivate in class org.eclipse.net4j.util.lifecycle.Lifecycle
      Throws:
      Exception