Search in sources :

Example 16 with User

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());
}
Also used : User(alluxio.security.User) Test(org.junit.Test)

Example 17 with User

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);
    });
}
Also used : AuthenticatedClientUser(alluxio.security.authentication.AuthenticatedClientUser) User(alluxio.security.User)

Example 18 with User

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;
}
Also used : NameCallback(javax.security.auth.callback.NameCallback) Callback(javax.security.auth.callback.Callback) NameCallback(javax.security.auth.callback.NameCallback) User(alluxio.security.User) LoginException(javax.security.auth.login.LoginException) IOException(java.io.IOException) UnsupportedCallbackException(javax.security.auth.callback.UnsupportedCallbackException)

Example 19 with User

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");
}
Also used : User(alluxio.security.User) LoginException(javax.security.auth.login.LoginException) Principal(java.security.Principal)

Aggregations

User (alluxio.security.User)19 Test (org.junit.Test)11 Subject (javax.security.auth.Subject)6 Principal (java.security.Principal)3 LoginException (javax.security.auth.login.LoginException)3 InstancedConfiguration (alluxio.conf.InstancedConfiguration)2 AuthenticatedClientUser (alluxio.security.authentication.AuthenticatedClientUser)2 HashSet (java.util.HashSet)2 AlluxioURI (alluxio.AlluxioURI)1 ClientContext (alluxio.ClientContext)1 AlluxioStorageType (alluxio.client.AlluxioStorageType)1 UnderStorageType (alluxio.client.UnderStorageType)1 LocalFirstPolicy (alluxio.client.block.policy.LocalFirstPolicy)1 FileSystem (alluxio.client.file.FileSystem)1 Key (alluxio.client.file.FileSystemCache.Key)1 URIStatus (alluxio.client.file.URIStatus)1 UnauthenticatedException (alluxio.exception.status.UnauthenticatedException)1 SetAttributePOptions (alluxio.grpc.SetAttributePOptions)1 ListAllMyBucketsResult (alluxio.proxy.s3.ListAllMyBucketsResult)1 Mode (alluxio.security.authorization.Mode)1