use of alluxio.security.User in project alluxio by Alluxio.
the class UserStateTest method getSimpleLoginUser.
/**
* Tests whether we can get login user with conf in SIMPLE mode.
*/
@Test
public void getSimpleLoginUser() throws Exception {
mConfiguration.set(PropertyKey.SECURITY_AUTHENTICATION_TYPE, AuthType.SIMPLE.getAuthName());
UserState s = UserState.Factory.create(mConfiguration);
User loginUser = s.getUser();
assertNotNull(loginUser);
assertEquals(System.getProperty("user.name"), loginUser.getName());
}
use of alluxio.security.User in project alluxio by Alluxio.
the class GrpcExecutorsTest method validateAuthenticatedClientUser.
private void validateAuthenticatedClientUser(ExecutorService executor) {
final User contextProxyUser = AuthenticatedClientUser.getOrNull();
executor.execute(() -> {
User workerProxyUser = AuthenticatedClientUser.getOrNull();
assertEquals(contextProxyUser, workerProxyUser);
});
AuthenticatedClientUser.set(IMPERSONATION_PROXY_USER_NAME);
User newContextProxyUser = AuthenticatedClientUser.getOrNull();
executor.execute(() -> {
User workerProxyUser = AuthenticatedClientUser.getOrNull();
assertEquals(newContextProxyUser, workerProxyUser);
});
}
use of alluxio.security.User in project alluxio by Alluxio.
the class AppLoginModule method login.
/**
* Retrieves the user name by querying the property of
* {@link PropertyKey#SECURITY_LOGIN_USERNAME} through {@link AppCallbackHandler}.
*
* @return true if user name provided by application is set and not empty
* @throws LoginException when the login fails
*/
@Override
public boolean login() throws LoginException {
Callback[] callbacks = new Callback[1];
callbacks[0] = new NameCallback("user name: ");
try {
mCallbackHandler.handle(callbacks);
} catch (IOException | UnsupportedCallbackException e) {
throw new LoginException(e.getMessage());
}
String userName = ((NameCallback) callbacks[0]).getName();
if (!userName.isEmpty()) {
mUser = new User(userName);
return true;
}
return false;
}
use of alluxio.security.User in project alluxio by Alluxio.
the class AlluxioLoginModule method commit.
/**
* Commits the authentication (second phase).
*
* This method is called if the LoginContext's overall authentication succeeded. (login
* succeeded)
* The implementation searches the Kerberos or OS user in the Subject. If existed,
* convert it to an Alluxio user and add into the Subject.
* @return true in all cases
* @throws LoginException if the user extending a specific Principal is not found
*/
@Override
public boolean commit() throws LoginException {
// if there is already an Alluxio user, it's done.
if (!mSubject.getPrincipals(User.class).isEmpty()) {
return true;
}
// get a OS user
Principal user = getPrincipalUser(LoginModuleConfigurationUtils.OS_PRINCIPAL_CLASS_NAME);
// if a user is found, convert it to an Alluxio user and save it.
if (user != null) {
mUser = new User(user.getName());
mSubject.getPrincipals().add(mUser);
return true;
}
throw new LoginException("Cannot find a user");
}
Aggregations