public class Group extends Object
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
:
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 WikiSession'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.
Modifier | Constructor and Description |
---|---|
protected |
Group(String name,
String wiki)
Protected constructor to prevent direct instantiation except by other
package members.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(Principal user)
Adds a Principal to the group.
|
void |
clear()
Clears all Principals from the group list.
|
boolean |
equals(Object o)
Two DefaultGroups are equal if they contain identical member Principals
and have the same name.
|
Date |
getCreated()
Returns the creation date.
|
String |
getCreator()
Returns the creator of this Group.
|
Date |
getLastModified()
Returns the last-modified date.
|
String |
getModifier()
Returns the name of the user who last modified this group.
|
String |
getName()
The name of the group.
|
Principal |
getPrincipal()
Returns the GroupPrincipal that represents this Group.
|
String |
getWiki()
Returns the wiki name.
|
int |
hashCode()
The hashcode is calculated as a XOR sum over all members of
the Group.
|
boolean |
isMember(Principal principal)
Returns
true if a Principal is a member of the group. |
Principal[] |
members()
Returns the members of the group as an array of Principal objects.
|
boolean |
remove(Principal user)
Removes a Principal from the group.
|
void |
setCreated(Date date)
Sets the created date.
|
void |
setCreator(String creator)
Sets the creator of this Group.
|
void |
setLastModified(Date date)
Sets the last-modified date
|
void |
setModifier(String modifier)
Sets the name of the user who last modified this group.
|
String |
toString()
Returns a string representation of the Group.
|
protected Group(String name, String wiki)
GroupManager.parseGroup(String, String, boolean)
or
GroupManager.parseGroup(org.apache.wiki.WikiContext, boolean)
.
instead.name
- the name of the groupwiki
- the wiki the group belongs topublic boolean add(Principal user)
user
- the principal to addtrue
if the operation was successfulpublic void clear()
public boolean equals(Object o)
public int hashCode()
public Date getCreated()
public final String getCreator()
public Date getLastModified()
public final String getModifier()
public String getName()
public Principal getPrincipal()
public boolean isMember(Principal principal)
true
if a Principal is a member of the group.
Specifically, the Principal's getName()
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.principal
- the principal about whom membeship status is soughtpublic Principal[] members()
public boolean remove(Principal user)
user
- the principal to removetrue
if the operation was successfulpublic void setCreated(Date date)
date
- the creation datepublic final void setCreator(String creator)
creator
- the creatorpublic void setLastModified(Date date)
date
- the last-modified datepublic final void setModifier(String modifier)
modifier
- the modifierpublic String toString()
toString
in class Object
Object.toString()
Copyright © 2001-2019 The Apache Software Foundation. All rights reserved.