org.jboss.seam.security
Class IdentityImpl

java.lang.Object
  extended by org.jboss.seam.security.IdentityImpl
All Implemented Interfaces:
Serializable, Identity

@Named(value="identity")
@SessionScoped
public class IdentityImpl
extends Object
implements Identity, Serializable

Identity implementation for authorization and authentication via Seam security.

Author:
Shane Bryzak
See Also:
Serialized Form

Field Summary
protected static boolean securityEnabled
           
 
Constructor Summary
IdentityImpl()
           
 
Method Summary
 boolean addGroup(String name, String groupType)
           
 boolean addRole(String roleType, String group, String groupType)
           
protected  boolean authenticate()
           
 void checkGroup(String group, String groupType)
           
 void checkPermission(Object target, String action)
           
 void checkRestriction(String expr)
           
 void checkRole(String roleType, String group, String groupType)
           
protected  void deferredAuthenticationObserver(DeferredAuthenticationEvent event)
           
 void filterByPermission(Collection<?> collection, String action)
           
 String getAuthenticatorName()
           
 Set<org.picketlink.idm.api.Group> getGroups()
           
 Set<org.picketlink.idm.api.Role> getRoles()
           
 org.picketlink.idm.api.User getUser()
           
 boolean hasPermission(Object target, String action)
           
 boolean hasRole(String roleType, String group, String groupType)
           
 boolean inGroup(String name, String groupType)
           
 boolean isLoggedIn()
           
static boolean isSecurityEnabled()
           
 boolean isVerified()
           
 String login()
          Performs an authorization check, based on the specified security expression string.
 void logout()
           
protected  Authenticator lookupAuthenticator()
          Returns an Authenticator instance to be used for authentication.
protected  void postAuthenticate()
          Extracts the principal from the subject, and uses it to create the User object.
protected  void preAuthenticate()
          Clears any roles added by calling addRole() while not authenticated.
 void quietLogin()
           
 void removeGroup(String name, String groupType)
           
 void removeRole(String roleType, String group, String groupType)
          Removes a role from the authenticated user
 void runAs(RunAsOperation operation)
           
 void setAuthenticatorName(String authenticatorName)
           
static void setSecurityEnabled(boolean enabled)
           
 boolean tryLogin()
           
 void unAuthenticate()
          Resets all security state and credentials
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

securityEnabled

protected static boolean securityEnabled
Constructor Detail

IdentityImpl

public IdentityImpl()
Method Detail

isSecurityEnabled

public static boolean isSecurityEnabled()

setSecurityEnabled

public static void setSecurityEnabled(boolean enabled)

isLoggedIn

public boolean isLoggedIn()
Specified by:
isLoggedIn in interface Identity

getAuthenticatorName

public String getAuthenticatorName()

setAuthenticatorName

public void setAuthenticatorName(String authenticatorName)

tryLogin

public boolean tryLogin()
Specified by:
tryLogin in interface Identity

login

public String login()
Performs an authorization check, based on the specified security expression string.

Specified by:
login in interface Identity
Parameters:
expr - The security expression string to evaluate
Throws:
NotLoggedInException - Thrown if the authorization check fails and the user is not authenticated
AuthorizationException - Thrown if the authorization check fails and the user is authenticated

quietLogin

public void quietLogin()
Specified by:
quietLogin in interface Identity

authenticate

protected boolean authenticate()
                        throws AuthenticationException
Throws:
AuthenticationException

preAuthenticate

protected void preAuthenticate()
Clears any roles added by calling addRole() while not authenticated. This method may be overridden by a subclass if different pre-authentication logic should occur.


deferredAuthenticationObserver

protected void deferredAuthenticationObserver(@Observes
                                              DeferredAuthenticationEvent event)

postAuthenticate

protected void postAuthenticate()
Extracts the principal from the subject, and uses it to create the User object. This method may be overridden by a subclass if different post-authentication logic should occur.


lookupAuthenticator

protected Authenticator lookupAuthenticator()
                                     throws AuthenticationException
Returns an Authenticator instance to be used for authentication. The default implementation obeys the following business logic: 1. If the user has specified an authenticatorName property, use it to locate and return the Authenticator with that name 2. If the authenticatorName hasn't been specified, and the user has provided their own custom Authenticator, return that one 3. If the user hasn't provided a custom Authenticator, return IdmAuthenticator and attempt to use the identity management API to authenticate

Returns:
Throws:
AuthenticationException

unAuthenticate

public void unAuthenticate()
Resets all security state and credentials


logout

public void logout()
Specified by:
logout in interface Identity

hasRole

public boolean hasRole(String roleType,
                       String group,
                       String groupType)
Specified by:
hasRole in interface Identity

addRole

public boolean addRole(String roleType,
                       String group,
                       String groupType)
Specified by:
addRole in interface Identity

inGroup

public boolean inGroup(String name,
                       String groupType)
Specified by:
inGroup in interface Identity

addGroup

public boolean addGroup(String name,
                        String groupType)
Specified by:
addGroup in interface Identity

removeGroup

public void removeGroup(String name,
                        String groupType)
Specified by:
removeGroup in interface Identity

removeRole

public void removeRole(String roleType,
                       String group,
                       String groupType)
Removes a role from the authenticated user

Specified by:
removeRole in interface Identity
Parameters:
role - The name of the role to remove

checkRole

public void checkRole(String roleType,
                      String group,
                      String groupType)
Specified by:
checkRole in interface Identity

checkGroup

public void checkGroup(String group,
                       String groupType)
Specified by:
checkGroup in interface Identity

checkPermission

public void checkPermission(Object target,
                            String action)
Specified by:
checkPermission in interface Identity

filterByPermission

public void filterByPermission(Collection<?> collection,
                               String action)
Specified by:
filterByPermission in interface Identity

hasPermission

public boolean hasPermission(Object target,
                             String action)
Specified by:
hasPermission in interface Identity

runAs

public void runAs(RunAsOperation operation)

checkRestriction

public void checkRestriction(String expr)
Specified by:
checkRestriction in interface Identity

getUser

public org.picketlink.idm.api.User getUser()
Specified by:
getUser in interface Identity

getRoles

public Set<org.picketlink.idm.api.Role> getRoles()
Specified by:
getRoles in interface Identity

getGroups

public Set<org.picketlink.idm.api.Group> getGroups()
Specified by:
getGroups in interface Identity

isVerified

public boolean isVerified()
Specified by:
isVerified in interface Identity


Copyright © 2011 Seam Framework. All Rights Reserved.