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.
| Modifier and Type | Class and Description |
|---|---|
private static class |
ConfigurableSpnegoLoginService.GSSContextHolder |
private class |
ConfigurableSpnegoLoginService.SpnegoConfiguration |
private static class |
ConfigurableSpnegoLoginService.SpnegoContext |
AbstractLifeCycle.AbstractLifeCycleListenerContainer.InheritedListener, Container.ListenerLifeCycle.Listener| Modifier and Type | Field and Description |
|---|---|
private AuthorizationService |
_authorizationService |
private ConfigurableSpnegoLoginService.SpnegoContext |
_context |
private org.ietf.jgss.GSSManager |
_gssManager |
private java.lang.String |
_hostName |
private IdentityService |
_identityService |
private java.nio.file.Path |
_keyTabPath |
private java.lang.String |
_realm |
private java.lang.String |
_serviceName |
private static Logger |
LOG |
| Constructor and Description |
|---|
ConfigurableSpnegoLoginService(java.lang.String realm,
AuthorizationService authorizationService) |
| Modifier and Type | Method and Description |
|---|---|
private java.security.PrivilegedAction<byte[]> |
acceptGSSContext(org.ietf.jgss.GSSContext gssContext,
byte[] token) |
protected void |
doStart()
Starts the managed lifecycle beans in the order they were added.
|
java.lang.String |
getHostName() |
IdentityService |
getIdentityService()
Get the IdentityService associated with this Login Service.
|
java.nio.file.Path |
getKeyTabPath() |
java.lang.String |
getName() |
java.lang.String |
getServiceName() |
UserIdentity |
login(java.lang.String username,
java.lang.Object credentials,
javax.servlet.ServletRequest req)
Login a user.
|
void |
logout(UserIdentity user) |
private java.security.PrivilegedAction<org.ietf.jgss.GSSContext> |
newGSSContext() |
private java.security.PrivilegedAction<ConfigurableSpnegoLoginService.SpnegoContext> |
newSpnegoContext(javax.security.auth.Subject subject) |
void |
setHostName(java.lang.String hostName) |
void |
setIdentityService(IdentityService identityService)
Set the IdentityService associated with this Login Service.
|
void |
setKeyTabPath(java.nio.file.Path keyTabFile) |
void |
setServiceName(java.lang.String serviceName) |
private java.lang.String |
toUserName(org.ietf.jgss.GSSContext gssContext) |
boolean |
validate(UserIdentity user)
Validate a user identity.
|
addBean, addBean, addEventListener, addManaged, contains, destroy, doStop, dump, dump, dump, dump, dump, dumpBeans, dumpObject, dumpObjects, dumpStdErr, dumpThis, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBean, updateBeansaddLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitdumpContainer, dumpIterable, dumpMapEntries, dumpObjects, dumpSelf, namedprivate static final Logger LOG
private final org.ietf.jgss.GSSManager _gssManager
private final java.lang.String _realm
private final AuthorizationService _authorizationService
private IdentityService _identityService
private java.lang.String _serviceName
private java.nio.file.Path _keyTabPath
private java.lang.String _hostName
private ConfigurableSpnegoLoginService.SpnegoContext _context
public ConfigurableSpnegoLoginService(java.lang.String realm,
AuthorizationService authorizationService)
public java.lang.String getName()
getName in interface LoginServicepublic java.nio.file.Path getKeyTabPath()
public void setKeyTabPath(java.nio.file.Path keyTabFile)
keyTabFile - the path of the keyTab file containing service credentialspublic java.lang.String getServiceName()
getHostName()public void setServiceName(java.lang.String serviceName)
serviceName - the service namesetHostName(String)public java.lang.String getHostName()
setServiceName(String)public void setHostName(java.lang.String hostName)
hostName - the host name of the serviceprotected void doStart()
throws java.lang.Exception
ContainerLifeCycledoStart in class ContainerLifeCyclejava.lang.Exceptionprivate java.security.PrivilegedAction<ConfigurableSpnegoLoginService.SpnegoContext> newSpnegoContext(javax.security.auth.Subject subject)
public UserIdentity login(java.lang.String username, java.lang.Object credentials, javax.servlet.ServletRequest req)
LoginServicelogin in interface LoginServiceusername - The user namecredentials - The users credentialsreq - TODOprivate java.security.PrivilegedAction<org.ietf.jgss.GSSContext> newGSSContext()
private java.security.PrivilegedAction<byte[]> acceptGSSContext(org.ietf.jgss.GSSContext gssContext,
byte[] token)
private java.lang.String toUserName(org.ietf.jgss.GSSContext gssContext)
public boolean validate(UserIdentity user)
LoginServiceLoginService.login(String, Object, ServletRequest) is still valid.validate in interface LoginServiceuser - The user to validatepublic IdentityService getIdentityService()
LoginServicegetIdentityService in interface LoginServicepublic void setIdentityService(IdentityService identityService)
LoginServicesetIdentityService in interface LoginServiceidentityService - the IdentityService associated with this Login Service.public void logout(UserIdentity user)
logout in interface LoginService