Search in sources :

Example 6 with UserData

use of org.ow2.proactive.authentication.UserData in project scheduling by ow2-proactive.

the class AuthenticationTest method loginAsUser.

private void loginAsUser(SchedulerAuthenticationInterface auth, PublicKey pubKey) throws KeyException, LoginException, AlreadyConnectedException, NotConnectedException, PermissionException {
    log("Test 2");
    log("Trying to authorized as a user with correct user name and password");
    Credentials cred = Credentials.createCredentials(new CredData(TestUsers.USER.username, TestUsers.USER.password), pubKey);
    Scheduler user = auth.login(cred);
    String userName = user.getCurrentUser();
    Assert.assertEquals(TestUsers.USER.username, userName);
    UserData userData = user.getCurrentUserData();
    Assert.assertNotNull(userData);
    Assert.assertNotNull(userData.getUserName());
    Assert.assertNotNull(userData.getGroups());
    Assert.assertTrue(userData.getGroups().contains("user"));
    user.disconnect();
    log("Passed: successful authentication");
}
Also used : UserData(org.ow2.proactive.authentication.UserData) Scheduler(org.ow2.proactive.scheduler.common.Scheduler) CredData(org.ow2.proactive.authentication.crypto.CredData) Credentials(org.ow2.proactive.authentication.crypto.Credentials)

Aggregations

UserData (org.ow2.proactive.authentication.UserData)6 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)3 CredData (org.ow2.proactive.authentication.crypto.CredData)2 Credentials (org.ow2.proactive.authentication.crypto.Credentials)2 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 KeyException (java.security.KeyException)1 LoginException (javax.security.auth.login.LoginException)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 Test (org.junit.Test)1 ActiveObjectCreationException (org.objectweb.proactive.ActiveObjectCreationException)1 UniqueID (org.objectweb.proactive.core.UniqueID)1 NodeException (org.objectweb.proactive.core.node.NodeException)1 ConnectionInfo (org.ow2.proactive.authentication.ConnectionInfo)1 ConnectionException (org.ow2.proactive.scheduler.common.exception.ConnectionException)1 InternalSchedulerException (org.ow2.proactive.scheduler.common.exception.InternalSchedulerException)1 JobAlreadyFinishedException (org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException)1 JobCreationException (org.ow2.proactive.scheduler.common.exception.JobCreationException)1