Package org.apache.wiki.auth
Class WikiPrincipal
java.lang.Object
org.apache.wiki.auth.WikiPrincipal
- All Implemented Interfaces:
Serializable
,Comparable<Principal>
,Principal
public final class WikiPrincipal extends Object implements Principal, Comparable<Principal>, Serializable
A lightweight, immutable Principal class. WikiPrincipals can be created with and optional "type" to denote what type of user
profile Principal it represents (FULL_NAME, WIKI_NAME, LOGIN_NAME). Types are used to determine suitable user and login Principals in
classes like Session. However, the type property of a WikiPrincipal does not affect a WikiPrincipal's logical equality
or hash code; two WikiPrincipals with the same name but different types are still considered equal.
- Since:
- 2.2
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description static Comparator<Principal>
COMPARATOR
Static instance of Comparator that allows Principals to be sorted.static String
FULL_NAME
WikiPrincipal type denoting a user's full name.static Principal
GUEST
Represents an anonymous user.static String
LOGIN_NAME
WikiPrincipal type denoting a user's login name.static String
UNSPECIFIED
Generic WikiPrincipal of unspecified type.static String
WIKI_NAME
WikiPrincipal type denoting a user's wiki name. -
Constructor Summary
Constructors Modifier Constructor Description protected
WikiPrincipal()
For serialization purposesWikiPrincipal(String name)
Constructs a new WikiPrincipal with a given name and a type ofUNSPECIFIED
.WikiPrincipal(String name, String type)
Constructs a new WikiPrincipal with a given name and optional type designator. -
Method Summary
Modifier and Type Method Description int
compareTo(Principal o)
Allows comparisons to any other Principal objects.boolean
equals(Object obj)
TwoWikiPrincipal
s are considered equal if their names are equal (case-sensitive).String
getName()
Returns the wiki name of the Principal.String
getType()
int
hashCode()
The hashCode() returned for the WikiPrincipal is the same as for its name.String
toString()
Returns a human-readable representation of the object.
-
Field Details
-
GUEST
Represents an anonymous user. WikiPrincipals may be created with an optional type designator: LOGIN_NAME, WIKI_NAME, FULL_NAME or UNSPECIFIED. -
FULL_NAME
WikiPrincipal type denoting a user's full name.- See Also:
- Constant Field Values
-
LOGIN_NAME
WikiPrincipal type denoting a user's login name.- See Also:
- Constant Field Values
-
WIKI_NAME
WikiPrincipal type denoting a user's wiki name.- See Also:
- Constant Field Values
-
UNSPECIFIED
Generic WikiPrincipal of unspecified type.- See Also:
- Constant Field Values
-
COMPARATOR
Static instance of Comparator that allows Principals to be sorted.
-
-
Constructor Details
-
WikiPrincipal
protected WikiPrincipal()For serialization purposes -
WikiPrincipal
Constructs a new WikiPrincipal with a given name and a type ofUNSPECIFIED
.- Parameters:
name
- the name of the Principal
-
WikiPrincipal
Constructs a new WikiPrincipal with a given name and optional type designator. If the suppliedtype
parameter is notLOGIN_NAME
,FULL_NAME
,WIKI_NAME
orWIKI_NAME
, this method throws anIllegalArgumentException
.- Parameters:
name
- the name of the Principaltype
- the type for this principal, which may beLOGIN_NAME
,FULL_NAME
,WIKI_NAME
orWIKI_NAME
.
-
-
Method Details
-
getName
Returns the wiki name of the Principal. -
equals
TwoWikiPrincipal
s are considered equal if their names are equal (case-sensitive). -
hashCode
The hashCode() returned for the WikiPrincipal is the same as for its name. -
getType
- Returns:
- the type
-
toString
Returns a human-readable representation of the object. -
compareTo
Allows comparisons to any other Principal objects. Primary sorting order is by the principal name, returned by getName(), as defined byPrincipalComparator
.- Specified by:
compareTo
in interfaceComparable<Principal>
- Since:
- 2.7.0
-