org.apache.wiki.auth.authorize
Class Role

java.lang.Object
  extended by 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
static Role ALL
          All users, regardless of authentication status
static Role ANONYMOUS
          If the user hasn't supplied a name
static Role ASSERTED
          If the user has supplied a cookie with a username
static Role AUTHENTICATED
          If the user has authenticated with the Container or UserDatabase
 
Constructor Summary
protected Role()
          Create an empty Role.
  Role(String name)
          Constructs a new Role with a given name.
 
Method Summary
 boolean equals(Object obj)
          Two Role objects are considered equal if their names are identical.
 String getName()
          Returns the name of the Principal.
 int hashCode()
          Returns a unique hashcode for the Role.
static boolean isBuiltInRole(Role role)
          Returns true if a supplied Role is a built-in Role: ALL, ANONYMOUS, ASSERTED, or AUTHENTICATED.
static boolean isReservedName(String name)
          Returns true if the supplied name is identical to the name of a built-in Role; that is, the value returned by getName() for built-in Roles ALL, ANONYMOUS, ASSERTED, or AUTHENTICATED.
 String toString()
          Returns a String representation of the role
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ALL

public static final Role ALL
All users, regardless of authentication status


ANONYMOUS

public static final Role ANONYMOUS
If the user hasn't supplied a name


ASSERTED

public static final Role ASSERTED
If the user has supplied a cookie with a username


AUTHENTICATED

public static final Role AUTHENTICATED
If the user has authenticated with the Container or UserDatabase

Constructor Detail

Role

protected Role()
Create an empty Role.


Role

public Role(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)
Returns true if a supplied Role is a built-in Role: ALL, ANONYMOUS, ASSERTED, or AUTHENTICATED.

Parameters:
role - the role to check
Returns:
the result of the check

isReservedName

public static boolean isReservedName(String name)
Returns true if the supplied name is identical to the name of a built-in Role; that is, the value returned by getName() for built-in Roles ALL, ANONYMOUS, ASSERTED, or AUTHENTICATED.

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 interface Principal
Overrides:
hashCode in class Object
Returns:
the hashcode

equals

public boolean equals(Object obj)
Two Role objects are considered equal if their names are identical.

Specified by:
equals in interface Principal
Overrides:
equals in class 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 String getName()
Returns the name of the Principal.

Specified by:
getName in interface Principal
Returns:
the name of the Role

toString

public String toString()
Returns a String representation of the role

Specified by:
toString in interface Principal
Overrides:
toString in class Object
Returns:
the string representation of the role
See Also:
Object.toString()


Copyright © {inceptionYear}-2014 The Apache Software Foundation. All rights reserved.