org.jboss.seam.security.management
Class JpaIdentityStore

java.lang.Object
  extended by org.jboss.seam.security.management.JpaIdentityStore
All Implemented Interfaces:
Serializable, IdentityStore

@Name(value="org.jboss.seam.security.identityStore")
@Install(precedence=0,
         value=false)
@Scope(value=APPLICATION)
@BypassInterceptors
public class JpaIdentityStore
extends Object
implements IdentityStore, Serializable

The default identity store implementation, uses JPA as its persistence mechanism.

Author:
Shane Bryzak
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jboss.seam.security.management.IdentityStore
IdentityStore.Feature, IdentityStore.FeatureSet
 
Field Summary
static String AUTHENTICATED_USER
           
static String EVENT_PRE_PERSIST_USER
           
static String EVENT_PRE_PERSIST_USER_ROLE
           
static String EVENT_USER_AUTHENTICATED
           
static String EVENT_USER_CREATED
           
protected  IdentityStore.FeatureSet featureSet
           
 
Constructor Summary
JpaIdentityStore()
           
 
Method Summary
 boolean addRoleToGroup(String role, String group)
          Adds the specified role as a member of the specified group.
 boolean authenticate(String username, String password)
          Authenticates the specified user, using the specified password.
 boolean changePassword(String username, String password)
          Changes the password of the specified user to the specified password.
 boolean createRole(String role)
          Creates a new role with the specified role name.
 boolean createUser(String username, String password)
          Creates a new user with the specified username and password.
 boolean createUser(String username, String password, String firstname, String lastname)
          Creates a new user with the specified username, password, first name and last name.
 boolean deleteRole(String role)
          Deletes the specified role.
 boolean deleteUser(String name)
          Deletes the user with the specified username.
 boolean disableUser(String name)
          Disables the user with the specified username.
 boolean enableUser(String name)
          Enables the user with the specified username.
 String generatePasswordHash(String password, byte[] salt)
           
protected  String generatePasswordHash(String password, String salt)
          Deprecated. Use JpaIdentityStore.generatePasswordHash(String, byte[]) instead
 byte[] generateUserSalt(Object user)
          Generates a 64 bit random salt value
 Expressions.ValueExpression getEntityManager()
           
 Set<IdentityStore.Feature> getFeatures()
           
 List<String> getGrantedRoles(String name)
          Returns a list of all the roles explicitly granted to the specified user.
 List<String> getImpliedRoles(String name)
          Returns a list of all roles that the specified user is a member of.
 Class getRoleClass()
           
 List<String> getRoleGroups(String name)
          Returns a list of all the groups that the specified role is a member of.
 String getRoleName(Object role)
           
protected  String getUserAccountSalt(Object user)
          Deprecated. Use JpaIdentityStore.generateRandomSalt(Object) instead
 Class getUserClass()
           
 String getUserName(Object user)
           
 boolean grantRole(String username, String role)
          Grants the specified role to the specified user.
 void init()
           
 boolean isRoleConditional(String role)
           
 boolean isUserEnabled(String name)
          Returns true if the specified user is enabled.
 List<String> listGrantableRoles()
          Returns a list of roles that can be granted (i.e, excluding conditional roles)
 List<Principal> listMembers(String role)
          Lists the members of the specified role.
 List<String> listRoles()
          Returns a list of all the roles.
 List<String> listUsers()
          Returns a list of all users.
 List<String> listUsers(String filter)
          Returns a list of all users containing the specified filter text within their username.
 Object lookupRole(String role)
           
 Object lookupUser(String username)
           
protected  Object mergeEntity(Object entity)
           
protected  void persistEntity(Object entity)
           
protected  void removeEntity(Object entity)
           
 boolean removeRoleFromGroup(String role, String group)
          Removes the specified role from the specified group.
 boolean revokeRole(String username, String role)
          Revokes the specified role from the specified user.
 boolean roleExists(String name)
          Returns true if the specified role exists.
 void setEntityManager(Expressions.ValueExpression expression)
           
 void setFeatures(Set<IdentityStore.Feature> features)
           
 void setRoleClass(Class roleClass)
           
 void setUserAccountForSession()
           
 void setUserClass(Class userClass)
           
protected  void setUserPassword(Object user, String password)
           
 boolean supportsFeature(IdentityStore.Feature feature)
          Returns true if the IdentityStore implementation supports the specified feature.
 boolean userExists(String name)
          Returns true if the specified user exists.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AUTHENTICATED_USER

public static final String AUTHENTICATED_USER
See Also:
Constant Field Values

EVENT_USER_CREATED

public static final String EVENT_USER_CREATED
See Also:
Constant Field Values

EVENT_PRE_PERSIST_USER

public static final String EVENT_PRE_PERSIST_USER
See Also:
Constant Field Values

EVENT_USER_AUTHENTICATED

public static final String EVENT_USER_AUTHENTICATED
See Also:
Constant Field Values

EVENT_PRE_PERSIST_USER_ROLE

public static final String EVENT_PRE_PERSIST_USER_ROLE
See Also:
Constant Field Values

featureSet

protected IdentityStore.FeatureSet featureSet
Constructor Detail

JpaIdentityStore

public JpaIdentityStore()
Method Detail

getFeatures

public Set<IdentityStore.Feature> getFeatures()

setFeatures

public void setFeatures(Set<IdentityStore.Feature> features)

supportsFeature

public boolean supportsFeature(IdentityStore.Feature feature)
Description copied from interface: IdentityStore
Returns true if the IdentityStore implementation supports the specified feature.

Specified by:
supportsFeature in interface IdentityStore

init

@Create
public void init()

createUser

public boolean createUser(String username,
                          String password,
                          String firstname,
                          String lastname)
Description copied from interface: IdentityStore
Creates a new user with the specified username, password, first name and last name.

Specified by:
createUser in interface IdentityStore
Returns:
true if the user was successfully created.

setUserPassword

protected void setUserPassword(Object user,
                               String password)

getUserAccountSalt

@Deprecated
protected String getUserAccountSalt(Object user)
Deprecated. Use JpaIdentityStore.generateRandomSalt(Object) instead


generateUserSalt

public byte[] generateUserSalt(Object user)
Generates a 64 bit random salt value


createUser

public boolean createUser(String username,
                          String password)
Description copied from interface: IdentityStore
Creates a new user with the specified username and password.

Specified by:
createUser in interface IdentityStore
Returns:
true if the user was successfully created.

deleteUser

public boolean deleteUser(String name)
Description copied from interface: IdentityStore
Deletes the user with the specified username.

Specified by:
deleteUser in interface IdentityStore
Returns:
true if the user was successfully deleted.

grantRole

public boolean grantRole(String username,
                         String role)
Description copied from interface: IdentityStore
Grants the specified role to the specified user.

Specified by:
grantRole in interface IdentityStore
Parameters:
username - The name of the user
role - The name of the role to grant to the user.
Returns:
true if the role was successfully granted.

revokeRole

public boolean revokeRole(String username,
                          String role)
Description copied from interface: IdentityStore
Revokes the specified role from the specified user.

Specified by:
revokeRole in interface IdentityStore
Parameters:
username - The name of the user
role - The name of the role to grant to the user.
Returns:
true if the role was successfully revoked.

addRoleToGroup

public boolean addRoleToGroup(String role,
                              String group)
Description copied from interface: IdentityStore
Adds the specified role as a member of the specified group.

Specified by:
addRoleToGroup in interface IdentityStore
Parameters:
role - The name of the role to add as a member
group - The name of the group that the specified role will be added to.
Returns:
true if the role was successfully added to the group.

removeRoleFromGroup

public boolean removeRoleFromGroup(String role,
                                   String group)
Description copied from interface: IdentityStore
Removes the specified role from the specified group.

Specified by:
removeRoleFromGroup in interface IdentityStore
Parameters:
role - The name of the role to remove from the group.
group - The group from which to remove the role.
Returns:
true if the role was successfully removed from the group.

createRole

public boolean createRole(String role)
Description copied from interface: IdentityStore
Creates a new role with the specified role name.

Specified by:
createRole in interface IdentityStore
Returns:
true if the role was created successfully.

deleteRole

public boolean deleteRole(String role)
Description copied from interface: IdentityStore
Deletes the specified role.

Specified by:
deleteRole in interface IdentityStore
Returns:
true if the role was successfully deleted.

enableUser

public boolean enableUser(String name)
Description copied from interface: IdentityStore
Enables the user with the specified username. Enabled users are able to authenticate.

Specified by:
enableUser in interface IdentityStore
Returns:
true if the specified user was successfully enabled.

disableUser

public boolean disableUser(String name)
Description copied from interface: IdentityStore
Disables the user with the specified username. Disabled users are unable to authenticate.

Specified by:
disableUser in interface IdentityStore
Returns:
true if the specified user was successfully disabled.

changePassword

public boolean changePassword(String username,
                              String password)
Description copied from interface: IdentityStore
Changes the password of the specified user to the specified password.

Specified by:
changePassword in interface IdentityStore
Returns:
true if the user's password was successfully changed.

userExists

public boolean userExists(String name)
Description copied from interface: IdentityStore
Returns true if the specified user exists.

Specified by:
userExists in interface IdentityStore

roleExists

public boolean roleExists(String name)
Description copied from interface: IdentityStore
Returns true if the specified role exists.

Specified by:
roleExists in interface IdentityStore

isUserEnabled

public boolean isUserEnabled(String name)
Description copied from interface: IdentityStore
Returns true if the specified user is enabled.

Specified by:
isUserEnabled in interface IdentityStore

getGrantedRoles

public List<String> getGrantedRoles(String name)
Description copied from interface: IdentityStore
Returns a list of all the roles explicitly granted to the specified user.

Specified by:
getGrantedRoles in interface IdentityStore

getRoleGroups

public List<String> getRoleGroups(String name)
Description copied from interface: IdentityStore
Returns a list of all the groups that the specified role is a member of.

Specified by:
getRoleGroups in interface IdentityStore

getImpliedRoles

public List<String> getImpliedRoles(String name)
Description copied from interface: IdentityStore
Returns a list of all roles that the specified user is a member of. This list may contain roles that may not have been explicitly granted to the user, which are indirectly implied due to group memberships.

Specified by:
getImpliedRoles in interface IdentityStore

generatePasswordHash

public String generatePasswordHash(String password,
                                   byte[] salt)

generatePasswordHash

@Deprecated
protected String generatePasswordHash(String password,
                                                 String salt)
Deprecated. Use JpaIdentityStore.generatePasswordHash(String, byte[]) instead


authenticate

public boolean authenticate(String username,
                            String password)
Description copied from interface: IdentityStore
Authenticates the specified user, using the specified password.

Specified by:
authenticate in interface IdentityStore
Returns:
true if authentication is successful.

setUserAccountForSession

@Observer(value="org.jboss.seam.security.postAuthenticate")
public void setUserAccountForSession()

lookupUser

public Object lookupUser(String username)

getUserName

public String getUserName(Object user)

getRoleName

public String getRoleName(Object role)

isRoleConditional

public boolean isRoleConditional(String role)

lookupRole

public Object lookupRole(String role)

listUsers

public List<String> listUsers()
Description copied from interface: IdentityStore
Returns a list of all users.

Specified by:
listUsers in interface IdentityStore

listUsers

public List<String> listUsers(String filter)
Description copied from interface: IdentityStore
Returns a list of all users containing the specified filter text within their username.

Specified by:
listUsers in interface IdentityStore

listRoles

public List<String> listRoles()
Description copied from interface: IdentityStore
Returns a list of all the roles.

Specified by:
listRoles in interface IdentityStore

listMembers

public List<Principal> listMembers(String role)
Description copied from interface: IdentityStore
Lists the members of the specified role.

Specified by:
listMembers in interface IdentityStore

listGrantableRoles

public List<String> listGrantableRoles()
Description copied from interface: IdentityStore
Returns a list of roles that can be granted (i.e, excluding conditional roles)

Specified by:
listGrantableRoles in interface IdentityStore

persistEntity

protected void persistEntity(Object entity)

mergeEntity

protected Object mergeEntity(Object entity)

removeEntity

protected void removeEntity(Object entity)

getUserClass

public Class getUserClass()

setUserClass

public void setUserClass(Class userClass)

getRoleClass

public Class getRoleClass()

setRoleClass

public void setRoleClass(Class roleClass)

getEntityManager

public Expressions.ValueExpression getEntityManager()

setEntityManager

public void setEntityManager(Expressions.ValueExpression expression)


Copyright © 2011 Seam Framework. All Rights Reserved.