public class SimplePrincipalCollection extends Objectimplements MutablePrincipalCollection
MutablePrincipalCollection interface that tracks principals internally by storing them in a
LinkedHashMap.
| Constructor and Description |
|---|
SimplePrincipalCollection()
|
SimplePrincipalCollection(Collection
|
SimplePrincipalCollection(Object
|
SimplePrincipalCollection(PrincipalCollection
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(Object
Adds the given principal to this collection.
|
void |
addAll(Collection
Adds all of the principals in the given collection to this collection.
|
void |
addAll(PrincipalCollection
Adds all of the principals from the given principal collection to this collection.
|
List |
asList()
Returns a single Subject's principals retrieved from all configured Realms as a List, or an empty List if there are not any principals.
|
Set |
asSet()
Returns a single Subject's principals retrieved from all configured Realms as a Set, or an empty Set if there are not any principals.
|
<T> Collection |
byType(Class
Returns all principals assignable from the specified type, or an empty Collection if no principals of that type are contained.
|
void |
clear()
Removes all Principals in this collection.
|
boolean |
equals(Object
|
Collection |
fromRealm(String
Returns a single Subject's principals retrieved from the specified Realm
only as a Collection, or an empty Collection if there are not any principals from that realm.
|
Object |
getPrimaryPrincipal()
Returns the first available principal from any of the
Realm principals, or
null if there are no principals yet.
|
protected Collection |
getPrincipalsLazy(String
|
Set |
getRealmNames()
Returns the realm names that this collection has principals for.
|
int |
hashCode()
|
boolean |
isEmpty()
Returns
true if this collection is empty,
false otherwise.
|
Iterator |
iterator()
|
<T> T |
oneByType(Class
Returns the first discovered principal assignable from the specified type, or
null if there are none of the specified type.
|
String |
toString()
Returns a simple string representation suitable for printing.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, waitforEach, spliteratorpublic SimplePrincipalCollection()
public SimplePrincipalCollection(Collectionprincipals, String realmName)
public SimplePrincipalCollection(PrincipalCollectionprincipals)
protected CollectiongetPrincipalsLazy(String realmName)
public ObjectgetPrimaryPrincipal()
Realm principals, or
null if there are no principals yet.
The 'first available principal' is interpreted as the principal that would be returned by
iterator().next().
getPrimaryPrincipal in interface
PrincipalCollection
public void add(Objectprincipal, String realmName)
MutablePrincipalCollection
add in interface
MutablePrincipalCollection
principal - the principal to be added.
realmName - the realm this principal came from.
public void addAll(Collectionprincipals, String realmName)
MutablePrincipalCollection
addAll in interface
MutablePrincipalCollection
principals - the principals to be added.
realmName - the realm these principals came from.
public void addAll(PrincipalCollectionprincipals)
MutablePrincipalCollection
addAll in interface
MutablePrincipalCollection
principals - the principals to add.
public <T> T oneByType(Class<T> type)
PrincipalCollection
null if there are none of the specified type.
Note that this will return
null if the 'owning' subject has not yet logged in.
oneByType in interface
PrincipalCollection
type - the type of the principal that should be returned.
null if there isn't one of the specified type.
public <T> Collection<T> byType(Class <T> type)
PrincipalCollection
byType in interface
PrincipalCollection
type - the type of the principals that should be returned.
public ListasList()
PrincipalCollection
asList in interface
PrincipalCollection
public SetasSet()
PrincipalCollection
asSet in interface
PrincipalCollection
public CollectionfromRealm(String realmName)
PrincipalCollection
fromRealm in interface
PrincipalCollection
realmName - the name of the Realm from which the principals were retrieved.
public Set<String > getRealmNames()
PrincipalCollection
getRealmNames in interface
PrincipalCollection
public boolean isEmpty()
PrincipalCollection
true if this collection is empty,
false otherwise.
isEmpty in interface
PrincipalCollection
true if this collection is empty,
false otherwise.
public void clear()
MutablePrincipalCollection
public Iteratoriterator()
public boolean equals(Objecto)
public int hashCode()