|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface SubjectContext
A SubjectContext
is a 'bucket' of data presented to a SecurityManager
which interprets
this data to construct Subject
instances. It is essentially a Map of data
with a few additional type-safe methods for easy retrieval of objects commonly used to construct Subject instances.
SecurityManager
or
SubjectFactory
implementation to construct Subject
instances.
SubjectContext
interface also allows for heuristic resolution of data used to construct a subject
instance. That is, if an attribute has not been explicitly provided via a setter method, the resolve*
methods can use heuristics to obtain that data in another way from other attributes.
For example, if one calls getPrincipals()
and no principals are returned, perhaps the principals exist
in the session
or another attribute in the context. The resolvePrincipals()
will know
how to resolve the principals based on heuristics. If the resolve*
methods return null
then the
data could not be achieved by any heuristics and must be considered as not available in the context.
The general idea is that the normal getters can be called to see if the value was explicitly set. The
resolve*
methods should be used when actually constructing the Subject
instance to ensure the most
specific/accurate data can be used.
USAGE: Most Shiro end-users will never use a SubjectContext
instance directly and instead will use a
Subject.Builder
(which internally uses a SubjectContext
) and build Subject
instances that
way.
SecurityManager.createSubject
,
SubjectFactory
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface java.util.Map |
---|
Map.Entry<K,V> |
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 interface java.util.Map |
---|
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values |
Method Detail |
---|
SecurityManager getSecurityManager()
Subject
instance or
null
if one has not yet been provided to this context.
Subject
instance or
null
if one has not yet been provided to this context.void setSecurityManager(SecurityManager securityManager)
Subject
instance
(typically used to support DelegatingSubject
implementations).
securityManager
- the SecurityManager instance that should be used to back the constructed Subject
instance.SecurityManager resolveSecurityManager()
SecurityManager
instance that should be used to back the constructed Subject
instance (typically used to support DelegatingSubject
implementations).
SecurityManager
instance that should be used to back the constructed Subject
instanceSerializable getSessionId()
Subject
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.
Subject
instance.void setSessionId(Serializable sessionId)
Subject
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.
sessionId
- the session id of the session that should be associated with the constructed Subject
instance.Subject getSubject()
Subject
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.
Subject
that may be in use at the time the new Subject
instance is
being created.void setSubject(Subject subject)
Subject
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.
subject
- the existing Subject
that may be in use at the time the new Subject
instance is
being created.PrincipalCollection getPrincipals()
Subject
should reflect.
Subject
should reflect.PrincipalCollection resolvePrincipals()
void setPrincipals(PrincipalCollection principals)
Subject
should reflect.
principals
- the principals (aka identity) that the constructed Subject
should reflect.Session getSession()
Session
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.
Session
to use when building the Subject
instance.void setSession(Session session)
Session
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.
session
- the Session
to use when building the Subject
instance.Session resolveSession()
boolean isAuthenticated()
true
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.
true
if the constructed Subject
should be considered authenticated, false
otherwise.void setAuthenticated(boolean authc)
Subject
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.
authc
- whether or not the constructed Subject
instance should be considered as authenticated.boolean isSessionCreationEnabled()
true
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.
true
if the constructed Subject
should be allowed to create sessions, false
otherwise.void setSessionCreationEnabled(boolean enabled)
Subject
instance should be allowed to create a session,
false
otherwise.
enabled
- whether or not the constructed Subject
instance should be allowed to create a session,
false
otherwise.boolean resolveAuthenticated()
AuthenticationInfo getAuthenticationInfo()
void setAuthenticationInfo(AuthenticationInfo info)
AuthenticationToken getAuthenticationToken()
void setAuthenticationToken(AuthenticationToken token)
String getHost()
Subject
's originating location.
Subject
's originating location.void setHost(String host)
Subject
's originating location.
host
- the host name or IP that should reflect the constructed Subject
's originating location.String resolveHost()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |