|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.shiro.util.MapContext
org.apache.shiro.subject.support.DefaultSubjectContext
public class DefaultSubjectContext
Default implementation of the SubjectContext interface. Note that the getters and setters are not
simple pass-through methods to an underlying attribute; the getters will employ numerous heuristics to acquire
their data attribute as best as possible (for example, if getPrincipals() is invoked, if the principals aren't
in the backing map, it might check to see if there is a subject or session in the map and attempt to acquire the
principals from those objects).
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface java.util.Map |
|---|
Map.Entry<K,V> |
| Field Summary | |
|---|---|
static String |
AUTHENTICATED_SESSION_KEY
The session key that is used to store whether or not the user is authenticated. |
static String |
PRINCIPALS_SESSION_KEY
The session key that is used to store subject principals. |
static String |
SESSION_CREATION_ENABLED
|
| Constructor Summary | |
|---|---|
DefaultSubjectContext()
|
|
DefaultSubjectContext(SubjectContext ctx)
|
|
| Method Summary | |
|---|---|
AuthenticationInfo |
getAuthenticationInfo()
|
AuthenticationToken |
getAuthenticationToken()
|
String |
getHost()
Returns the host name or IP that should reflect the constructed Subject's originating location. |
PrincipalCollection |
getPrincipals()
Returns the principals (aka identity) that the constructed Subject should reflect. |
SecurityManager |
getSecurityManager()
Returns the SecurityManager instance that should be used to back the constructed Subject instance or
null if one has not yet been provided to this context. |
Session |
getSession()
Returns the Session to use when building the Subject instance. |
Serializable |
getSessionId()
Returns the session id of the session that should be associated with the constructed Subject instance. |
Subject |
getSubject()
Returns any existing Subject that may be in use at the time the new Subject instance is
being created. |
boolean |
isAuthenticated()
Returns true if the constructed Subject should be considered authenticated, false
otherwise. |
boolean |
isSessionCreationEnabled()
Returns true if the constructed Subject should be allowed to create a session, false
otherwise. |
boolean |
resolveAuthenticated()
|
String |
resolveHost()
|
PrincipalCollection |
resolvePrincipals()
|
SecurityManager |
resolveSecurityManager()
Resolves the SecurityManager instance that should be used to back the constructed Subject
instance (typically used to support DelegatingSubject implementations). |
Session |
resolveSession()
|
void |
setAuthenticated(boolean authc)
Sets whether or not the constructed Subject instance should be considered as authenticated. |
void |
setAuthenticationInfo(AuthenticationInfo info)
|
void |
setAuthenticationToken(AuthenticationToken token)
|
void |
setHost(String host)
Sets the host name or IP that should reflect the constructed Subject's originating location. |
void |
setPrincipals(PrincipalCollection principals)
Sets the principals (aka identity) that the constructed Subject should reflect. |
void |
setSecurityManager(SecurityManager securityManager)
Sets the SecurityManager instance that should be used to back the constructed Subject instance
(typically used to support DelegatingSubject implementations). |
void |
setSession(Session session)
Sets the Session to use when building the Subject instance. |
void |
setSessionCreationEnabled(boolean enabled)
Sets whether or not the constructed Subject instance should be allowed to create a session,
false otherwise. |
void |
setSessionId(Serializable sessionId)
Sets the session id of the session that should be associated with the constructed Subject instance. |
void |
setSubject(Subject subject)
Sets the existing Subject that may be in use at the time the new Subject instance is
being created. |
| Methods inherited from class org.apache.shiro.util.MapContext |
|---|
clear, containsKey, containsValue, entrySet, get, getTypedValue, isEmpty, keySet, nullSafePut, put, putAll, remove, size, 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 |
|---|
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values |
| Field Detail |
|---|
public static final String SESSION_CREATION_ENABLED
public static final String PRINCIPALS_SESSION_KEY
public static final String AUTHENTICATED_SESSION_KEY
| Constructor Detail |
|---|
public DefaultSubjectContext()
public DefaultSubjectContext(SubjectContext ctx)
| Method Detail |
|---|
public SecurityManager getSecurityManager()
SubjectContextSubject instance or
null if one has not yet been provided to this context.
getSecurityManager in interface SubjectContextSubject instance or
null if one has not yet been provided to this context.public void setSecurityManager(SecurityManager securityManager)
SubjectContextSubject instance
(typically used to support DelegatingSubject implementations).
setSecurityManager in interface SubjectContextsecurityManager - the SecurityManager instance that should be used to back the constructed Subject
instance.public SecurityManager resolveSecurityManager()
SubjectContextSecurityManager instance that should be used to back the constructed Subject
instance (typically used to support DelegatingSubject implementations).
resolveSecurityManager in interface SubjectContextSecurityManager instance that should be used to back the constructed Subject
instancepublic Serializable getSessionId()
SubjectContextSubject instance.
The construction process is expected to resolve the session with the specified id and then construct the Subject
instance based on the resolved session.
getSessionId in interface SubjectContextSubject instance.public void setSessionId(Serializable sessionId)
SubjectContextSubject instance.
The construction process is expected to resolve the session with the specified id and then construct the Subject
instance based on the resolved session.
setSessionId in interface SubjectContextsessionId - the session id of the session that should be associated with the constructed Subject
instance.public Subject getSubject()
SubjectContextSubject that may be in use at the time the new Subject instance is
being created.
This is typically used in the case where the existing Subject instance returned by
this method is unauthenticated and a new Subject instance is being created to reflect a successful
authentication - you want to return most of the state of the previous Subject instance when creating the
newly authenticated instance.
getSubject in interface SubjectContextSubject that may be in use at the time the new Subject instance is
being created.public void setSubject(Subject subject)
SubjectContextSubject that may be in use at the time the new Subject instance is
being created.
This is typically used in the case where the existing Subject instance returned by
this method is unauthenticated and a new Subject instance is being created to reflect a successful
authentication - you want to return most of the state of the previous Subject instance when creating the
newly authenticated instance.
setSubject in interface SubjectContextsubject - the existing Subject that may be in use at the time the new Subject instance is
being created.public PrincipalCollection getPrincipals()
SubjectContextSubject should reflect.
getPrincipals in interface SubjectContextSubject should reflect.public void setPrincipals(PrincipalCollection principals)
SubjectContextSubject should reflect.
setPrincipals in interface SubjectContextprincipals - the principals (aka identity) that the constructed Subject should reflect.public PrincipalCollection resolvePrincipals()
resolvePrincipals in interface SubjectContextpublic Session getSession()
SubjectContextSession to use when building the Subject instance. Note that it is more
common to specify a sessionId to acquire the desired session rather than having to
construct a Session to be returned by this method.
getSession in interface SubjectContextSession to use when building the Subject instance.public void setSession(Session session)
SubjectContextSession to use when building the Subject instance. Note that it is more
common to specify a sessionId to automatically resolve the desired session rather than
constructing a Session to call this method.
setSession in interface SubjectContextsession - the Session to use when building the Subject instance.public Session resolveSession()
resolveSession in interface SubjectContextpublic boolean isSessionCreationEnabled()
SubjectContexttrue if the constructed Subject should be allowed to create a session, false
otherwise. Shiro's configuration defaults to true as most applications find value in Sessions.
isSessionCreationEnabled in interface SubjectContexttrue if the constructed Subject should be allowed to create sessions, false
otherwise.public void setSessionCreationEnabled(boolean enabled)
SubjectContextSubject instance should be allowed to create a session,
false otherwise.
setSessionCreationEnabled in interface SubjectContextenabled - whether or not the constructed Subject instance should be allowed to create a session,
false otherwise.public boolean isAuthenticated()
SubjectContexttrue if the constructed Subject should be considered authenticated, false
otherwise. Be careful setting this value to true - you should know what you are doing and have a good
reason for ignoring Shiro's default authentication state mechanisms.
isAuthenticated in interface SubjectContexttrue if the constructed Subject should be considered authenticated, false
otherwise.public void setAuthenticated(boolean authc)
SubjectContextSubject instance should be considered as authenticated. Be careful
when specifying true - you should know what you are doing and have a good reason for ignoring Shiro's
default authentication state mechanisms.
setAuthenticated in interface SubjectContextauthc - whether or not the constructed Subject instance should be considered as authenticated.public boolean resolveAuthenticated()
resolveAuthenticated in interface SubjectContextpublic AuthenticationInfo getAuthenticationInfo()
getAuthenticationInfo in interface SubjectContextpublic void setAuthenticationInfo(AuthenticationInfo info)
setAuthenticationInfo in interface SubjectContextpublic AuthenticationToken getAuthenticationToken()
getAuthenticationToken in interface SubjectContextpublic void setAuthenticationToken(AuthenticationToken token)
setAuthenticationToken in interface SubjectContextpublic String getHost()
SubjectContextSubject's originating location.
getHost in interface SubjectContextSubject's originating location.public void setHost(String host)
SubjectContextSubject's originating location.
setHost in interface SubjectContexthost - the host name or IP that should reflect the constructed Subject's originating location.public String resolveHost()
resolveHost in interface SubjectContext
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||