Class ConfigurableSpnegoLoginService

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

public class ConfigurableSpnegoLoginService 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 login(String, Object, ServletRequest) where the GSS APIs are used to verify client tokens and (perhaps after a few round-trips) a GSSContext is established.

  • Constructor Details

    • ConfigurableSpnegoLoginService

      public ConfigurableSpnegoLoginService(String realm, AuthorizationService authorizationService)
  • Method Details

    • getName

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

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

      public void setKeyTabPath(Path keyTabFile)
      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)
      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, javax.servlet.ServletRequest req)
      Description copied from interface: LoginService
      Login a user.
      Specified by:
      login in interface LoginService
      Parameters:
      username - The user name
      credentials - The users credentials
      req - TODO
      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, ServletRequest) 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