use of io.pravega.shared.security.crypto.StrongPasswordProcessor in project pravega by pravega.
the class ControllerGrpcListStreamsTest method preparePasswordInputFileEntries.
// region Private methods
private List<PasswordAuthHandlerInput.Entry> preparePasswordInputFileEntries(Map<String, String> entries) {
StrongPasswordProcessor passwordProcessor = StrongPasswordProcessor.builder().build();
try {
String encryptedPassword = passwordProcessor.encryptPassword("1111_aaaa");
List<PasswordAuthHandlerInput.Entry> result = new ArrayList<>();
entries.forEach((k, v) -> result.add(PasswordAuthHandlerInput.Entry.of(k, encryptedPassword, v)));
return result;
} catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
throw new RuntimeException(e);
}
}
use of io.pravega.shared.security.crypto.StrongPasswordProcessor in project pravega by pravega.
the class StrongPasswordProcessorTest method checkPassword.
@Test
public void checkPassword() throws InvalidKeySpecException, NoSuchAlgorithmException {
StrongPasswordProcessor processor = StrongPasswordProcessor.builder().iterations(5000).build();
String encrypted = processor.encryptPassword("1111_aaaa");
StrongPasswordProcessor secondProcessor = StrongPasswordProcessor.builder().iterations(5000).build();
secondProcessor.checkPassword("1111_aaaa".toCharArray(), encrypted);
StrongPasswordProcessor failingProcessor = StrongPasswordProcessor.builder().iterations(1000).build();
Assert.assertTrue("Passwords with different iterations should not match", !encrypted.equals(failingProcessor.encryptPassword("1111_aaaa")));
}
use of io.pravega.shared.security.crypto.StrongPasswordProcessor in project pravega by pravega.
the class PasswordEncryptorTool method main.
public static void main(String[] args) throws InvalidKeySpecException, NoSuchAlgorithmException {
String userName = args[0];
String userPassword = args[1];
StrongPasswordProcessor passwordEncryptor = StrongPasswordProcessor.builder().build();
String encryptedPassword = passwordEncryptor.encryptPassword(userPassword);
System.out.println(encryptedPassword);
}
use of io.pravega.shared.security.crypto.StrongPasswordProcessor in project pravega by pravega.
the class PasswordValidatorTool method main.
public static void main(String[] args) throws InvalidKeySpecException, NoSuchAlgorithmException {
String userName = args[0];
String userPassword = args[1];
String encryptedPassword = args[2];
StrongPasswordProcessor passwordEncryptor = StrongPasswordProcessor.builder().build();
System.out.println(passwordEncryptor.checkPassword(userPassword.toCharArray(), encryptedPassword));
}
use of io.pravega.shared.security.crypto.StrongPasswordProcessor in project pravega by pravega.
the class BatchClientAuthTest method createAuthFile.
private static File createAuthFile() {
@SuppressWarnings("resource") PasswordAuthHandlerInput result = new PasswordAuthHandlerInput("BatchClientAuth", ".txt");
StrongPasswordProcessor passwordProcessor = StrongPasswordProcessor.builder().build();
try {
String encryptedPassword = passwordProcessor.encryptPassword("1111_aaaa");
List<PasswordAuthHandlerInput.Entry> entries = Arrays.asList(PasswordAuthHandlerInput.Entry.of("admin", encryptedPassword, "prn::*,READ_UPDATE;"), PasswordAuthHandlerInput.Entry.of("appaccount", encryptedPassword, "prn::*,READ_UPDATE;"), PasswordAuthHandlerInput.Entry.of("unauthorizeduser", encryptedPassword, "prn::"));
result.postEntries(entries);
} catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
throw new RuntimeException(e);
}
return result.getFile();
}
Aggregations