Package se.gu.fire.core

Examples of se.gu.fire.core.Password


        currentUser = getUserFromInterSessionContext();
        if (currentUser == null) {
            return "";
        }

        Password password = resetPasswordBean.doResetPassword(currentUser, firstPassword);
       
        if(password == null) {
            FireFaces.addErrorMessage("Unable to reset password");
            return "";
        }
View Full Code Here


            RandomNumberGenerator numberGenerator = new SecureRandomNumberGenerator();
            ByteSource salt = numberGenerator.nextBytes();

            String hashedPassword = new Sha256Hash("haxx", salt, 1024).toBase64();

            Password newPassword = new Password(newUser.getId(), hashedPassword, salt.getBytes());

            passwordManager.create(newPassword);

            FireLogger.logInfo(
                    "Created debug user "
                    + newUser.getEmail()
                    + " with password "
                    + newPassword.getPassword()
                    + " and salt "
                    + newPassword.getSalt());
        }
    }
View Full Code Here

       
        UserManager um = new UserManager();
        um.setEntityManager(em);
       
        em.getTransaction().begin();
        Password password = new Password(10L, "tio");
        pm.create(password);
        em.getTransaction().commit();

        assertNotNull(pm.read(10L));
View Full Code Here

       
        FireUser u5 = um.read(oscar.getId());
        assertNotNull(u5);

        String smart = "haxx";
        Password oscarsPassword = new Password(oscar.getId(), smart);
        em.getTransaction().begin();
        pm.create(oscarsPassword);
        em.getTransaction().commit();
       
        assertNotNull(pm.findPassword(oscar, smart));
View Full Code Here

            FireLogger.logSevere("Realm {0} found no match for user {1}", getName(), username);
            throw new UnknownAccountException("Unable to locate user: " + username);
        }

        // Extract password and check for match
        Password resolvedPassword;
        try {
            resolvedPassword = passwordManager.findPassword(resolvedUser);

        } catch (Exception e) {
            FireLogger.logSevere("Realm {0} has encountered a database problem: {1}", getName(), e.getClass());
            throw new AuthenticationException("Database error: " + e.getMessage());
        }

         // If the password does not exist, the user will have to create a new one
        if (resolvedPassword == null) {
            FireLogger.logSevere("Realm {0} found no matching password for user {1}", getName(), username);
            throw new UnknownAccountException("Password for account could not be found. New password must be created");
        }

        FireLogger.logInfo("Realm {0} generated SimpleAuthenticationToken for user {1}", getName(), username);

        return new SimpleAuthenticationInfo(resolvedUser.getEmail(),
                resolvedPassword.getPassword(),
                new SimpleByteSource(resolvedPassword.getSalt()),
                getName());
    }
View Full Code Here

     */
    public void createPasswords() {
        int i = 0;
        for (FireUser user : users) {
            passwords.add(
                    new Password(
                    user.getId(),
                    new Sha256Hash(passwordStrs.get(i),
                    ByteSource.Util.bytes(new byte[]{7}), 1024).toBase64(),
                    new byte[]{7}));
            i++;
View Full Code Here

     }
     * */
    @Override
    public Password findPassword(FireUser user) {

        Password pwdEntity = null;
        try {
            String query =
                    "select p from Password p where p.id = :passId";

            TypedQuery<Password> q = getEntityManager().createQuery(query, Password.class);
View Full Code Here

    }

    @Override
    public Password findPassword(Long userId, String password) throws NoResultException, PersistenceException {

        Password pwdEntity = null;
        try {
            String query =
                    "select p from Password p where p.id = :userId and p.password like :passId";

            TypedQuery<Password> q = getEntityManager().createQuery(query, Password.class);
View Full Code Here

     * @param plaintextPassword the password in plaintext
     */
    @Override
    public void create(long userID, String plaintextPassword) {

        Password hashedPassword = createHashedPassword(userID, plaintextPassword);

        super.create(hashedPassword);
    }
View Full Code Here

     * @param newPlaintextPassword the new password in plaintext.
     */
    @Override
    public void update(long userID, String newPlaintextPassword) {

        Password updatedPassword = createHashedPassword(userID, newPlaintextPassword);

        super.update(updatedPassword);
    }
View Full Code Here

TOP

Related Classes of se.gu.fire.core.Password

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.