- All Implemented Interfaces:
public class DefaultGroupManager extends java.lang.Object implements GroupManager, Authorizer, WikiEventListener
Facade class for storing, retrieving and managing wiki groups on behalf of AuthorizationManager, JSPs and other presentation-layer
classes. GroupManager works in collaboration with a back-end
GroupDatabase, which persists groups to permanent storage.
Note: prior to JSPWiki 2.4.19, GroupManager was an interface; it is now a concrete, final class. The aspects of GroupManager which previously extracted group information from storage (e.g., wiki pages) have been refactored into the GroupDatabase interface.
Constructors Constructor Description
Modifier and Type Method Description
WikiEvent event)(Fired when a WikiEvent is triggered by an event source.
WikiEventListener listener)(Registers a WikiEventListener with this instance.
Context context, java.lang.String name)(Checks if a String is blank or a restricted Group name, and if it is, appends an error to the Session's message list.
(java.lang.String memberLine)Extracts carriage-return separated members into a Set of String objects.
(java.lang.String name)Looks up and returns a role Principal matching a given String.
(java.lang.String name)Returns the Group matching a given name.
()Returns the current external
()Returns an array of role Principals this Authorizer knows about.
Engine engine, java.util.Properties props)(Initializes this Engine component.
Session session, java.security.Principal role)(Determines whether the Subject associated with a WikiSession is in a particular role.
(java.lang.String name, java.lang.String memberLine, boolean create)Extracts group name and members from passed parameters and populates an existing Group with them.
(java.lang.String index)Removes a named Group from the group database.
WikiEventListener listener)(Un-registers a WikiEventListener with this instance.
Session session, Group group)(Saves the
Groupcreated by a user in a wiki session.
Context context, Group group)(Validates a Group, and appends any errors to the session errors list.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
findRolepublic java.security.Principal findRole(java.lang.String name)Looks up and returns a role Principal matching a given String. If a matching role cannot be found, this method returns
null. Note that it may not always be feasible for an Authorizer implementation to return a role Principal.
getGroupReturns the Group matching a given name. If the group cannot be found, this method throws a
getGroupDatabaseReturns the current external
GroupDatabasein use. This method is guaranteed to return a properly-initialized GroupDatabase, unless it could not be initialized. In that case, this method throws a
WikiException. The GroupDatabase is lazily initialized.
getRolespublic java.security.Principal getRoles()Returns an array of role Principals this Authorizer knows about. This method will always return an array; an implementing class may choose to return an zero-length array if it has no ability to identify the roles under its control.
Initializes this Engine component. Note that the engine is not fully initialized at this point, so don't do anything fancy here - use lazy init, if you have to.
isUserInRoleDetermines whether the Subject associated with a WikiSession is in a particular role. This method takes two parameters: the WikiSession containing the subject and the desired role ( which may be a Role or a Group). If either parameter is
null, this method must return
parseGrouppublic Group parseGroup(java.lang.String name, java.lang.String memberLine, boolean create) throws WikiSecurityException
Extracts group name and members from passed parameters and populates an existing Group with them. The Group will either be a copy of an existing Group (if one can be found), or a new, unregistered Group (if not). Optionally, this method can throw a WikiSecurityException if the Group does not yet exist in the GroupManager cache.
groupparameter in the HTTP request contains the Group name to look up and populate. The
membersparameter contains the member list. If these differ from those in the existing group, the passed values override the old values.
This method does not commit the new Group to the GroupManager cache. To do that, use
- Specified by:
name- the name of the group to construct
memberLine- the line of text containing the group membership list
create- whether this method should create a new, empty Group if one with the requested name is not found. If
false, groups that do not exist will cause a
NoSuchPrincipalExceptionto be thrown
- a new, populated group
WikiSecurityException- if the group name isn't allowed, or if
falseand the Group named
namedoes not exist
- See Also:
removeGroupRemoves a named Group from the group database. If not found, throws a
NoSuchPrincipalException. After removal, this method will commit the delete to the back-end group database. It will also fire a
WikiSecurityEvent.GROUP_REMOVEevent with the GroupManager instance as the source and the Group as target. If
null, this method throws an
checkGroupNameChecks if a String is blank or a restricted Group name, and if it is, appends an error to the Session's message list.
extractMembersprotected java.lang.String extractMembers(java.lang.String memberLine)Extracts carriage-return separated members into a Set of String objects.
memberLine- the list of members
- the list of members
addWikiEventListenerRegisters a WikiEventListener with this instance. This is a convenience method.
removeWikiEventListenerUn-registers a WikiEventListener with this instance. This is a convenience method.
actionPerformedFired when a WikiEvent is triggered by an event source.