Search in sources :

Example 1 with UserData

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

the class AuthenticationTest method loginAsAdmin.

private void loginAsAdmin(SchedulerAuthenticationInterface auth, PublicKey pubKey) throws KeyException, LoginException, AlreadyConnectedException, NotConnectedException, PermissionException {
    log("Test 1");
    log("Trying to authorized as an admin with correct user name and password");
    Credentials cred = Credentials.createCredentials(new CredData(TestUsers.DEMO.username, TestUsers.DEMO.password), pubKey);
    Scheduler admin = auth.login(cred);
    String userName = admin.getCurrentUser();
    Assert.assertEquals(TestUsers.DEMO.username, userName);
    UserData userData = admin.getCurrentUserData();
    Assert.assertNotNull(userData);
    Assert.assertNotNull(userData.getUserName());
    Assert.assertNotNull(userData.getGroups());
    Assert.assertTrue(userData.getGroups().contains("scheduleradmins"));
    admin.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)

Example 2 with UserData

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

the class SchedulerFrontendState method getCurrentUserData.

public UserData getCurrentUserData() throws NotConnectedException {
    Pair<ListeningUser, UserIdentificationImpl> userSessionInfo = renewSession(false);
    UserData userData = new UserData();
    userData.setUserName(userSessionInfo.getRight().getUsername());
    userData.setGroups(userSessionInfo.getRight().getGroups());
    return userData;
}
Also used : UserData(org.ow2.proactive.authentication.UserData) UserIdentificationImpl(org.ow2.proactive.scheduler.job.UserIdentificationImpl)

Example 3 with UserData

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

the class SchedulerStateRest method getUserDataFromSessionId.

/**
 * {@inheritDoc}
 */
@Override
@GET
@Path("logins/sessionid/{sessionId}/userdata")
@Produces("application/json")
public UserData getUserDataFromSessionId(@PathParam("sessionId") String sessionId) {
    if (sessionId != null && sessionStore.exists(sessionId)) {
        try {
            renewSession(sessionId);
            Scheduler scheduler = sessionStore.get(sessionId).getScheduler();
            UserData userData = scheduler.getCurrentUserData();
            return userData;
        } catch (NotConnectedRestException | NotConnectedException e) {
            logger.trace(e);
        } catch (Exception e) {
            logger.warn(e);
        }
    }
    return null;
}
Also used : NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) UserData(org.ow2.proactive.authentication.UserData) SchedulerUserData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.SchedulerUserData) Scheduler(org.ow2.proactive.scheduler.common.Scheduler) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) KeyException(java.security.KeyException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) SchedulerRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.SchedulerRestException) InternalSchedulerException(org.ow2.proactive.scheduler.common.exception.InternalSchedulerException) LogForwardingRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.LogForwardingRestException) NodeException(org.objectweb.proactive.core.node.NodeException) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) JobCreationRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.JobCreationRestException) ConnectionException(org.ow2.proactive.scheduler.common.exception.ConnectionException) IOException(java.io.IOException) SchedulerException(org.ow2.proactive.scheduler.common.exception.SchedulerException) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) LoginException(javax.security.auth.login.LoginException) ActiveObjectCreationException(org.objectweb.proactive.ActiveObjectCreationException) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) URISyntaxException(java.net.URISyntaxException) UnknownTaskRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownTaskRestException) LogForwardingException(org.ow2.proactive.scheduler.common.util.logforwarder.LogForwardingException) JobAlreadyFinishedException(org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException) UnknownJobRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException) SubmissionClosedException(org.ow2.proactive.scheduler.common.exception.SubmissionClosedException) JobAlreadyFinishedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.JobAlreadyFinishedRestException) SubmissionClosedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.SubmissionClosedRestException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 4 with UserData

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

the class RMCore method getCurrentUserData.

@Override
public UserData getCurrentUserData() {
    UserData userData = new UserData();
    userData.setUserName(caller.getName());
    userData.setGroups(caller.getGroups());
    return userData;
}
Also used : UserData(org.ow2.proactive.authentication.UserData)

Example 5 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 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 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)1