public class DefaultAuthenticationManager extends java.lang.Object implements AuthenticationManager
AuthenticationManager
| Modifier and Type | Field and Description |
|---|---|
protected static java.util.Map<java.lang.String,java.lang.String> |
EMPTY_MAP
Empty Map passed to JAAS
doJAASLogin(Class, CallbackHandler, Map) method. |
protected java.lang.Class<? extends javax.security.auth.spi.LoginModule> |
m_loginModuleClass
Class (of type LoginModule) to use for custom authentication.
|
protected java.util.Map<java.lang.String,java.lang.String> |
m_loginModuleOptions
Options passed to
LoginModule.initialize(Subject, CallbackHandler, Map, Map);
initialized by initialize(Engine, Properties). |
PREFIX_LOGIN_MODULE_OPTIONS, PROP_ALLOW_COOKIE_ASSERTIONS, PROP_ALLOW_COOKIE_AUTH, PROP_LOGIN_MODULE, PROP_LOGIN_THROTTLING, PROP_STOREIPADDRESS| Constructor and Description |
|---|
DefaultAuthenticationManager() |
| Modifier and Type | Method and Description |
|---|---|
void |
addWikiEventListener(WikiEventListener listener)
Registers a WikiEventListener with this instance.
|
boolean |
allowsCookieAssertions()
Determines whether this Engine allows users to assert identities using cookies instead of passwords.
|
boolean |
allowsCookieAuthentication()
Determines whether this Engine allows users to authenticate using cookies instead of passwords.
|
java.util.Set<java.security.Principal> |
doJAASLogin(java.lang.Class<? extends javax.security.auth.spi.LoginModule> clazz,
javax.security.auth.callback.CallbackHandler handler,
java.util.Map<java.lang.String,java.lang.String> options)
Instantiates and executes a single JAAS
LoginModule, and returns a Set of Principals that results from a successful login. |
void |
initialize(Engine engine,
java.util.Properties props) |
boolean |
isContainerAuthenticated()
Returns true if this Engine uses container-managed authentication.
|
boolean |
login(javax.servlet.http.HttpServletRequest request)
Logs in the user by attempting to populate a Session Subject from a web servlet request by examining the request
for the presence of container credentials and user cookies.
|
boolean |
login(Session session,
javax.servlet.http.HttpServletRequest request,
java.lang.String username,
java.lang.String password)
Attempts to perform a Session login for the given username/password combination using JSPWiki's custom authentication mode.
|
void |
logout(javax.servlet.http.HttpServletRequest request)
Logs the user out by retrieving the Session associated with the HttpServletRequest and unbinding all of the Subject's Principals,
except for
Role.ALL, Role.ANONYMOUS. is a cheap-and-cheerful way to do it without invoking JAAS LoginModules. |
void |
removeWikiEventListener(WikiEventListener listener)
Un-registers a WikiEventListener with this instance.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitfireEvent, getLoginPrincipal, isRolePrincipal, isUserPrincipalprotected static final java.util.Map<java.lang.String,java.lang.String> EMPTY_MAP
doJAASLogin(Class, CallbackHandler, Map) method.protected java.lang.Class<? extends javax.security.auth.spi.LoginModule> m_loginModuleClass
protected final java.util.Map<java.lang.String,java.lang.String> m_loginModuleOptions
LoginModule.initialize(Subject, CallbackHandler, Map, Map);
initialized by initialize(Engine, Properties).public DefaultAuthenticationManager()
public void initialize(Engine engine, java.util.Properties props) throws WikiException
initialize in interface InitializableWikiExceptionpublic boolean isContainerAuthenticated()
WebContainerAuthorizer.isContainerAuthorized(),
if used as the external authorizer; otherwise, returns false.isContainerAuthenticated in interface AuthenticationManagertrue if the wiki's authentication is managed by the container, false otherwisepublic boolean login(javax.servlet.http.HttpServletRequest request) throws WikiSecurityException
Logs in the user by attempting to populate a Session Subject from a web servlet request by examining the request for the presence of container credentials and user cookies. The processing logic is as follows:
userPrincipal,
container remoteUser, or authentication cookie. If the user is authenticated, this method fires event
WikiSecurityEvent.LOGIN_AUTHENTICATED with two parameters: a Principal representing the login principal,
and the current Session. In addition, if the authorizer is of type WebContainerAuthorizer, this method iterates through the
container roles returned by WebContainerAuthorizer.getRoles(), tests for membership in each
one, and adds those that pass to the Subject's principal set.WikiSecurityEvent.LOGIN_ASSERTED with two parameters: WikiPrincipal(cookievalue),
and the current Session.WikiSecurityEvent.LOGIN_ANONYMOUS with two parameters: WikiPrincipal(remoteAddress),
and the current Session login in interface AuthenticationManagerrequest - servlet request for this usertrue (because anonymous login, at least, will always succeed)WikiSecurityException - if the user cannot be logged in for any reasonpublic boolean login(Session session, javax.servlet.http.HttpServletRequest request, java.lang.String username, java.lang.String password) throws WikiSecurityException
AuthenticationManager.PROP_LOGIN_MODULE will be instantiated, and its
LoginModule.initialize(Subject, CallbackHandler, Map, Map) method will be invoked. By default,
the UserDatabaseLoginModule class will be used. When the LoginModule's initialize
method is invoked, an options Map populated by properties keys prefixed by AuthenticationManager.PREFIX_LOGIN_MODULE_OPTIONS will be passed as a
parameter.login in interface AuthenticationManagersession - the current wiki session; may not be null.request - the user's HTTP request. This parameter may be null, but the configured LoginModule will not have access
to the HTTP request in this case.username - The user name. This is a login name, not a WikiName. In most cases they are the same, but in some cases, they might not be.password - the passwordWikiSecurityException - if the Authorizer or UserManager cannot be obtainedpublic void logout(javax.servlet.http.HttpServletRequest request)
Role.ALL, Role.ANONYMOUS. is a cheap-and-cheerful way to do it without invoking JAAS LoginModules.
The logout operation will also flush the JSESSIONID cookie from the user's browser session, if it was set.logout in interface AuthenticationManagerrequest - the current HTTP requestpublic boolean allowsCookieAssertions()
AuthenticationManager.PROP_ALLOW_COOKIE_ASSERTIONS.allowsCookieAssertions in interface AuthenticationManagertrue if cookies are allowedpublic boolean allowsCookieAuthentication()
AuthenticationManager.PROP_ALLOW_COOKIE_AUTH.allowsCookieAuthentication in interface AuthenticationManagertrue if cookies are allowed for authenticationpublic java.util.Set<java.security.Principal> doJAASLogin(java.lang.Class<? extends javax.security.auth.spi.LoginModule> clazz, javax.security.auth.callback.CallbackHandler handler, java.util.Map<java.lang.String,java.lang.String> options) throws WikiSecurityException
LoginModule, and returns a Set of Principals that results from a successful login.
The LoginModule is instantiated, then its LoginModule.initialize(Subject, CallbackHandler, Map, Map) method is called. The
parameters passed to initialize is a dummy Subject, an empty shared-state Map, and an options Map the caller supplies.doJAASLogin in interface AuthenticationManagerclazz - the LoginModule class to instantiatehandler - the callback handler to supply to the LoginModuleoptions - a Map of key/value strings for initializing the LoginModuleSubject.getPrincipals()WikiSecurityException - if the LoginModule could not be instantiated for any reasonpublic void addWikiEventListener(WikiEventListener listener)
addWikiEventListener in interface AuthenticationManagerlistener - the event listenerpublic void removeWikiEventListener(WikiEventListener listener)
removeWikiEventListener in interface AuthenticationManagerlistener - the event listenerCopyright (c) 2001-2022 The Apache Software Foundation. All rights reserved.