use of org.summerb.users.impl.dom.Password in project summerb by skarpushin.
the class PasswordFactory method createExistentUserPassword.
public static Password createExistentUserPassword() {
Password ret = new Password();
ret.setUserUuid(UserFactory.EXISTENT_USER);
ret.setPasswordHash(RIGHT_PASSWORD_FOR_EXISTENT_USER_HASH);
ret.setRestorationToken(TOKEN_FOR_EXISTENT_USER);
return ret;
}
use of org.summerb.users.impl.dom.Password in project summerb by skarpushin.
the class PasswordServiceImpl method isRestorationTokenValid.
@Override
public boolean isRestorationTokenValid(String userUuid, String restorationTokenUuid) throws UserNotFoundException {
Preconditions.checkArgument(userUuid != null);
Preconditions.checkArgument(restorationTokenUuid != null);
assertUserExists(userUuid);
try {
Password password = passwordDao.findPasswordByUserUuid(userUuid);
if (password == null || !restorationTokenUuid.equals(password.getRestorationToken())) {
return false;
}
} catch (Throwable t) {
String msg = String.format("Failed to check user '%s' restoration token validity", userUuid);
throw new UserServiceUnexpectedException(msg, t);
}
return true;
}
use of org.summerb.users.impl.dom.Password in project summerb by skarpushin.
the class PasswordDaoImpl method updateUserPassword.
@Override
public int updateUserPassword(String userUuid, String newPasswordHash) {
Password pwd = new Password();
pwd.setUserUuid(userUuid);
pwd.setPasswordHash(newPasswordHash);
pwd.setRestorationToken(null);
BeanPropertySqlParameterSource params = new BeanPropertySqlParameterSource(pwd);
return jdbc.update(sqlPutPassword, params);
}
use of org.summerb.users.impl.dom.Password in project summerb by skarpushin.
the class PasswordServiceImpl method isUserPasswordValid.
@Override
public boolean isUserPasswordValid(String userUuid, String passwordPlain) throws UserNotFoundException {
Preconditions.checkArgument(userUuid != null);
Preconditions.checkArgument(passwordPlain != null);
assertUserExists(userUuid);
try {
Password password = passwordDao.findPasswordByUserUuid(userUuid);
if (password == null) {
return false;
}
if (!isPasswordMatch(passwordPlain, password.getPasswordHash())) {
return false;
}
} catch (Throwable t) {
String msg = String.format("Failed to validate user '%s' password", userUuid);
throw new UserServiceUnexpectedException(msg, t);
}
return true;
}
Aggregations