use of io.crate.user.SecureHash in project crate by crate.
the class AlterUserPlan method executeOrFail.
@Override
public void executeOrFail(DependencyCarrier dependencies, PlannerContext plannerContext, RowConsumer consumer, Row params, SubQueryResults subQueryResults) throws Exception {
SecureHash newPassword = UserActions.generateSecureHash(alterUser.properties(), params, plannerContext.transactionContext(), plannerContext.nodeContext());
userManager.alterUser(alterUser.userName(), newPassword).whenComplete(new OneRowActionListener<>(consumer, rCount -> new Row1(rCount == null ? -1 : rCount)));
}
use of io.crate.user.SecureHash in project crate by crate.
the class CreateUserPlan method executeOrFail.
@Override
public void executeOrFail(DependencyCarrier dependencies, PlannerContext plannerContext, RowConsumer consumer, Row params, SubQueryResults subQueryResults) throws Exception {
SecureHash newPassword = UserActions.generateSecureHash(createUser.properties(), params, plannerContext.transactionContext(), plannerContext.nodeContext());
userManager.createUser(createUser.userName(), newPassword).whenComplete(new OneRowActionListener<>(consumer, rCount -> new Row1(rCount == null ? -1 : rCount)));
}
use of io.crate.user.SecureHash in project crate by crate.
the class UserAuthenticationMethodTest method userLookup.
private User userLookup(String userName) {
if (userName.equals("crate")) {
User user = null;
try {
SecureHash pwHash = SecureHash.of(new SecureString("pw".toCharArray()));
user = User.of("crate", Collections.emptySet(), pwHash);
} catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
// do nothing
}
assertNotNull(user);
return user;
}
return null;
}
use of io.crate.user.SecureHash in project crate by crate.
the class SecureHashTest method testSamePasswordsGenerateDifferentHash.
@Test
public void testSamePasswordsGenerateDifferentHash() throws Exception {
SecureHash hash1 = SecureHash.of(PASSWORD);
SecureHash hash2 = SecureHash.of(PASSWORD);
assertNotEquals(hash1, hash2);
}
use of io.crate.user.SecureHash in project crate by crate.
the class SecureHashTest method testNonAsciiChars.
@Test
public void testNonAsciiChars() throws InvalidKeySpecException, NoSuchAlgorithmException {
SecureString pw = new SecureString("ฯรค๐ูุต".toCharArray());
SecureHash hash = SecureHash.of(pw);
assertTrue(hash.verifyHash(pw));
}
Aggregations