Search in sources :

Example 6 with User

use of alluxio.security.User in project alluxio by Alluxio.

the class GrpcSecurityTest method createSubject.

private Subject createSubject(String username, String password) {
    Subject subject = new Subject();
    subject.getPrincipals().add(new User(username));
    subject.getPrivateCredentials().add(password);
    return subject;
}
Also used : User(alluxio.security.User) Subject(javax.security.auth.Subject)

Example 7 with User

use of alluxio.security.User in project alluxio by Alluxio.

the class UserStateTest method securityEnabled.

// TODO(dong): getKerberosLoginUserTest()
@Test
public void securityEnabled() throws Exception {
    mConfiguration.set(PropertyKey.SECURITY_AUTHENTICATION_TYPE, AuthType.NOSASL.getAuthName());
    // without security, the user will be blank.
    User u = UserState.Factory.create(mConfiguration).getUser();
    Assert.assertEquals("", u.getName());
}
Also used : User(alluxio.security.User) Test(org.junit.Test)

Example 8 with User

use of alluxio.security.User in project alluxio by Alluxio.

the class UserStateTest method getCustomLoginUserWhenNotProvidedByApp.

/**
 * Tests whether we can get login user with conf in CUSTOM mode, when user name is set to an
 * empty string in the application configuration. In this case, login should return the OS user
 * instead of empty string.
 */
@Test
public void getCustomLoginUserWhenNotProvidedByApp() throws Exception {
    mConfiguration.set(PropertyKey.SECURITY_AUTHENTICATION_TYPE, AuthType.CUSTOM.getAuthName());
    mConfiguration.unset(PropertyKey.SECURITY_LOGIN_USERNAME);
    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 9 with User

use of alluxio.security.User in project alluxio by Alluxio.

the class UserStateTest method getSimpleLoginUserWhenNotProvidedByApp.

/**
 * Tests whether we can get login user with conf in SIMPLE mode, when user name is set to an
 * empty string in the application configuration. In this case, login should return the OS user
 * instead of empty string.
 */
@Test
public void getSimpleLoginUserWhenNotProvidedByApp() throws Exception {
    mConfiguration.set(PropertyKey.SECURITY_AUTHENTICATION_TYPE, AuthType.SIMPLE.getAuthName());
    mConfiguration.unset(PropertyKey.SECURITY_LOGIN_USERNAME);
    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 10 with User

use of alluxio.security.User in project alluxio by Alluxio.

the class UserStateTest method getSimpleLoginUserProvidedByApp.

/**
 * Tests whether we can get login user with conf in SIMPLE mode, when user name is provided by
 * the application through configuration.
 */
@Test
public void getSimpleLoginUserProvidedByApp() throws Exception {
    mConfiguration.set(PropertyKey.SECURITY_AUTHENTICATION_TYPE, AuthType.SIMPLE.getAuthName());
    mConfiguration.set(PropertyKey.SECURITY_LOGIN_USERNAME, "alluxio-user");
    UserState s = UserState.Factory.create(mConfiguration);
    User loginUser = s.getUser();
    assertNotNull(loginUser);
    assertEquals("alluxio-user", loginUser.getName());
}
Also used : User(alluxio.security.User) Test(org.junit.Test)

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