|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.shiro.subject.SimplePrincipalCollection
public class SimplePrincipalCollection
A simple implementation of the MutablePrincipalCollection interface that tracks principals internally
by storing them in a LinkedHashMap.
| Constructor Summary | |
|---|---|
SimplePrincipalCollection()
|
|
SimplePrincipalCollection(Collection principals,
String realmName)
|
|
SimplePrincipalCollection(Object principal,
String realmName)
|
|
SimplePrincipalCollection(PrincipalCollection principals)
|
|
| Method Summary | ||
|---|---|---|
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. |
|
|
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()
|
|
|
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. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public SimplePrincipalCollection()
public SimplePrincipalCollection(Object principal,
String realmName)
public SimplePrincipalCollection(Collection principals,
String realmName)
public SimplePrincipalCollection(PrincipalCollection principals)
| Method Detail |
|---|
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 PrincipalCollection
public void add(Object principal,
String realmName)
MutablePrincipalCollection
add in interface MutablePrincipalCollectionprincipal - the principal to be added.realmName - the realm this principal came from.
public void addAll(Collection principals,
String realmName)
MutablePrincipalCollection
addAll in interface MutablePrincipalCollectionprincipals - the principals to be added.realmName - the realm these principals came from.public void addAll(PrincipalCollection principals)
MutablePrincipalCollection
addAll 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)
PrincipalCollection
byType in interface PrincipalCollectiontype - the type of the principals that should be returned.
public List asList()
PrincipalCollection
asList in interface PrincipalCollectionpublic Set asSet()
PrincipalCollection
asSet in interface PrincipalCollectionpublic Collection fromRealm(String realmName)
PrincipalCollection
fromRealm in interface PrincipalCollectionrealmName - the name of the Realm from which the principals were retrieved.
public Set<String> getRealmNames()
PrincipalCollection
getRealmNames 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()
MutablePrincipalCollection
clear in interface MutablePrincipalCollectionpublic Iterator iterator()
iterator in interface Iterablepublic boolean equals(Object o)
equals in class Objectpublic int hashCode()
hashCode in class Objectpublic String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||