Class Group
Groups are a specialized type of ad-hoc role used by the wiki system. Unlike externally-provided roles (such as those provided by an LDAP server or web container), JSPWiki groups can be created dynamically by wiki users, without requiring special container privileges or administrator intervention. They are designed to provide a lightweight role-based access control system that complements existing role systems.
Group names are case-insensitive, and have a few naming restrictions, which
are enforced by the GroupManager
:
- Groups cannot have the same name as a built-in Role (e.g., "Admin", "Authenticated" etc.)
- Groups cannot have the same name as an existing user
Note: prior to JSPWiki 2.4.19, Group was an interface; it is now a concrete, final class.
Groups are related to GroupPrincipal
s. A GroupPrincipal, when
injected into the Principal set of a Session's Subject, means that the
user is a member of a Group of the same name -- it is, in essence, an
"authorization token." GroupPrincipals, unlike Groups, are thread-safe,
lightweight and immutable. That's why we use them in Subjects rather than the
Groups themselves.
- Since:
- 2.3
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Adds a Principal to the group.void
clear()
Clears all Principals from the group list.boolean
Two DefaultGroups are equal if they contain identical member Principals and have the same name.Returns the creation date.final String
Returns the creator of this Group.Returns the last-modified date.final String
Returns the name of the user who last modified this group.getName()
The name of the group.Returns the GroupPrincipal that represents this Group.getWiki()
Returns the wiki name.int
hashCode()
The hashcode is calculated as a XOR sum over all members of the Group.boolean
Returnstrue
if a Principal is a member of the group.members()
Returns the members of the group as an array of Principal objects.boolean
Removes a Principal from the group.void
setCreated
(Date date) Sets the created date.final void
setCreator
(String creator) Sets the creator of this Group.void
setLastModified
(Date date) Sets the last-modified datefinal void
setModifier
(String modifier) Sets the name of the user who last modified this group.toString()
Returns a string representation of the Group.
-
Constructor Details
-
Group
Protected constructor to prevent direct instantiation except by other package members. Callers should useGroupManager.parseGroup(String, String, boolean)
orGroupManager.parseGroup(org.apache.wiki.api.core.Context, boolean)
. instead.- Parameters:
name
- the name of the groupwiki
- the wiki the group belongs to
-
-
Method Details
-
add
Adds a Principal to the group.- Parameters:
user
- the principal to add- Returns:
true
if the operation was successful
-
clear
Clears all Principals from the group list. -
equals
Two DefaultGroups are equal if they contain identical member Principals and have the same name. -
hashCode
The hashcode is calculated as a XOR sum over all members of the Group. -
getCreated
Returns the creation date.- Returns:
- the creation date
-
getCreator
Returns the creator of this Group.- Returns:
- the creator
-
getLastModified
Returns the last-modified date.- Returns:
- the date and time of last modification
-
getModifier
Returns the name of the user who last modified this group.- Returns:
- the modifier
-
getName
The name of the group. This is set in the class constructor.- Returns:
- the name of the Group
-
getPrincipal
Returns the GroupPrincipal that represents this Group.- Returns:
- the group principal
-
getWiki
Returns the wiki name.- Returns:
- the wiki name
-
isMember
Returnstrue
if a Principal is a member of the group. Specifically, the Principal'sgetName()
method must return the same value as one of the Principals in the group member list. The Principal's type does not need to match.- Parameters:
principal
- the principal about whom membership status is sought- Returns:
- the result of the operation
-
members
Returns the members of the group as an array of Principal objects.- Returns:
- the members
-
remove
Removes a Principal from the group.- Parameters:
user
- the principal to remove- Returns:
true
if the operation was successful
-
setCreated
Sets the created date.- Parameters:
date
- the creation date
-
setCreator
Sets the creator of this Group.- Parameters:
creator
- the creator
-
setLastModified
Sets the last-modified date- Parameters:
date
- the last-modified date
-
setModifier
Sets the name of the user who last modified this group.- Parameters:
modifier
- the modifier
-
toString
Returns a string representation of the Group.
-