Example usage for org.bouncycastle.crypto.generators OpenBSDBCrypt checkPassword

List of usage examples for org.bouncycastle.crypto.generators OpenBSDBCrypt checkPassword

Introduction

In this page you can find the example usage for org.bouncycastle.crypto.generators OpenBSDBCrypt checkPassword.

Prototype

public static boolean checkPassword(String bcryptString, char[] password) 

Source Link

Document

Checks if a password corresponds to a 60 character Bcrypt String

Usage

From source file:com.acciente.oacc.encryptor.bcrypt.BCryptPasswordEncryptor.java

License:Apache License

@Override
public boolean checkPassword(char[] plainPassword, String storedPassword) {
    if (plainPassword == null) {
        return (storedPassword == null);
    } else if (storedPassword == null) {
        return false;
    }//from w  w w .  java 2 s  . com

    final String bcryptString = passwordEncoderDecoder.decode(storedPassword);
    final char[] normalizedChars = TextNormalizer.getInstance().normalizeToNfc(plainPassword);

    return OpenBSDBCrypt.checkPassword(bcryptString, normalizedChars);
}

From source file:org.jivesoftware.openfire.auth.JDBCAuthProvider.java

License:Open Source License

protected boolean comparePasswords(String plainText, String hashed) {
    int lastIndex = passwordTypes.size() - 1;
    if (passwordTypes.get(lastIndex) == PasswordType.bcrypt) {
        for (int i = 0; i < lastIndex; i++) {
            plainText = hashPassword(plainText, passwordTypes.get(i));
        }//from   w  ww  . ja  v a  2 s.c  o  m
        return OpenBSDBCrypt.checkPassword(hashed, plainText.toCharArray());
    }

    return hashPassword(plainText).equals(hashed);
}

From source file:password.pwm.util.BCrypt.java

License:Open Source License

public static boolean testAnswer(final String password, final String hashedPassword) {
    return OpenBSDBCrypt.checkPassword(hashedPassword, password.toLowerCase().toCharArray());
}

From source file:password.pwm.util.secure.BCrypt.java

License:Open Source License

public static boolean testAnswer(final String password, final String hashedPassword,
        final Configuration configuration) {
    final char[] pwCharArray = password.toLowerCase().toCharArray();
    final boolean bsdCryptPass = OpenBSDBCrypt.checkPassword(hashedPassword, pwCharArray);
    if (!bsdCryptPass) {
        final boolean enableJBCrypt = Boolean
                .parseBoolean(configuration.readAppProperty(AppProperty.CONFIG_JBCRYPT_PWLIB_ENABLE));
        if (enableJBCrypt) {
            // legacy check, older jbcrypt library used previously incorrectly encoded some characters
            // including special ascii characters.
            return JBCrypt.checkpw(password, hashedPassword);
        }/*from  w  ww  .  ja va 2  s. c o m*/
    }
    return bsdCryptPass;
}