Package org.apache.wiki.auth.authorize
Class XMLGroupDatabase
- java.lang.Object
-
- org.apache.wiki.auth.authorize.XMLGroupDatabase
-
- All Implemented Interfaces:
GroupDatabase
public class XMLGroupDatabase extends java.lang.Object implements GroupDatabase
GroupDatabase implementation for loading, persisting and storing wiki groups, using an XML file for persistence. Group entries are simple
<group>
elements under the root. Each group member is representated by a<member>
element. For example:<groups>
<group name="TV" created="Jun 20, 2006 2:50:54 PM" lastModified="Jan 21, 2006 2:50:54 PM">
<member principal="Archie Bunker" />
<member principal="BullwinkleMoose" />
<member principal="Fred Friendly" />
</group>
<group name="Literature" created="Jun 22, 2006 2:50:54 PM" lastModified="Jan 23, 2006 2:50:54 PM">
<member principal="Charles Dickens" />
<member principal="Homer" />
</group>
</groups>- Since:
- 2.4.17
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
PROP_DATABASE
The jspwiki.properties property specifying the file system location of the group database.
-
Constructor Summary
Constructors Constructor Description XMLGroupDatabase()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
delete(Group group)
Looks up and deletes aGroup
from the group database.Group[]
groups()
Returns all wiki groups that are stored in the GroupDatabase as an array of Group objects.void
initialize(Engine engine, java.util.Properties props)
Initializes the group database based on values from a Properties object.void
save(Group group, java.security.Principal modifier)
Saves a Group to the group database.
-
-
-
Field Detail
-
PROP_DATABASE
public static final java.lang.String PROP_DATABASE
The jspwiki.properties property specifying the file system location of the group database.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
XMLGroupDatabase
public XMLGroupDatabase()
-
-
Method Detail
-
delete
public void delete(Group group) throws WikiSecurityException
Looks up and deletes aGroup
from the group database. If the group database does not contain the supplied Group. this method throws aNoSuchPrincipalException
. The method commits the results of the delete to persistent storage.- Specified by:
delete
in interfaceGroupDatabase
- Parameters:
group
- the group to remove- Throws:
WikiSecurityException
- if the database does not contain the supplied group (thrown asNoSuchPrincipalException
) or if the commit did not succeed
-
groups
public Group[] groups() throws WikiSecurityException
Returns all wiki groups that are stored in the GroupDatabase as an array of Group objects. If the database does not contain any groups, this method will return a zero-length array. This method causes back-end storage to load the entire set of group; thus, it should be called infrequently (e.g., at initialization time).- Specified by:
groups
in interfaceGroupDatabase
- Returns:
- the wiki groups
- Throws:
WikiSecurityException
- if the groups cannot be returned by the back-end
-
initialize
public void initialize(Engine engine, java.util.Properties props) throws NoRequiredPropertyException, WikiSecurityException
Initializes the group database based on values from a Properties object. The properties object must contain a file path to the XML database file whose key isPROP_DATABASE
.- Specified by:
initialize
in interfaceGroupDatabase
- Parameters:
engine
- the wiki engineprops
- the properties used to initialize the group database- Throws:
NoRequiredPropertyException
- if the user database cannot be located, parsed, or openedWikiSecurityException
- if the database could not be initialized successfully
-
save
public void save(Group group, java.security.Principal modifier) throws WikiSecurityException
Saves a Group to the group database. Note that this method must fail, and throw anIllegalArgumentException
, if the proposed group is the same name as one of the built-in Roles: e.g., Admin, Authenticated, etc. The database is responsible for setting create/modify timestamps, upon a successful save, to the Group. The method commits the results of the delete to persistent storage.- Specified by:
save
in interfaceGroupDatabase
- Parameters:
group
- the Group to savemodifier
- the user who saved the Group- Throws:
WikiSecurityException
- if the Group could not be saved successfully
-
-