com.mizar.persistence.jpa.security
Class AuthenticatorJPAFactory

java.lang.Object
  extended by com.mizar.persistence.jpa.facade.JPAFacade
      extended by com.mizar.persistence.jpa.security.AuthenticatorJPAFactory
All Implemented Interfaces:
Authenticator
Direct Known Subclasses:
AuthenticatorFacesFactory

public abstract class AuthenticatorJPAFactory
extends JPAFacade
implements Authenticator


Field Summary
 
Fields inherited from class com.mizar.persistence.jpa.facade.JPAFacade
em, emf, model, persistenceUnitName, schemaName, sequencesValidated, silent, verbose
 
Constructor Summary
AuthenticatorJPAFactory()
           
AuthenticatorJPAFactory(java.lang.String persistenceUnitName)
           
 
Method Summary
static java.lang.String encrypt(java.lang.String source)
          Encrypts the given string using SHA-1 and returns the result.
 JPAFacade getFacade()
           
 UserBean getUser(javax.persistence.EntityManager em, java.lang.String username, java.lang.String password)
           
 UserBean guestLogin(java.lang.String roleList)
          Creates a guest userRow for the system.
 void loadSettings(UserBean bean, java.lang.String applicationName)
           
 UserBean login(java.lang.Object persistenceManager, java.lang.String username, java.lang.String password)
          Performs an authentication.
 void setFacade(JPAFacade facade)
           
 
Methods inherited from class com.mizar.persistence.jpa.facade.JPAFacade
closeEm, closeEm, closeEmf, executeDDL, executeNativeUpdate, executeNativeUpdate, executeUpdate, getClosableConnectionAccessor, getConnection, getConnection, getEm, getEm, getEmf, getEmf, getLogger, getPassword, getPassword, getPersistenceUnitName, getSchemaName, getSequencesValidated, getSid, getSilent, getTableName, getToleratedErrorCodes, getUrl, getUser, getVerbose, mergeBean, persist, persistBean, printAnyBean, queryTester, queryTester, refreshBean, remove, removeBean, removeBean, setEmf, setPersistenceUnitName, setSilent, setToleratedErrorCodes, setVerbose, validateSequences
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AuthenticatorJPAFactory

public AuthenticatorJPAFactory()

AuthenticatorJPAFactory

public AuthenticatorJPAFactory(java.lang.String persistenceUnitName)
Method Detail

encrypt

public static java.lang.String encrypt(java.lang.String source)
Encrypts the given string using SHA-1 and returns the result.
The MessageDigest class will thrown an exception if it can't locate the SHA digest function. This exception has been suppressed on the basis that userList should never receive this message.

Parameters:
source - string to be encrypted
Returns:

loadSettings

public void loadSettings(UserBean bean,
                         java.lang.String applicationName)
                  throws org.jdom.JDOMException
Throws:
org.jdom.JDOMException

login

public UserBean login(java.lang.Object persistenceManager,
                      java.lang.String username,
                      java.lang.String password)
               throws AccessException
Description copied from interface: Authenticator
Performs an authentication. The function attempts a log-in with the given credentials. If successful, a com.mizar.credentials.User object is returned. In JSF applications, the userRow's credentials can be retrieved from the SessionContext. In non-JSF aware components, the userRow's credentials must be explicitly passed in to the function.

Specified by:
login in interface Authenticator
username - The username to authenticate with.
password - The userRow's supplied password
Returns:
An instance of com.mizar.credentials.User which represents the logged in userRow.
Throws:
AccessException - In the event of a log-in failure, this exception will be throw.

getUser

public UserBean getUser(javax.persistence.EntityManager em,
                        java.lang.String username,
                        java.lang.String password)
                 throws AccessException
Parameters:
em -
username - username for authentication
password - password for authentication
Returns:
Throws:
AccessException

guestLogin

public UserBean guestLogin(java.lang.String roleList)
                    throws AccessException
Description copied from interface: Authenticator
Creates a guest userRow for the system. Guest users are automatically assigned the role of 'guest'.

Specified by:
guestLogin in interface Authenticator
Parameters:
roleList - space seperated list of the requested roles for the guest
Returns:
Throws:
AccessException - If the requested roles cannot be assigned to the guest

setFacade

public void setFacade(JPAFacade facade)

getFacade

public JPAFacade getFacade()