public interface PrincipalMap extends PrincipalCollection, Map<String,Object>
PrincipalMap
is map of all of a subject's principals - its identifying attributes like username, userId,
etc.
The Map
methods allow you to interact with a unified representation of
all of the Subject's principals, even if they came from different realms. You can think of the Map
methods
as the general purpose API for a Subject's principals. That is, you can access a principal generally:
Object principal = subject.getPrincipals().get(principalName);For example, to get the Subject's username (if the username principal indeed exists and was populated by a Realm), you can do the following:
String username = (String)subject.getPrincipals().get("username");
Map
methods reflect
the the aggregate principals from all realms that authenticated the owning Subject
.
But in these multi-realm environments, it is often convenient or necessary to acquire only the principals contributed
by a specific realm (often in a realm implementation itself). This PrincipalMap
interface satisfies
those needs by providing additional realm-specific accessor/mutator methods.Modifier and Type | Method and Description |
---|---|
Object |
getRealmPrincipal(String realmName,
String realmPrincipal) |
Map<String,Object> |
getRealmPrincipals(String realmName) |
Object |
removeRealmPrincipal(String realmName,
String principalName) |
Object |
setRealmPrincipal(String realmName,
String principalName,
Object principal) |
Map<String,Object> |
setRealmPrincipals(String realmName,
Map<String,Object> principals) |
asList, asSet, byType, fromRealm, getPrimaryPrincipal, getRealmNames, isEmpty, oneByType
forEach, iterator, spliterator
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
Map<String,Object> getRealmPrincipals(String realmName)
Map<String,Object> setRealmPrincipals(String realmName, Map<String,Object> principals)
Object setRealmPrincipal(String realmName, String principalName, Object principal)
Object getRealmPrincipal(String realmName, String realmPrincipal)
Object removeRealmPrincipal(String realmName, String principalName)
Copyright © 2004-2016 The Apache Software Foundation. All Rights Reserved.