|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.shiro.subject.SimplePrincipalMap
public class SimplePrincipalMap
Default implementation of the PrincipalMap interface.
*EXPERIMENTAL for Shiro 1.2 - DO NOT USE YET*
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface java.util.Map |
|---|
Map.Entry<K,V> |
| Constructor Summary | |
|---|---|
SimplePrincipalMap()
|
|
SimplePrincipalMap(Map<String,Map<String,Object>> backingMap)
|
|
| Method Summary | ||
|---|---|---|
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()
|
|
boolean |
containsKey(Object o)
|
|
boolean |
containsValue(Object o)
|
|
protected Map<String,Object> |
ensureCombinedPrincipals()
|
|
Set<Map.Entry<String,Object>> |
entrySet()
|
|
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 |
get(Object o)
|
|
Object |
getPrimaryPrincipal()
Returns the primary principal used application-wide to uniquely identify the owning account/Subject. |
|
Set<String> |
getRealmNames()
Returns the realm names that this collection has principals for. |
|
Object |
getRealmPrincipal(String realmName,
String principalName)
|
|
Map<String,Object> |
getRealmPrincipals(String name)
|
|
boolean |
isEmpty()
Returns true if this collection is empty, false otherwise. |
|
Iterator |
iterator()
|
|
Set<String> |
keySet()
|
|
|
oneByType(Class<T> type)
Returns the first discovered principal assignable from the specified type, or null if there are none
of the specified type. |
|
Object |
put(String s,
Object o)
|
|
void |
putAll(Map<? extends String,?> map)
|
|
Object |
remove(Object o)
|
|
Object |
removeRealmPrincipal(String realmName,
String principalName)
|
|
Object |
setRealmPrincipal(String realmName,
String principalName,
Object principal)
|
|
Map<String,Object> |
setRealmPrincipals(String realmName,
Map<String,Object> principals)
|
|
int |
size()
|
|
Collection<Object> |
values()
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.util.Map |
|---|
equals, hashCode |
| Constructor Detail |
|---|
public SimplePrincipalMap()
public SimplePrincipalMap(Map<String,Map<String,Object>> backingMap)
| Method Detail |
|---|
public int size()
size in interface Map<String,Object>protected Map<String,Object> ensureCombinedPrincipals()
public boolean containsKey(Object o)
containsKey in interface Map<String,Object>public boolean containsValue(Object o)
containsValue in interface Map<String,Object>public Object get(Object o)
get in interface Map<String,Object>
public Object put(String s,
Object o)
put in interface Map<String,Object>public Object remove(Object o)
remove in interface Map<String,Object>public void putAll(Map<? extends String,?> map)
putAll in interface Map<String,Object>public Set<String> keySet()
keySet in interface Map<String,Object>public Collection<Object> values()
values in interface Map<String,Object>public Set<Map.Entry<String,Object>> entrySet()
entrySet in interface Map<String,Object>public void clear()
clear in interface Map<String,Object>public Object getPrimaryPrincipal()
PrincipalCollectionUUIDlong value such as a surrogate primary key in a relational databaseRealm application, typically there is only ever one unique principal to retain and that
is the value returned from this method. However, in a multi-Realm application, where the
PrincipalCollection might retain principals across more than one realm, the value returned from this
method should be the single principal that uniquely identifies the subject for the entire application.
That value is of course application specific, but most applications will typically choose one of the primary
principals from one of the Realms.
Shiro's default implementations of this interface make this
assumption by usually simply returning Iterable.iterator().next(), which just
returns the first returned principal obtained from the first consulted/configured Realm during the
authentication attempt. This means in a multi-Realm application, Realm configuraiton order
matters if you want to retain this default heuristic.
If this heuristic is not sufficient, most Shiro end-users will need to implement a custom
AuthenticationStrategy. An AuthenticationStrategy has exact control
over the PrincipalCollection returned at the end of an authentication attempt via the
AuthenticationStrategy#afterAllAttempts
implementation.
getPrimaryPrincipal in interface PrincipalCollectionpublic <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 Map<String,Object>isEmpty in interface PrincipalCollectiontrue if this collection is empty, false otherwise.public Iterator iterator()
iterator in interface Iterablepublic Map<String,Object> getRealmPrincipals(String name)
getRealmPrincipals in interface PrincipalMap
public Map<String,Object> setRealmPrincipals(String realmName,
Map<String,Object> principals)
setRealmPrincipals in interface PrincipalMap
public Object setRealmPrincipal(String realmName,
String principalName,
Object principal)
setRealmPrincipal in interface PrincipalMap
public Object getRealmPrincipal(String realmName,
String principalName)
getRealmPrincipal in interface PrincipalMap
public Object removeRealmPrincipal(String realmName,
String principalName)
removeRealmPrincipal in interface PrincipalMap
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||