public class SimplePrincipalCollection extends Object implements MutablePrincipalCollection
MutablePrincipalCollection interface that tracks principals internally
by storing them in a LinkedHashMap.| Constructor and Description |
|---|
SimplePrincipalCollection() |
SimplePrincipalCollection(Collection principals,
String realmName) |
SimplePrincipalCollection(Object principal,
String realmName) |
SimplePrincipalCollection(PrincipalCollection principals) |
| Modifier and Type | Method and Description |
|---|---|
void |
add(Object principal,
String realmName)
Adds the given principal to this collection.
|
void |
addAll(Collection principals,
String realmName)
Adds all of the principals in the given collection to this collection.
|
void |
addAll(PrincipalCollection principals)
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<T> |
byType(Class<T> type)
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 o) |
Collection |
fromRealm(String realmName)
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 realmName) |
Set<String> |
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<T> type)
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(Collection principals, String realmName)
public SimplePrincipalCollection(PrincipalCollection principals)
protected Collection getPrincipalsLazy(String realmName)
public Object getPrimaryPrincipal()
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 PrincipalCollectionpublic void add(Object principal, String realmName)
MutablePrincipalCollectionadd in interface MutablePrincipalCollectionprincipal - the principal to be added.realmName - the realm this principal came from.public void addAll(Collection principals, String realmName)
MutablePrincipalCollectionaddAll in interface MutablePrincipalCollectionprincipals - the principals to be added.realmName - the realm these principals came from.public void addAll(PrincipalCollection principals)
MutablePrincipalCollectionaddAll in interface MutablePrincipalCollectionprincipals - the principals to add.public <T> T oneByType(Class<T> type)
PrincipalCollectionnull 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 PrincipalCollectiontype - 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)
PrincipalCollectionbyType in interface PrincipalCollectiontype - the type of the principals that should be returned.public List asList()
PrincipalCollectionasList in interface PrincipalCollectionpublic Set asSet()
PrincipalCollectionasSet in interface PrincipalCollectionpublic Collection fromRealm(String realmName)
PrincipalCollectionfromRealm in interface PrincipalCollectionrealmName - the name of the Realm from which the principals were retrieved.public Set<String> getRealmNames()
PrincipalCollectiongetRealmNames in interface PrincipalCollectionpublic boolean isEmpty()
PrincipalCollectiontrue if this collection is empty, false otherwise.isEmpty in interface PrincipalCollectiontrue if this collection is empty, false otherwise.public void clear()
MutablePrincipalCollectionclear in interface MutablePrincipalCollectionCopyright © 2004-2016 The Apache Software Foundation. All Rights Reserved.