Class SPNEGOLoginService

All Implemented Interfaces:
LoginService, Container, Destroyable, Dumpable, Dumpable.DumpableContainer, LifeCycle

public class SPNEGOLoginService extends ContainerLifeCycle implements LoginService

A configurable (as opposed to using system properties) SPNEGO LoginService.

At startup, this LoginService will login via JAAS the service principal, composed of the service name and the host name, for example HTTP/wonder.com, using a keyTab file as the service principal credentials.

Upon receiving an HTTP request, the server tries to authenticate the client calling LoginService.login(String, Object, Request, Function) where the GSS APIs are used to verify client tokens and (perhaps after a few round-trips) a GSSContext is established.

  • Constructor Details

    • SPNEGOLoginService

      public SPNEGOLoginService(String realm, LoginService loginService)
  • Method Details

    • getName

      public String getName()
      Specified by:
      getName in interface LoginService
      Returns:
      the realm name
    • getKeyTabPath

      public Path getKeyTabPath()
      Get the path of the keyTab file containing service credentials.
      Returns:
      the path of the keyTab file containing service credentials
    • setKeyTabPath

      public void setKeyTabPath(Path keyTabFile)
      Set the path of the keyTab file containing service credentials.
      Parameters:
      keyTabFile - the path of the keyTab file containing service credentials
    • getServiceName

      public String getServiceName()
      Returns:
      the service name, typically "HTTP"
      See Also:
    • setServiceName

      public void setServiceName(String serviceName)
      Parameters:
      serviceName - the service name
      See Also:
    • getHostName

      public String getHostName()
      Returns:
      the host name of the service
      See Also:
    • setHostName

      public void setHostName(String hostName)
      Set the host name of the service.
      Parameters:
      hostName - the host name of the service
    • doStart

      protected void doStart() throws Exception
      Description copied from class: ContainerLifeCycle
      Starts the managed lifecycle beans in the order they were added.
      Overrides:
      doStart in class ContainerLifeCycle
      Throws:
      AbstractLifeCycle.StopException - If thrown, the lifecycle will immediately be stopped.
      Exception - If there was a problem starting. Will cause a transition to FAILED state
    • login

      public UserIdentity login(String username, Object credentials, Request request, Function<Boolean,Session> getOrCreateSession)
      Description copied from interface: LoginService
      Login a user.
      Specified by:
      login in interface LoginService
      Parameters:
      username - The username.
      credentials - The users credentials.
      request - The request or null
      getOrCreateSession - function to retrieve or create a session.
      Returns:
      A UserIdentity if the credentials matched, otherwise null
    • validate

      public boolean validate(UserIdentity user)
      Description copied from interface: LoginService
      Validate a user identity. Validate that a UserIdentity previously created by a call to LoginService.login(String, Object, Request, Function) is still valid.
      Specified by:
      validate in interface LoginService
      Parameters:
      user - The user to validate
      Returns:
      true if authentication has not been revoked for the user.
    • getIdentityService

      public IdentityService getIdentityService()
      Description copied from interface: LoginService
      Get the IdentityService associated with this Login Service.
      Specified by:
      getIdentityService in interface LoginService
      Returns:
      the IdentityService associated with this Login Service.
    • setIdentityService

      public void setIdentityService(IdentityService identityService)
      Description copied from interface: LoginService
      Set the IdentityService associated with this Login Service.
      Specified by:
      setIdentityService in interface LoginService
      Parameters:
      identityService - the IdentityService associated with this Login Service.
    • logout

      public void logout(UserIdentity user)
      Specified by:
      logout in interface LoginService