Class CompositePrincipal
java.lang.Object
org.wildfly.security.auth.principal.CompositePrincipal
- All Implemented Interfaces:
Serializable,Iterable<Principal>,Principal
public final class CompositePrincipal
extends Object
implements Principal, Serializable, Iterable<Principal>
A composite principal that consists of multiple elements of possibly disparate type. This may be used to locate
a unique principal in a realm which is backed by a database that uses a composite key; in this case, the constituent
principals may be names or numbers, or a combination of both.
- Author:
- David M. Lloyd
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCompositePrincipal(Principal... principals) Construct a new instance.CompositePrincipal(Collection<Principal> principals) Construct a new instance. -
Method Summary
Modifier and TypeMethodDescriptionbooleanDetermine whether this composite principal contains the a nested principal of the given type class.booleanDetermine whether this composite principal contains the given nested principal.booleanDetermine whether this principal is equal to the given object.booleanequals(CompositePrincipal obj) Determine whether this principal is equal to the given object.get(int idx) Get the principal at the given index.<P extends Principal>
PGet the principal at the given index, if it is of the given type.<P extends Principal>
PGet the first principal with the given type, if any.getName()Get the principal name.inthashCode()Get the hash code of this principal.iterator()Get an iterator over this principal.intsize()Get the number of nested principals.toString()Get this principal as a string.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
CompositePrincipal
Construct a new instance.- Parameters:
principals- the collection of principals to use (must not benull)
-
CompositePrincipal
Construct a new instance.- Parameters:
principals- the principals to use (must not benull)
-
-
Method Details
-
getName
Get the principal name. -
contains
Determine whether this composite principal contains the given nested principal.- Parameters:
principal- the nested principal (must not benull)- Returns:
trueif this principal contains the nested principal,falseotherwise
-
contains
Determine whether this composite principal contains the a nested principal of the given type class.- Parameters:
type- the nested principal type class (must not benull)- Returns:
trueif this principal contains a nested principal of the given type,falseotherwise
-
size
public int size()Get the number of nested principals.- Returns:
- the number of nested principals
-
get
Get the principal at the given index.- Parameters:
idx- the index- Returns:
- the principal at the given index (not
null) - Throws:
IndexOutOfBoundsException- if the given index is less than zero or greater than or equal tosize()
-
get
Get the principal at the given index, if it is of the given type.- Type Parameters:
P- the principal type- Parameters:
idx- the indextype- the principal type class (must not benull)- Returns:
- the principal at the given index or
nullif that principal is not of the given type - Throws:
IndexOutOfBoundsException- if the given index is less than zero or greater than or equal tosize()
-
get
Get the first principal with the given type, if any.- Type Parameters:
P- the principal type- Parameters:
type- the principal type class (must not benull)- Returns:
- the first principal with the given type, or
nullif none was found - Throws:
IndexOutOfBoundsException- if the given index is less than zero or greater than or equal tosize()
-
iterator
Get an iterator over this principal. -
equals
Determine whether this principal is equal to the given object. -
equals
Determine whether this principal is equal to the given object.- Parameters:
obj- the object- Returns:
trueif they are equal,falseotherwise
-
hashCode
public int hashCode()Get the hash code of this principal. -
toString
Get this principal as a string.
-