|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ecyrd.jspwiki.auth.authorize.DefaultGroupManager
public class DefaultGroupManager
This default UserDatabase implementation provides groups to JSPWiki.
Groups are based on WikiPages. The name of the page determines the group name (as a convention, we suggest the name of the page ends in DefaultGroup, e.g. EditorGroup). By setting attribute 'members' on the page, the named members are added to the group:
[{SET members fee fie foe foo}]
The list of members can be separated by commas or spaces.
TODO: are 'named members' supposed to be usernames, or are group names allowed? (Suggestion: both)
Nested Class Summary | |
---|---|
static class |
DefaultGroupManager.GroupListener
Tiny little listener that captures wiki events fired by Groups this GroupManager knows about. |
class |
DefaultGroupManager.SaveFilter
This special filter class is used to refresh the database after a page has been changed. |
Field Summary | |
---|---|
static String |
ATTR_MEMBERLIST
The attribute to set on a page - [{SET members ...}] - to define members of the group named by that page. |
static String |
GROUP_PREFIX
|
protected WikiEngine |
m_engine
|
protected WikiEventListener |
m_groupListener
|
Fields inherited from interface com.ecyrd.jspwiki.auth.authorize.GroupManager |
---|
PROP_GROUPMANAGER |
Constructor Summary | |
---|---|
DefaultGroupManager()
|
Method Summary | |
---|---|
void |
add(Group group)
Adds a Group to the group cache. |
void |
addWikiEventListener(WikiEventListener listener)
Registers a WikiEventListener with this GroupManager. |
void |
commit()
Commits the groups to disk. |
boolean |
exists(Group group)
Returns true if a Group is known to the GroupManager
(contained in the group cache), false otherwise. |
Principal |
findRole(String name)
Returns a Group matching a given name. |
protected void |
fireEvent(WikiSecurityEvent event)
Fires a wiki event to all registered listeners. |
protected static String |
getGroupName(WikiPage p)
Returns the name of a wiki group, based on a supplied wiki page. |
Principal[] |
getRoles()
Returns an array of role Principals this GroupManager knows about. |
void |
initialize(WikiEngine engine,
Properties props)
Initializes the group cache by adding a DefaultGroupManager.SaveFilter to the page
manager, so that groups are updated when pages are saved. |
boolean |
isUserInRole(WikiSession session,
Principal role)
Determines whether the Subject associated with a WikiSession is in a particular role. |
protected List |
parseMemberList(String memberLine)
Protected method that parses through the group membership list on a wiki page, and returns a List containing the member names as Strings. |
void |
reload()
Reloads the group cache by iterating through all wiki pages and updating groups whenever a [{SET members ...}] tag is found. |
void |
remove(Group group)
Removes a Group from the group cache. |
void |
removeWikiEventListener(WikiEventListener listener)
Un-registers a WikiEventListener with this GroupManager. |
protected void |
updateGroup(String groupName,
List memberList)
Updates a named group with a List of new members. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String ATTR_MEMBERLIST
protected WikiEngine m_engine
protected WikiEventListener m_groupListener
public static final String GROUP_PREFIX
Constructor Detail |
---|
public DefaultGroupManager()
Method Detail |
---|
public void add(Group group)
IllegalArgumentException
, if the proposed group
is the same name as one of the built-in Roles: e.g., Admin,
Authenticated, etc.
add
in interface GroupManager
group
- the Group to add
IllegalArgumentException
- if the group name isn't allowedGroupManager.add(Group)
public void addWikiEventListener(WikiEventListener listener)
addWikiEventListener
in interface GroupManager
listener
- the event listenerpublic void commit() throws WikiException
commit
in interface GroupManager
WikiException
GroupManager.commit()
public boolean exists(Group group)
true
if a Group is known to the GroupManager
(contained in the group cache), false
otherwise.
exists
in interface GroupManager
GroupManager.exists(Group)
public Principal findRole(String name)
Returns a Group matching a given name. If a group cannot be found, return null.
findRole
in interface Authorizer
name
- Name of the group. This is case-sensitive.
Authorizer.findRole(java.lang.String)
public Principal[] getRoles()
getRoles
in interface Authorizer
public void initialize(WikiEngine engine, Properties props)
DefaultGroupManager.SaveFilter
to the page
manager, so that groups are updated when pages are saved. This method
also calls reload()
.
initialize
in interface GroupManager
initialize
in interface Authorizer
engine
- the current wiki engineprops
- the wiki engine initialization propertiesGroupManager.initialize(com.ecyrd.jspwiki.WikiEngine,
java.util.Properties)
public boolean isUserInRole(WikiSession session, Principal role)
Determines 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 false
.
With respect to this implementation, the supplied Principal must
be a Group. The Subject posesses the "role" if it is a member of
that Group. This method simply finds the Group in question, then
delegates to Group.isMember(Principal)
for each of the
principals in the Subject's principal set.
isUserInRole
in interface Authorizer
session
- the current WikiSessionrole
- the role to check
true
if the user is considered to be in the role,
false
otherwisepublic void reload()
updateGroup(String, List)
is called.
reload
in interface GroupManager
GroupManager.reload()
public void remove(Group group)
remove
in interface GroupManager
group
- the group to removeGroupManager.remove(Group)
public void removeWikiEventListener(WikiEventListener listener)
removeWikiEventListener
in interface GroupManager
listener
- the event listenerprotected List parseMemberList(String memberLine)
memberLine
- the line of text containing the group membership list
protected void fireEvent(WikiSecurityEvent event)
event
- the eventprotected static String getGroupName(WikiPage p)
GROUP_PREFIX
,
the group name will be all of the characters following the prefix.
If the wiki page does not begin with the default group prefix,
this method returns null
.
p
- the wiki page
null
protected void updateGroup(String groupName, List memberList)
groupName
- the name of the group to updatememberList
- the members to add to the group definition
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |