Package org.apache.shiro.mgt
Interface SecurityManager
-
- All Superinterfaces:
Authenticator
,Authorizer
,SessionManager
- All Known Implementing Classes:
AuthenticatingSecurityManager
,AuthorizingSecurityManager
,CachingSecurityManager
,DefaultSecurityManager
,RealmSecurityManager
,SessionsSecurityManager
public interface SecurityManager extends Authenticator, Authorizer, SessionManager
ASecurityManager
executes all security operations for all Subjects (aka users) across a single application. The interface itself primarily exists as a convenience - it extends theAuthenticator
,Authorizer
, andSessionManager
interfaces, thereby consolidating these behaviors into a single point of reference. For most Shiro usages, this simplifies configuration and tends to be a more convenient approach than referencingAuthenticator
,Authorizer
, andSessionManager
instances separately; instead one only needs to interact with a singleSecurityManager
instance. In addition to the above three interfaces, this interface provides a number of methods supportingSubject
behavior. ASubject
executes authentication, authorization, and session operations for a single user, and as such can only be managed byA SecurityManager
which is aware of all three functions. The three parent interfaces on the other hand do not 'know' aboutSubject
s to ensure a clean separation of concerns. Usage Note: In actuality the large majority of application programmers won't interact with a SecurityManager very often, if at all. Most application programmers only care about security operations for the currently executing user, usually attained by callingSecurityUtils.getSubject()
. Framework developers on the other hand might find working with an actual SecurityManager useful.- Since:
- 0.2
- See Also:
DefaultSecurityManager
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Subject
createSubject(SubjectContext context)
Creates aSubject
instance reflecting the specified contextual data.Subject
login(Subject subject, AuthenticationToken authenticationToken)
Logs in the specified Subject using the givenauthenticationToken
, returning an updated Subject instance reflecting the authenticated state if successful or throwingAuthenticationException
if it is not.void
logout(Subject subject)
Logs out the specified Subject from the system.-
Methods inherited from interface org.apache.shiro.authc.Authenticator
authenticate
-
Methods inherited from interface org.apache.shiro.authz.Authorizer
checkPermission, checkPermission, checkPermissions, checkPermissions, checkRole, checkRoles, checkRoles, hasAllRoles, hasRole, hasRoles, isPermitted, isPermitted, isPermitted, isPermitted, isPermittedAll, isPermittedAll
-
Methods inherited from interface org.apache.shiro.session.mgt.SessionManager
getSession, start
-
-
-
-
Method Detail
-
login
Subject login(Subject subject, AuthenticationToken authenticationToken) throws AuthenticationException
Logs in the specified Subject using the givenauthenticationToken
, returning an updated Subject instance reflecting the authenticated state if successful or throwingAuthenticationException
if it is not. Note that most application developers should probably not call this method directly unless they have a good reason for doing so. The preferred way to log in a Subject is to callsubject.
(usually after acquiring the Subject by callinglogin(authenticationToken)
SecurityUtils.getSubject()
). Framework developers on the other hand might find calling this method directly useful in certain cases.- Parameters:
subject
- the subject against which the authentication attempt will occurauthenticationToken
- the token representing the Subject's principal(s) and credential(s)- Returns:
- the subject instance reflecting the authenticated state after a successful attempt
- Throws:
AuthenticationException
- if the login attempt failed.- Since:
- 1.0
-
logout
void logout(Subject subject)
Logs out the specified Subject from the system. Note that most application developers should not call this method unless they have a good reason for doing so. The preferred way to logout a Subject is to call
, not theSubject.logout()
SecurityManager
directly. Framework developers on the other hand might find calling this method directly useful in certain cases.- Parameters:
subject
- the subject to log out.- Since:
- 1.0
-
createSubject
Subject createSubject(SubjectContext context)
Creates aSubject
instance reflecting the specified contextual data. The context can be anything needed by thisSecurityManager
to construct aSubject
instance. Most Shiro end-users will never call this method - it exists primarily for framework development and to support any underlying customSubjectFactory
implementations that may be used by theSecurityManager
.Usage
After calling this method, the returned instance is not bound to the application for further use. Callers are expected to know thatSubject
instances have local scope only and any other further use beyond the calling method must be managed explicitly.- Parameters:
context
- any data needed to direct how the Subject should be constructed.- Returns:
- the
Subject
instance reflecting the specified initialization data. - Since:
- 1.0
- See Also:
SubjectFactory.createSubject(SubjectContext)
,Subject.Builder
-
-