use of io.pravega.shared.security.auth.PasswordAuthHandlerInput 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();
}
use of io.pravega.shared.security.auth.PasswordAuthHandlerInput in project pravega by pravega.
the class PasswordAuthHandlerTest method initializeWorksWithValidAclsAndComments.
@SneakyThrows
@Test
public void initializeWorksWithValidAclsAndComments() {
PasswordAuthHandler authHandler = new PasswordAuthHandler();
try (PasswordAuthHandlerInput pwdInputFile = new PasswordAuthHandlerInput("PasswordAuthHandlerTest.init", ".txt")) {
String encryptedPassword = StrongPasswordProcessor.builder().build().encryptPassword("some_password");
List<PasswordAuthHandlerInput.Entry> entries = Arrays.asList(PasswordAuthHandlerInput.Entry.of("admin", encryptedPassword, "prn::*,READ_UPDATE;"), PasswordAuthHandlerInput.Entry.of("appaccount", encryptedPassword, "prn::/scope:scope1,READ_UPDATE;"), PasswordAuthHandlerInput.Entry.of("#commented", encryptedPassword, "prn::"));
pwdInputFile.postEntries(entries);
authHandler.initialize(new ServerConfig() {
@Override
public Properties toAuthHandlerProperties() {
Properties props = new Properties();
props.setProperty(AuthPluginConfig.BASIC_AUTHPLUGIN_DATABASE, pwdInputFile.getFile().getAbsolutePath());
return props;
}
});
ConcurrentHashMap<String, AccessControlList> aclsByUser = authHandler.getAclsByUser();
assertEquals(2, aclsByUser.size());
assertTrue(aclsByUser.containsKey("admin"));
assertEquals("prn::/scope:scope1", aclsByUser.get("appaccount").getEntries().get(0).getResourcePattern());
assertFalse(aclsByUser.containsKey("unauthorizeduser"));
}
}
use of io.pravega.shared.security.auth.PasswordAuthHandlerInput in project pravega by pravega.
the class ClusterWrapper method createAuthFile.
private File createAuthFile(List<PasswordAuthHandlerInput.Entry> entries) {
PasswordAuthHandlerInput result = new PasswordAuthHandlerInput(UUID.randomUUID().toString(), ".txt");
result.postEntries(entries);
log.debug("Posted entries to [{}] file", result.getFile().getPath());
return result.getFile();
}
Aggregations