use of io.pravega.shared.security.auth.UserPrincipal in project pravega by pravega.
the class RESTAuthHelperTest method testAuthFailsForUnknownUser.
@Test
public void testAuthFailsForUnknownUser() throws AuthException {
String username = "unknown";
String password = "whatever";
boolean authorized = authHelper.isAuthorized(createAuthHeader(username, password), "/", new UserPrincipal(username), READ);
assertFalse(authorized);
}
use of io.pravega.shared.security.auth.UserPrincipal in project pravega by pravega.
the class RESTAuthHelperTest method testAuthOkForUnprivilegedUserForAssignedPermission.
@Test
public void testAuthOkForUnprivilegedUserForAssignedPermission() throws AuthException {
String username = FakeAuthHandler.UNPRIVILEGED_USER;
String password = "whatever";
boolean authorized = authHelper.isAuthorized(createAuthHeader(username, password), "/", new UserPrincipal(username), READ);
assertFalse(authorized);
}
use of io.pravega.shared.security.auth.UserPrincipal in project pravega by pravega.
the class RESTAuthHelperTest method testAuthFailsForUnprivilegedUserForUnassignedPermission.
@Test
public void testAuthFailsForUnprivilegedUserForUnassignedPermission() throws AuthException {
String username = FakeAuthHandler.UNPRIVILEGED_USER;
String password = "whatever";
boolean authorized = authHelper.isAuthorized(createAuthHeader(username, password), "/", new UserPrincipal(username), READ_UPDATE);
assertFalse(authorized);
}
use of io.pravega.shared.security.auth.UserPrincipal in project pravega by pravega.
the class PasswordAuthHandler method authenticate.
@Override
public Principal authenticate(String token) throws AuthException {
String[] parts = parseToken(token);
String userName = parts[0];
char[] password = parts[1].toCharArray();
try {
if (aclsByUser.containsKey(userName) && encryptor.checkPassword(password, aclsByUser.get(userName).getEncryptedPassword())) {
return new UserPrincipal(userName);
}
throw new AuthenticationException("User authentication exception");
} catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
log.warn("Exception during password authentication", e);
throw new AuthenticationException(e);
} finally {
// Zero out the password for security.
Arrays.fill(password, '0');
}
}
Aggregations