public class UserManager extends Object
Modifier and Type | Class and Description |
---|---|
static class |
UserManager.DummyUserDatabase
This is a database that gets used if nothing else is available.
|
static class |
UserManager.JSONUserModule
Implements the JSON API for usermanager.
|
Modifier and Type | Field and Description |
---|---|
static String |
JSON_USERS |
Constructor and Description |
---|
UserManager() |
Modifier and Type | Method and Description |
---|---|
void |
addWikiEventListener(WikiEventListener listener)
Registers a WikiEventListener with this instance.
|
protected void |
fireEvent(int type,
WikiSession session,
Object profile)
Fires a WikiSecurityEvent of the provided type, Principal and target Object
to all registered listeners.
|
UserDatabase |
getUserDatabase()
Returns the UserDatabase employed by this WikiEngine.
|
UserProfile |
getUserProfile(WikiSession session)
Retrieves the
UserProfile for the
user in a wiki session. |
void |
initialize(WikiEngine engine,
Properties props)
Initializes the engine for its nefarious purposes.
|
Principal[] |
listWikiNames()
A helper method for returning all of the known WikiNames in this system.
|
UserProfile |
parseProfile(WikiContext context)
Extracts user profile parameters from the HTTP request and populates
a UserProfile with them.
|
void |
removeWikiEventListener(WikiEventListener listener)
Un-registers a WikiEventListener with this instance.
|
void |
setUserProfile(WikiSession session,
UserProfile profile)
Saves the
UserProfile for the user in
a wiki session. |
void |
startUserProfileCreationWorkflow(WikiSession session,
UserProfile profile) |
void |
validateProfile(WikiContext context,
UserProfile profile)
Validates a user profile, and appends any errors to the session errors
list.
|
public static final String JSON_USERS
public UserManager()
public void initialize(WikiEngine engine, Properties props)
engine
- the current wiki engineprops
- the wiki engine initialization propertiespublic UserDatabase getUserDatabase()
public UserProfile getUserProfile(WikiSession session)
Retrieves the UserProfile
for the
user in a wiki session. If the user is authenticated, the UserProfile
returned will be the one stored in the user database; if one does not
exist, a new one will be initialized and returned. If the user is
anonymous or asserted, the UserProfile will always be newly
initialized to prevent spoofing of identities. If a UserProfile needs to
be initialized, its
UserProfile.isNew()
method will
return true
, and its login name will will be set
automatically if the user is authenticated. Note that this method does
not modify the retrieved (or newly created) profile otherwise; other
fields in the user profile may be null
.
If a new UserProfile was created, but its
UserProfile.isNew()
method returns
false
, this method throws an IllegalStateException
.
This is meant as a quality check for UserDatabase providers;
it should only be thrown if the implementation is faulty.
session
- the wiki session, which may not be null
public void setUserProfile(WikiSession session, UserProfile profile) throws DuplicateUserException, WikiException
Saves the UserProfile
for the user in
a wiki session. This method verifies that a user profile to be saved
doesn't collide with existing profiles; that is, the login name
or full name is already used by another profile. If the profile
collides, a DuplicateUserException
is thrown. After saving
the profile, the user database changes are committed, and the user's
credential set is refreshed; if custom authentication is used, this means
the user will be automatically be logged in.
When the user's profile is saved successfully, this method fires a
WikiSecurityEvent.PROFILE_SAVE
event with the WikiSession as the
source and the UserProfile as target. For existing profiles, if the
user's full name changes, this method also fires a "name changed"
event (WikiSecurityEvent.PROFILE_NAME_CHANGED
) with the
WikiSession as the source and an array containing the old and new
UserProfiles, respectively. The NAME_CHANGED
event allows
the GroupManager and PageManager can change group memberships and
ACLs if needed.
Note that WikiSessions normally attach event listeners to the UserManager, so changes to the profile will automatically cause the correct Principals to be reloaded into the current WikiSession's Subject.
session
- the wiki session, which may not be null
profile
- the user profile, which may not be null
DuplicateUserException
- if the proposed profile's login name or full name collides with anotherWikiException
- if the save fails for some reason. If the current user does not have
permission to save the profile, this will be a WikiSecurityException
;
if if the user profile must be approved before it can be saved, it will be a
DecisionRequiredException
. All other WikiException
indicate a condition that is not normal is probably due to mis-configurationpublic void startUserProfileCreationWorkflow(WikiSession session, UserProfile profile) throws WikiException
WikiException
public UserProfile parseProfile(WikiContext context)
Extracts user profile parameters from the HTTP request and populates a UserProfile with them. The UserProfile will either be a copy of the user's existing profile (if one can be found), or a new profile (if not). The rules for populating the profile as as follows:
email
or password
parameter values differ
from those in the existing profile, the passed parameters override the
old values.fullname
parameter is always
used; for existing profiles the existing value is used, and whatever
value the user supplied is discarded. The wiki name is automatically
computed by taking the full name and extracting all whitespace.WikiSession.getLoginPrincipal()
. Otherwise,
the value of the loginname
parameter is used.context
- the current wiki contextpublic void validateProfile(WikiContext context, UserProfile profile)
WikiSession.getMessages()
.context
- the current wiki contextprofile
- the supplied UserProfilepublic Principal[] listWikiNames() throws WikiSecurityException
WikiSecurityException
- If for reason the names cannot be fetchedpublic void addWikiEventListener(WikiEventListener listener)
listener
- the event listenerpublic void removeWikiEventListener(WikiEventListener listener)
listener
- the event listenerprotected void fireEvent(int type, WikiSession session, Object profile)
type
- the event type to be firedsession
- the wiki session supporting the eventprofile
- the user profile (or array of user profiles), which may be null
WikiSecurityEvent
Copyright © 2001-2019 The Apache Software Foundation. All rights reserved.