use of org.ow2.proactive.authentication.crypto.CredData in project scheduling by ow2-proactive.
the class SmartProxyImpl method init.
@Override
public void init(ConnectionInfo connectionInfo) throws SchedulerException, LoginException {
this.connectionInfo = connectionInfo;
if (connectionInfo.getCredentialFile() != null) {
try {
Credentials credentials = Credentials.getCredentials(connectionInfo.getCredentialFile().getAbsolutePath());
init(connectionInfo.getUrl(), credentials);
} catch (KeyException e) {
throw new LoginException(e.getMessage());
}
} else {
CredData cred = new CredData(CredData.parseLogin(connectionInfo.getLogin()), CredData.parseDomain(connectionInfo.getLogin()), connectionInfo.getPassword());
init(connectionInfo.getUrl(), cred);
}
}
use of org.ow2.proactive.authentication.crypto.CredData in project scheduling by ow2-proactive.
the class SchedulerTestUser method connect.
/**
* Connects the singleton using the given user
*/
public boolean connect(String username, String password, byte[] key, String schedulerUrl) throws LoginException, KeyException, ActiveObjectCreationException, NodeException, SchedulerException {
this.connectedUserName = username;
this.connectedUserPassword = password;
this.connectedUserKey = key;
disconnectFromScheduler();
if (schedulerProxy == null) {
schedulerProxy = PAActiveObject.newActive(SchedulerProxyUserInterface.class, new Object[0]);
}
SchedulerTHelper.log("Connecting user " + connectedUserName + " to the Scheduler at url " + schedulerUrl);
CredData connectedUserCreds = new CredData(CredData.parseLogin(connectedUserName), CredData.parseDomain(connectedUserName), connectedUserPassword, connectedUserKey);
schedulerProxy.init(schedulerUrl, connectedUserCreds);
monitorsHandler = new SchedulerMonitorsHandler();
if (eventReceiver != null) {
PAActiveObject.terminateActiveObject(eventReceiver, true);
}
/**
* create event receiver then turnActive to avoid deepCopy of MonitorsHandler object
* (shared instance between event receiver and static helpers).
*/
MonitorEventReceiver passiveEventReceiver = new MonitorEventReceiver(monitorsHandler);
eventReceiver = PAActiveObject.turnActive(passiveEventReceiver);
SchedulerState state = schedulerProxy.addEventListener(eventReceiver, true, true);
monitorsHandler.init(state);
return true;
}
use of org.ow2.proactive.authentication.crypto.CredData in project scheduling by ow2-proactive.
the class TestScheduler method startLocalNodes.
private static void startLocalNodes(SchedulerTestConfiguration configuration) throws KeyException, LoginException, InterruptedException {
if (configuration.hasLocalNodes()) {
// Waiting while all the nodes will be registered in the RM.
// Without waiting test can finish earlier than nodes are added.
// It leads to test execution hang up on windows due to running processes.
Credentials creds = Credentials.createCredentials(new CredData(CredData.parseLogin(TestUsers.DEMO.username), CredData.parseDomain(TestUsers.DEMO.username), TestUsers.DEMO.password), rmAuth.getPublicKey());
ResourceManager rm = rmAuth.login(creds);
while (rm.getState().getTotalAliveNodesNumber() < SchedulerStartForFunctionalTest.RM_NODE_NUMBER) {
Thread.sleep(50);
}
PAFuture.waitFor(rm.disconnect());
System.out.println("Nodes are deployed");
}
}
use of org.ow2.proactive.authentication.crypto.CredData in project scheduling by ow2-proactive.
the class AuthenticationTest method loginAsAdminIncorrectPassword.
private void loginAsAdminIncorrectPassword(SchedulerAuthenticationInterface auth, PublicKey pubKey) {
// negative
log("Test 3");
log("Trying to authorized as an admin with incorrect user name and password");
try {
Credentials cred = Credentials.createCredentials(new CredData(TestUsers.DEMO.username, "b"), pubKey);
auth.login(cred);
fail("Error: successful authentication");
} catch (Exception e) {
log("Passed: expected error " + e.getMessage());
}
}
use of org.ow2.proactive.authentication.crypto.CredData 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