Package org.apache.shiro.subject
Interface PrincipalMap
-
- All Superinterfaces:
,
<,>
,
- All Known Implementing Classes:
SimplePrincipalMap
public interface PrincipalMap extends <,>
EXPERIMENTAL - DO NOT USE YET APrincipalMap
is map of all of a subject's principals - its identifying attributes like username, userId, etc. The 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 theMap
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");
Multi-Realm Environments
If your application uses multiple realms, theMap
methods reflect the the aggregate principals from all realms that authenticated the owningSubject
. 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). ThisPrincipalMap
interface satisfies those needs by providing additional realm-specific accessor/mutator methods.- Since:
- 1.2
- Author:
- Les Hazlewood
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description realmName, realmPrincipal)
<,>
realmName)
realmName, principalName)
realmName, principalName, principal)
<,>
realmName, <,> principals)
-
Methods inherited from interface org.apache.shiro.subject.PrincipalCollection
asList, asSet, byType, fromRealm, getPrimaryPrincipal, getRealmNames, isEmpty, oneByType
-
-
-
-
Method Detail
-
getRealmPrincipals
<,> getRealmPrincipals( realmName)
-
setRealmPrincipals
<,> setRealmPrincipals( realmName, <,> principals)
-
setRealmPrincipal
setRealmPrincipal( realmName, principalName, principal)
-
getRealmPrincipal
getRealmPrincipal( realmName, realmPrincipal)
-
removeRealmPrincipal
removeRealmPrincipal( realmName, principalName)
-
-