JSecurity

org.jsecurity.mgt
Interface SecurityManager

All Superinterfaces:
Authenticator, Authorizer, SessionFactory
All Known Implementing Classes:
AuthenticatingSecurityManager, AuthorizingSecurityManager, CachingSecurityManager, DefaultSecurityManager, DefaultWebSecurityManager, RealmSecurityManager, SessionsSecurityManager

public interface SecurityManager
extends Authenticator, Authorizer, SessionFactory

A SecurityManager executes all security operations for all Subjects (aka users) across a single application.

The interface itself primarily exists as a convenience - it extends the Authenticator, Authorizer, and SessionFactory interfaces, thereby consolidating these behaviors into a single point of reference. For most JSecurity usages, this simplifies configuration and tends to be a more convenient approach than referencing Authenticator, Authorizer, and SessionFactory instances seperately; instead one only needs to interact with a single SecurityManager instance.

In addition to the above three interfaces, three unique methods are provided by this interface by itself, login(org.jsecurity.authc.AuthenticationToken), logout(org.jsecurity.subject.PrincipalCollection) and getSubject(). A Subject executes authentication, authorization, and session operations for a single user, and as such can only be managed by A SecurityManager which is aware of all three functions. The three parent interfaces on the other hand do not 'know' about Subjects 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.

In that case, the application programmer can call the getSubject() method and then use that returned instance for continued interaction with JSecurity. If your application code does not have a direct handle to the application's SecurityManager, you can use SecurityUtils anywhere in your code to achieve the same result.

Framework developers on the other hand might find working with an actual SecurityManager useful.

Since:
0.2
Author:
Les Hazlewood
See Also:
DefaultSecurityManager

Method Summary
 Subject getSubject()
          Returns the Subject instance representing the currently executing user.
 Subject login(AuthenticationToken authenticationToken)
          Logs in a user, returning a Subject instance if the authentication is successful or throwing an AuthenticationException if it is not.
 void logout(PrincipalCollection subjectIdentifier)
          Logs out the specified Subject from the system.
 
Methods inherited from interface org.jsecurity.authc.Authenticator
authenticate
 
Methods inherited from interface org.jsecurity.authz.Authorizer
checkPermission, checkPermission, checkPermissions, checkPermissions, checkRole, checkRoles, hasAllRoles, hasRole, hasRoles, isPermitted, isPermitted, isPermitted, isPermitted, isPermittedAll, isPermittedAll
 
Methods inherited from interface org.jsecurity.session.SessionFactory
getSession, start
 

Method Detail

login

Subject login(AuthenticationToken authenticationToken)
              throws AuthenticationException
Logs in a user, returning a Subject instance if the authentication is successful or throwing an AuthenticationException 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 call Subject.login(authenticationToken) (usually after acquiring the Subject by calling SecurityUtils.getSubject()).

Framework developers on the other hand might find calling this method directly useful in certain cases.

Parameters:
authenticationToken - the token representing the Subject's principal(s) and credential(s)
Returns:
an authenticated Subject upon a successful attempt
Throws:
AuthenticationException - if the login attempt failed.
Since:
0.9

logout

void logout(PrincipalCollection subjectIdentifier)
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 Subject.logout(), not the SecurityManager directly.

Framework developers on the other hand might find calling this method directly useful in certain cases.

Parameters:
subjectIdentifier - the identifier of the subject/user to log out.
Since:
0.9
See Also:
getSubject()

getSubject

Subject getSubject()
Returns the Subject instance representing the currently executing user.

Returns:
the Subject instance representing the currently executing user.
Since:
0.9

JSecurity

Copyright © 2004-2008 JSecurity.