Package org.apache.wiki.auth
Class WikiPrincipal
java.lang.Object
org.apache.wiki.auth.WikiPrincipal
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<java.security.Principal>,java.security.Principal
public final class WikiPrincipal extends java.lang.Object implements java.security.Principal, java.lang.Comparable<java.security.Principal>, java.io.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 java.util.Comparator<java.security.Principal>COMPARATORStatic instance of Comparator that allows Principals to be sorted.static java.lang.StringFULL_NAMEWikiPrincipal type denoting a user's full name.static java.security.PrincipalGUESTRepresents an anonymous user.static java.lang.StringLOGIN_NAMEWikiPrincipal type denoting a user's login name.static java.lang.StringUNSPECIFIEDGeneric WikiPrincipal of unspecified type.static java.lang.StringWIKI_NAMEWikiPrincipal type denoting a user's wiki name. -
Constructor Summary
Constructors Modifier Constructor Description protectedWikiPrincipal()For serialization purposesWikiPrincipal(java.lang.String name)Constructs a new WikiPrincipal with a given name and a type ofUNSPECIFIED.WikiPrincipal(java.lang.String name, java.lang.String type)Constructs a new WikiPrincipal with a given name and optional type designator. -
Method Summary
Modifier and Type Method Description intcompareTo(java.security.Principal o)Allows comparisons to any other Principal objects.booleanequals(java.lang.Object obj)TwoWikiPrincipals are considered equal if their names are equal (case-sensitive).java.lang.StringgetName()Returns the wiki name of the Principal.java.lang.StringgetType()inthashCode()The hashCode() returned for the WikiPrincipal is the same as for its name.java.lang.StringtoString()Returns a human-readable representation of the object.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.security.Principal
implies
-
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 suppliedtypeparameter is notLOGIN_NAME,FULL_NAME,WIKI_NAMEorWIKI_NAME, this method throws anIllegalArgumentException.- Parameters:
name- the name of the Principaltype- the type for this principal, which may beLOGIN_NAME,FULL_NAME,WIKI_NAMEorWIKI_NAME.
-
-
Method Details
-
getName
Returns the wiki name of the Principal.- Specified by:
getNamein interfacejava.security.Principal- Returns:
- the name
-
equals
TwoWikiPrincipals are considered equal if their names are equal (case-sensitive).- Specified by:
equalsin interfacejava.security.Principal- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- the object to compare- Returns:
- the result of the equality test
-
hashCode
The hashCode() returned for the WikiPrincipal is the same as for its name.- Specified by:
hashCodein interfacejava.security.Principal- Overrides:
hashCodein classjava.lang.Object- Returns:
- the hash code
-
getType
- Returns:
- the type
-
toString
Returns a human-readable representation of the object.- Specified by:
toStringin interfacejava.security.Principal- Overrides:
toStringin classjava.lang.Object- Returns:
- the string representation
-
compareTo
Allows comparisons to any other Principal objects. Primary sorting order is by the principal name, returned by getName(), as defined byPrincipalComparator.- Specified by:
compareToin interfacejava.lang.Comparable<java.security.Principal>- Since:
- 2.7.0
-