org.jboss.seam.security
Class IdentityImpl

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

@Named(value="identity")
@SessionScoped
public class IdentityImpl
extends Object
implements org.jboss.seam.security.Identity, Serializable

Identity implementation for authentication and authorization

Author:
Shane Bryzak
See Also:
Serialized Form

Field Summary
protected static boolean securityEnabled
           
 
Fields inherited from interface org.jboss.seam.security.Identity
RESPONSE_LOGIN_EXCEPTION, RESPONSE_LOGIN_FAILED, RESPONSE_LOGIN_SUCCESS
 
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(org.jboss.seam.security.events.DeferredAuthenticationEvent event)
           
 void filterByPermission(Collection<?> collection, String action)
           
 Class<? extends org.jboss.seam.security.Authenticator> getAuthenticatorClass()
           
 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()
           
 void logout()
           
protected  org.jboss.seam.security.Authenticator lookupAuthenticator()
          Returns an Authenticator instance to be used for authentication.
protected  void postAuthenticate()
           
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 setAuthenticatorClass(Class<? extends org.jboss.seam.security.Authenticator> authenticatorClass)
           
 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 org.jboss.seam.security.Identity

getAuthenticatorClass

public Class<? extends org.jboss.seam.security.Authenticator> getAuthenticatorClass()
Specified by:
getAuthenticatorClass in interface org.jboss.seam.security.Identity

setAuthenticatorClass

public void setAuthenticatorClass(Class<? extends org.jboss.seam.security.Authenticator> authenticatorClass)
Specified by:
setAuthenticatorClass in interface org.jboss.seam.security.Identity

getAuthenticatorName

public String getAuthenticatorName()
Specified by:
getAuthenticatorName in interface org.jboss.seam.security.Identity

setAuthenticatorName

public void setAuthenticatorName(String authenticatorName)
Specified by:
setAuthenticatorName in interface org.jboss.seam.security.Identity

tryLogin

public boolean tryLogin()
Specified by:
tryLogin in interface org.jboss.seam.security.Identity

login

public String login()
Specified by:
login in interface org.jboss.seam.security.Identity

quietLogin

public void quietLogin()
Specified by:
quietLogin in interface org.jboss.seam.security.Identity

authenticate

protected boolean authenticate()
                        throws org.jboss.seam.security.AuthenticationException
Throws:
org.jboss.seam.security.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
                                              org.jboss.seam.security.events.DeferredAuthenticationEvent event)

postAuthenticate

protected void postAuthenticate()

lookupAuthenticator

protected org.jboss.seam.security.Authenticator lookupAuthenticator()
                                                             throws org.jboss.seam.security.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 authenticatorClass property, use it to locate the Authenticator with that exact type 2. If the user has specified an authenticatorName property, use it to locate and return the Authenticator with that name 3. If the authenticatorClass and authenticatorName haven't been specified, and the user has provided their own custom Authenticator, return that one 4. If the user hasn't provided a custom Authenticator, return IdmAuthenticator and attempt to use the identity management API to authenticate

Returns:
Throws:
org.jboss.seam.security.AuthenticationException

unAuthenticate

public void unAuthenticate()
Resets all security state and credentials


logout

public void logout()
Specified by:
logout in interface org.jboss.seam.security.Identity

hasRole

public boolean hasRole(String roleType,
                       String group,
                       String groupType)
Specified by:
hasRole in interface org.jboss.seam.security.Identity

addRole

public boolean addRole(String roleType,
                       String group,
                       String groupType)
Specified by:
addRole in interface org.jboss.seam.security.Identity

inGroup

public boolean inGroup(String name,
                       String groupType)
Specified by:
inGroup in interface org.jboss.seam.security.Identity

addGroup

public boolean addGroup(String name,
                        String groupType)
Specified by:
addGroup in interface org.jboss.seam.security.Identity

removeGroup

public void removeGroup(String name,
                        String groupType)
Specified by:
removeGroup in interface org.jboss.seam.security.Identity

removeRole

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

Specified by:
removeRole in interface org.jboss.seam.security.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 org.jboss.seam.security.Identity

checkGroup

public void checkGroup(String group,
                       String groupType)
Specified by:
checkGroup in interface org.jboss.seam.security.Identity

checkPermission

public void checkPermission(Object target,
                            String action)
Specified by:
checkPermission in interface org.jboss.seam.security.Identity

filterByPermission

public void filterByPermission(Collection<?> collection,
                               String action)
Specified by:
filterByPermission in interface org.jboss.seam.security.Identity

hasPermission

public boolean hasPermission(Object target,
                             String action)
Specified by:
hasPermission in interface org.jboss.seam.security.Identity

runAs

public void runAs(RunAsOperation operation)

checkRestriction

public void checkRestriction(String expr)
Specified by:
checkRestriction in interface org.jboss.seam.security.Identity

getUser

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

getRoles

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

getGroups

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

isVerified

public boolean isVerified()
Specified by:
isVerified in interface org.jboss.seam.security.Identity


Copyright © 2011 Seam Framework. All Rights Reserved.