public boolean isPasswordValid(String encPass, String rawPass, Object obj) throws DataAccessException { return BCrypt.checkpw(rawPass,encPass); }
@Override public AuthenticationResult checkCredentials(UserDto user, String password) { if (!BCrypt.checkpw(password, user.getCryptedPassword())) { return new AuthenticationResult(false, "wrong password"); } return new AuthenticationResult(true, ""); }
/** * Test method for 'BCrypt.checkpw(String, String)' * expecting failure */ public void testCheckpw_failure() { System.out.print("BCrypt.checkpw w/ bad passwords: "); for (int i = 0; i < test_vectors.length; i++) { int broken_index = (i + 4) % test_vectors.length; String plain = test_vectors[i][0]; String expected = test_vectors[broken_index][2]; assertFalse(BCrypt.checkpw(plain, expected)); System.out.print("."); } System.out.println(""); }
/** * Test method for 'BCrypt.checkpw(String, String)' * expecting success */ public void testCheckpw_success() { System.out.print("BCrypt.checkpw w/ good passwords: "); for (int i = 0; i < test_vectors.length; i++) { String plain = test_vectors[i][0]; String expected = test_vectors[i][2]; assertTrue(BCrypt.checkpw(plain, expected)); System.out.print("."); } System.out.println(""); }
/** * Test for correct hashing of non-US-ASCII passwords */ public void testInternationalChars() { System.out.print("BCrypt.hashpw w/ international chars: "); String pw1 = "\u2605\u2605\u2605\u2605\u2605\u2605\u2605\u2605"; String pw2 = "????????"; String h1 = BCrypt.hashpw(pw1, BCrypt.gensalt()); assertFalse(BCrypt.checkpw(pw2, h1)); System.out.print("."); String h2 = BCrypt.hashpw(pw2, BCrypt.gensalt()); assertFalse(BCrypt.checkpw(pw1, h2)); System.out.print("."); System.out.println(""); }
public AuthenticatedUser authenticate(final Map<String, String> credentials) throws AuthenticationException { final Vertex user; if (!credentials.containsKey(PROPERTY_USERNAME)) throw new IllegalArgumentException(String.format("Credentials must contain a %s", PROPERTY_USERNAME)); if (!credentials.containsKey(PROPERTY_PASSWORD)) throw new IllegalArgumentException(String.format("Credentials must contain a %s", PROPERTY_PASSWORD)); final String username = credentials.get(PROPERTY_USERNAME); final String password = credentials.get(PROPERTY_PASSWORD); final CredentialTraversal<Vertex,Vertex> t = credentialStore.users(username); if (!t.hasNext()) throw new AuthenticationException("Username and/or password are incorrect"); user = t.next(); if (t.hasNext()) { logger.warn("There is more than one user with the username [{}] - usernames must be unique", username); throw new AuthenticationException("Username and/or password are incorrect"); } final String hash = user.value(PROPERTY_PASSWORD); if (!BCrypt.checkpw(password, hash)) throw new AuthenticationException("Username and/or password are incorrect"); return new AuthenticatedUser(username); }
boolean passwordOk; try { passwordOk = !TextUtils.isEmpty(pw) && BCrypt.checkpw(apikey, pw); } catch (IllegalArgumentException e) { Log.w(TAG, "Malformed password", e);
public boolean verifyPassword(char[] password, String hash) { if (null == password) { return false; } try { return BCrypt.checkpw(password, hash); } catch (Exception e) { return false; } }
public static boolean matchBCrypted(String candidate, String hash) { // Check that an unencrypted password matches one that has // previously been hashed return BCrypt.checkpw(candidate, hash); }
@Override public boolean check(String plainText, String hashed) { try { return BCrypt.checkpw(plainText, hashed); } catch (java.lang.IllegalArgumentException iae ) { // the password was probably not hashed using bcrypt. return false; } } };
public boolean verifyPassword(String plainPassword) { if (plainPassword == null || this.passwordHash == null) return false; return BCrypt.checkpw(plainPassword, this.passwordHash); }
public boolean verifyPassword(String password, String hash) { if (null == password) { return false; } try { return BCrypt.checkpw(password, hash); } catch (Exception e) { return false; } }
public boolean verifyPassword(String password, String hash) { if (null == password) { return false; } try { return BCrypt.checkpw(password, hash); } catch (Exception e) { return false; } }
/** * 校验参数提供的密码的正确性 * * @param tryPassword 待校验密码值 * @param salt 密码盐值 * @param password 密码密文 * @return */ default boolean matches(String tryPassword, String salt, String password) { // 换用 BCrypt 淘汰 md5 return BCrypt.checkpw(tryPassword + salt, password); }
public boolean verifyPassword(char[] password, char[] hash) { if (null == password) { return false; } try { return BCrypt.checkpw(password, new String(hash)); } catch (Exception e) { return false; } }
/** * Check that a plaintext password matches a previously hashed * one * @param plaintext the plaintext password to verify * @param hashed the previously-hashed password * @return true if the passwords match, false otherwise */ public static boolean checkpw(String plaintext, String hashed) { return checkpw(plaintext.toCharArray(), hashed); }
/** * @see org.mindrot.jbcrypt.BCrypt#checkpw(String,String) */ @Deprecated public static boolean checkpw(String plaintext, String hashed) { return org.mindrot.jbcrypt.BCrypt.checkpw(plaintext, hashed); } }
/** * Check that a plaintext password matches a previously hashed * one * @param plaintext the plaintext password to verify * @param hashed the previously-hashed password * @return true if the passwords match, false otherwise */ public static boolean checkpw(String plaintext, String hashed) { return checkpw(plaintext.toCharArray(), hashed); }
public boolean verifyPassword(char[] password, char[] hash) { if (null == password) { return false; } try { return BCrypt.checkpw(password, new String(hash)); } catch (Exception e) { return false; } }
@Override public void resetPassWord(User currentUser, JSONObject requestJson) throws Exception { if (!requestJson.getString("password").equals(requestJson.getString("rePassword"))) { throw new BusinessException(PublicResultConstant.INVALID_RE_PASSWORD); } if(!BCrypt.checkpw(requestJson.getString("oldPassword"),currentUser.getPassword())){ throw new BusinessException(PublicResultConstant.INVALID_USERNAME_PASSWORD); } currentUser.setPassword(BCrypt.hashpw(requestJson.getString("password"),BCrypt.gensalt())); this.updateById(currentUser); }