Code example for SessionFactory

Methods: isClosed

0
     * @return A user object of the authenticated user or null. 
     */ 
    public User authenticate(final String username, final String password) {
        Transaction tx = null;
        logger.debug("Login attempt for " + username);
 
        /* acquire Hibernate session */ 
        Session session = _session.openSession();
 
        String hashAlgo = Configuration.getInstance()
                .getUserPasswordHashAlgorithm(); 
        MessageDigest md = null;
 
        if (hashAlgo.equals("SHA-1") || hashAlgo.equals("SHA-256")
                || hashAlgo.equals("SHA-512") || hashAlgo.equals("MD5")) {
            try { 
                md = MessageDigest.getInstance(hashAlgo);
            } catch (NoSuchAlgorithmException e) {
                logger.error("X: Login attempt could not be processed." 
                        + " Specified password hashing method not known." 
Contextual code suggestions in your IDE  Get Codota for Java