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");
}
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;
}
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;
}
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;
}
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");
}
Aggregations