Package org.apache.wiki.auth.authorize
Class Role
java.lang.Object
org.apache.wiki.auth.authorize.Role
- All Implemented Interfaces:
Serializable,Principal
public final class Role extends Object implements Principal, Serializable
A lightweight, immutable Principal that represents a built-in wiki role such
as Anonymous, Asserted and Authenticated. It can also represent dynamic roles
used by an external
Authorizer, such as a web
container.- Since:
- 2.3
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description static RoleALLAll users, regardless of authentication statusstatic RoleANONYMOUSIf the user hasn't supplied a namestatic RoleASSERTEDIf the user has supplied a cookie with a usernamestatic RoleAUTHENTICATEDIf the user has authenticated with the Container or UserDatabase -
Constructor Summary
-
Method Summary
Modifier and Type Method Description booleanequals(Object obj)Two Role objects are considered equal if their names are identical.StringgetName()Returns the name of the Principal.inthashCode()Returns a unique hashcode for the Role.static booleanisBuiltInRole(Role role)static booleanisReservedName(String name)Returnstrueif the supplied name is identical to the name of a built-in Role; that is, the value returned bygetName()for built-in RolesALL,ANONYMOUS,ASSERTED, orAUTHENTICATED.StringtoString()Returns a String representation of the role
-
Field Details
-
ALL
All users, regardless of authentication status -
ANONYMOUS
If the user hasn't supplied a name -
ASSERTED
If the user has supplied a cookie with a username -
AUTHENTICATED
If the user has authenticated with the Container or UserDatabase
-
-
Constructor Details
-
Role
protected Role()Create an empty Role. -
Role
Constructs a new Role with a given name.- Parameters:
name- the name of the Role
-
-
Method Details
-
isBuiltInRole
- Parameters:
role- the role to check- Returns:
- the result of the check
-
isReservedName
Returnstrueif the supplied name is identical to the name of a built-in Role; that is, the value returned bygetName()for built-in RolesALL,ANONYMOUS,ASSERTED, orAUTHENTICATED.- Parameters:
name- the name to be tested- Returns:
trueif the name is reserved;falseif not
-
hashCode
Returns a unique hashcode for the Role. -
equals
Two Role objects are considered equal if their names are identical.- Specified by:
equalsin interfacePrincipal- Overrides:
equalsin classObject- Parameters:
obj- the object to test- Returns:
trueif both objects are of type Role and have identical names- See Also:
Object.equals(java.lang.Object)
-
getName
Returns the name of the Principal. -
toString
Returns a String representation of the role- Specified by:
toStringin interfacePrincipal- Overrides:
toStringin classObject- Returns:
- the string representation of the role
- See Also:
Object.toString()
-