public class WikiSession extends java.lang.Object implements Session
Default implementation for Session.
In addition to methods for examining individual WikiSession objects, this class also contains a number of static
methods for managing WikiSessions for an entire wiki. These methods allow callers to find, query and remove WikiSession objects, and
to obtain a list of the current wiki session users.
ANONYMOUS, ASSERTED, AUTHENTICATED| Modifier and Type | Method and Description |
|---|---|
void |
actionPerformed(WikiEvent event)
Listens for WikiEvents generated by source objects such as the GroupManager, UserManager or AuthenticationManager.
|
void |
addMessage(java.lang.String message) |
void |
addMessage(java.lang.String topic,
java.lang.String message) |
void |
clearMessages() |
void |
clearMessages(java.lang.String topic) |
java.util.Locale |
getLocale() |
java.security.Principal |
getLoginPrincipal() |
java.lang.String[] |
getMessages() |
java.lang.String[] |
getMessages(java.lang.String topic) |
java.security.Principal[] |
getPrincipals() |
java.security.Principal[] |
getRoles() |
java.lang.String |
getStatus() |
javax.security.auth.Subject |
getSubject() |
java.security.Principal |
getUserPrincipal() |
static Session |
getWikiSession(Engine engine,
javax.servlet.http.HttpServletRequest request)
Static factory method that returns the Session object associated with the current HTTP request.
|
static Session |
guestSession(Engine engine)
Static factory method that creates a new "guest" session containing a single user Principal
WikiPrincipal.GUEST, plus the role principals Role.ALL and Role.ANONYMOUS. |
boolean |
hasPrincipal(java.security.Principal principal) |
protected void |
injectGroupPrincipals()
Injects GroupPrincipal objects into the user's Principal set based on the groups the user belongs to.
|
protected void |
injectUserProfilePrincipals()
Adds Principal objects to the Subject that correspond to the logged-in user's profile attributes for the wiki name, full name
and login name.
|
void |
invalidate() |
boolean |
isAnonymous() |
boolean |
isAsserted() |
boolean |
isAuthenticated() |
protected boolean |
isInGroup(Group group)
Returns
true if one of this WikiSession's user Principals can be shown to belong to a particular wiki group. |
static void |
removeWikiSession(Engine engine,
javax.servlet.http.HttpServletRequest request)
Removes the wiki session associated with the user's HTTP request from the cache of wiki sessions, typically as part of a
logout process.
|
static int |
sessions(Engine engine)
Deprecated.
use
SessionMonitor.sessions() instead |
static java.security.Principal[] |
userPrincipals(Engine engine)
Deprecated.
use
SessionMonitor.userPrincipals() instead |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdoPrivilegedprotected boolean isInGroup(Group group)
true if one of this WikiSession's user Principals can be shown to belong to a particular wiki group. If
the user is not authenticated, this method will always return false.group - the group to testpublic boolean isAsserted()
isAsserted in interface Sessionpublic boolean isAuthenticated()
isAuthenticated in interface Sessionpublic boolean isAnonymous()
isAnonymous in interface Sessionpublic java.security.Principal getLoginPrincipal()
getLoginPrincipal in interface Sessionpublic java.security.Principal getUserPrincipal()
getUserPrincipal in interface Sessionpublic void addMessage(java.lang.String message)
addMessage in interface Sessionpublic void addMessage(java.lang.String topic, java.lang.String message)
addMessage in interface Sessionpublic void clearMessages()
clearMessages in interface Sessionpublic void clearMessages(java.lang.String topic)
clearMessages in interface Sessionpublic java.lang.String[] getMessages()
getMessages in interface Sessionpublic java.lang.String[] getMessages(java.lang.String topic)
getMessages in interface Sessionpublic java.security.Principal[] getPrincipals()
getPrincipals in interface Sessionpublic boolean hasPrincipal(java.security.Principal principal)
hasPrincipal in interface Sessionpublic void actionPerformed(WikiEvent event)
actionPerformed in interface WikiEventListenerWikiEventListener.actionPerformed(WikiEvent)public void invalidate()
invalidate in interface Sessionprotected void injectGroupPrincipals()
Authorizer.getRoles() to obtain the array of GroupPrincipals the authorizer knows about. Then, the
method Authorizer.isUserInRole(Session, Principal) is called for each Principal. If the user is a member of the
group, an equivalent GroupPrincipal is injected into the user's principal set. Existing GroupPrincipals are flushed and replaced.
This method should generally be called after a user's UserProfile is saved. If the wiki session
is null, or there is no matching user profile, the method returns silently.protected void injectUserProfilePrincipals()
public javax.security.auth.Subject getSubject()
getSubject in interface Sessionpublic static void removeWikiSession(Engine engine, javax.servlet.http.HttpServletRequest request)
engine - the wiki enginerequest - the user's HTTP requestpublic static Session getWikiSession(Engine engine, javax.servlet.http.HttpServletRequest request)
Static factory method that returns the Session object associated with the current HTTP request. This method looks up
the associated HttpSession in an internal WeakHashMap and attempts to retrieve the WikiSession. If not found, one is created.
This method is guaranteed to always return a Session, although the authentication status is unpredictable until the user
attempts to log in. If the servlet request parameter is null, a synthetic guestSession(Engine) is
returned.
When a session is created, this method attaches a WikiEventListener to the GroupManager, UserManager and AuthenticationManager, so that changes to users, groups, logins, etc. are detected automatically.
engine - the enginerequest - the servlet request objectpublic static Session guestSession(Engine engine)
WikiPrincipal.GUEST, plus the role principals Role.ALL and Role.ANONYMOUS. This
method also adds the session as a listener for GroupManager, AuthenticationManager and UserManager events.engine - the wiki engine@Deprecated public static int sessions(Engine engine)
SessionMonitor.sessions() insteadSessionMonitor.sessions() method.engine - the wiki sessionSessionMonitor.sessions()@Deprecated public static java.security.Principal[] userPrincipals(Engine engine)
SessionMonitor.userPrincipals() insteadgetUserPrincipal() method. This method delegates to
SessionMonitor.userPrincipals().engine - the wiki engineSessionMonitor.userPrincipals()Copyright (c) 2001-2022 The Apache Software Foundation. All rights reserved.