public class CookieAssertionLoginModule extends AbstractLoginModule
Logs in a user based on assertion of a name supplied in a cookie. If the cookie is not found, authentication fails.
This module must be used with a CallbackHandler (such asWebContainerCallbackHandler) that supports the following Callback
types:
HttpRequestCallback- supplies the cookie, which should contain
a user name.After authentication, a generic WikiPrincipal based on the username will be created and associated with the Subject.
LoginModule.commit(),
CookieAuthenticationLoginModule| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
PREFS_COOKIE_NAME
The name of the cookie that gets stored to the user browser.
|
m_handler, m_options, m_principals, m_state, m_subject, NULL| Constructor and Description |
|---|
CookieAssertionLoginModule() |
| Modifier and Type | Method and Description |
|---|---|
static void |
clearUserCookie(javax.servlet.http.HttpServletResponse response)
Removes the user cookie from the response.
|
static java.lang.String |
getUserCookie(javax.servlet.http.HttpServletRequest request)
Returns the username cookie value.
|
boolean |
login()
Logs in the user by calling back to the registered CallbackHandler with a
series of callbacks.
|
static void |
setUserCookie(javax.servlet.http.HttpServletResponse response,
java.lang.String name)
Sets the username cookie.
|
abort, commit, initialize, logoutpublic static final java.lang.String PREFS_COOKIE_NAME
public CookieAssertionLoginModule()
public boolean login() throws javax.security.auth.login.LoginException
true
Logs in the user by calling back to the registered CallbackHandler with
an HttpRequestCallback. The CallbackHandler must supply the current
servlet HTTP request as its response.login in interface javax.security.auth.spi.LoginModulelogin in class AbstractLoginModuletrue. If not found, this
method throws a FailedLoginException.javax.security.auth.login.LoginException - if the authentication failsLoginModule.login()public static java.lang.String getUserCookie(javax.servlet.http.HttpServletRequest request)
request - The Servlet request, as usual.public static void setUserCookie(javax.servlet.http.HttpServletResponse response, java.lang.String name)
response - The Servlet responsename - The name to write into the cookie.public static void clearUserCookie(javax.servlet.http.HttpServletResponse response)
response - The servlet response.Copyright (c) 2001-2022 The Apache Software Foundation. All rights reserved.