Package org.apache.wiki.auth.authorize
Class Role
- java.lang.Object
-
- org.apache.wiki.auth.authorize.Role
-
- All Implemented Interfaces:
java.io.Serializable
,java.security.Principal
public final class Role extends java.lang.Object implements java.security.Principal, java.io.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 externalAuthorizer
, such as a web container.- Since:
- 2.3
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static Role
ALL
All users, regardless of authentication statusstatic Role
ANONYMOUS
If the user hasn't supplied a namestatic Role
ASSERTED
If the user has supplied a cookie with a usernamestatic Role
AUTHENTICATED
If the user has authenticated with the Container or UserDatabase
-
Constructor Summary
Constructors Constructor Description Role(java.lang.String name)
Constructs a new Role with a given name.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
Two Role objects are considered equal if their names are identical.java.lang.String
getName()
Returns the name of the Principal.int
hashCode()
Returns a unique hashcode for the Role.static boolean
isBuiltInRole(Role role)
static boolean
isReservedName(java.lang.String name)
Returnstrue
if 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
.java.lang.String
toString()
Returns a String representation of the role
-
-
-
Field Detail
-
AUTHENTICATED
public static final Role AUTHENTICATED
If the user has authenticated with the Container or UserDatabase
-
-
Constructor Detail
-
Role
public Role(java.lang.String name)
Constructs a new Role with a given name.- Parameters:
name
- the name of the Role
-
-
Method Detail
-
isBuiltInRole
public static boolean isBuiltInRole(Role role)
- Parameters:
role
- the role to check- Returns:
- the result of the check
-
isReservedName
public static boolean isReservedName(java.lang.String name)
Returnstrue
if 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:
true
if the name is reserved;false
if not
-
hashCode
public int hashCode()
Returns a unique hashcode for the Role.- Specified by:
hashCode
in interfacejava.security.Principal
- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- the hashcode
-
equals
public boolean equals(java.lang.Object obj)
Two Role objects are considered equal if their names are identical.- Specified by:
equals
in interfacejava.security.Principal
- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
- the object to test- Returns:
true
if both objects are of type Role and have identical names- See Also:
Object.equals(java.lang.Object)
-
getName
public java.lang.String getName()
Returns the name of the Principal.- Specified by:
getName
in interfacejava.security.Principal
- Returns:
- the name of the Role
-
toString
public java.lang.String toString()
Returns a String representation of the role- Specified by:
toString
in interfacejava.security.Principal
- Overrides:
toString
in classjava.lang.Object
- Returns:
- the string representation of the role
- See Also:
Object.toString()
-
-