org.jboss.seam.security.management
Class JpaIdentityStore

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

@Scope(value=APPLICATION)
@BypassInterceptors
public class JpaIdentityStore
extends Object
implements IdentityStore

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

Author:
Shane Bryzak

Field Summary
static String EVENT_ACCOUNT_AUTHENTICATED
           
static String EVENT_ACCOUNT_CREATED
           
 
Constructor Summary
JpaIdentityStore()
           
 
Method Summary
 boolean accountExists(String name)
           
 boolean authenticate(String username, String password)
           
 boolean changePassword(String name, String password)
           
 boolean createAccount(String username, String password)
           
 boolean deleteAccount(String name)
           
 boolean disableAccount(String name)
           
 boolean enableAccount(String name)
           
 Class<? extends UserAccount> getAccountClass()
           
 String getEntityManagerName()
           
 List<String> getGrantedRoles(String name)
           
 List<String> getImpliedRoles(String name)
           
 boolean grantRole(String name, String role)
           
protected  String hashPassword(String password, String saltPhrase)
           
 void init()
           
 boolean isEnabled(String name)
           
 List<String> listRoles()
           
 List<String> listUsers()
           
 List<String> listUsers(String filter)
           
protected  void loadRoles()
           
protected  UserAccount mergeAccount(UserAccount account)
           
protected  void persistAccount(UserAccount account)
           
 boolean revokeRole(String name, String role)
           
 void setAccountClass(Class<? extends UserAccount> accountClass)
           
 void setEntityManagerName(String name)
           
protected  UserAccount validateRole(String name)
          Retrieves a role UserAccount from persistent storage.
protected  UserAccount validateUser(String name)
          Retrieves a user UserAccount from persistent storage.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EVENT_ACCOUNT_CREATED

public static final String EVENT_ACCOUNT_CREATED
See Also:
Constant Field Values

EVENT_ACCOUNT_AUTHENTICATED

public static final String EVENT_ACCOUNT_AUTHENTICATED
See Also:
Constant Field Values
Constructor Detail

JpaIdentityStore

public JpaIdentityStore()
Method Detail

init

@Create
public void init()

loadRoles

protected void loadRoles()

createAccount

public boolean createAccount(String username,
                             String password)
Specified by:
createAccount in interface IdentityStore

deleteAccount

public boolean deleteAccount(String name)
Specified by:
deleteAccount in interface IdentityStore

grantRole

public boolean grantRole(String name,
                         String role)
Specified by:
grantRole in interface IdentityStore

revokeRole

public boolean revokeRole(String name,
                          String role)
Specified by:
revokeRole in interface IdentityStore

enableAccount

public boolean enableAccount(String name)
Specified by:
enableAccount in interface IdentityStore

disableAccount

public boolean disableAccount(String name)
Specified by:
disableAccount in interface IdentityStore

changePassword

public boolean changePassword(String name,
                              String password)
Specified by:
changePassword in interface IdentityStore

accountExists

public boolean accountExists(String name)
Specified by:
accountExists in interface IdentityStore

isEnabled

public boolean isEnabled(String name)
Specified by:
isEnabled in interface IdentityStore

getGrantedRoles

public List<String> getGrantedRoles(String name)
Specified by:
getGrantedRoles in interface IdentityStore

getImpliedRoles

public List<String> getImpliedRoles(String name)
Specified by:
getImpliedRoles in interface IdentityStore

authenticate

public boolean authenticate(String username,
                            String password)
Specified by:
authenticate in interface IdentityStore

validateUser

protected UserAccount validateUser(String name)
                            throws NoSuchUserException
Retrieves a user UserAccount from persistent storage. If the UserAccount does not exist, an IdentityManagementException is thrown.

Parameters:
name - The user's username
Returns:
The UserAccount for the specified user
Throws:
NoSuchUserException

validateRole

protected UserAccount validateRole(String name)
Retrieves a role UserAccount from persistent storage. If the UserAccount does not exist, an IdentityManagementException is thrown.

Parameters:
name - The role name
Returns:
The UserAccount for the specific role

listUsers

public List<String> listUsers()
Specified by:
listUsers in interface IdentityStore

listUsers

public List<String> listUsers(String filter)
Specified by:
listUsers in interface IdentityStore

listRoles

public List<String> listRoles()
Specified by:
listRoles in interface IdentityStore

persistAccount

protected void persistAccount(UserAccount account)

mergeAccount

protected UserAccount mergeAccount(UserAccount account)

getAccountClass

public Class<? extends UserAccount> getAccountClass()

setAccountClass

public void setAccountClass(Class<? extends UserAccount> accountClass)

getEntityManagerName

public String getEntityManagerName()

setEntityManagerName

public void setEntityManagerName(String name)

hashPassword

protected String hashPassword(String password,
                              String saltPhrase)