use of org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface in project scheduling by ow2-proactive.
the class SchedulerStarter method start.
protected static void start(CommandLine commandLine) throws Exception {
// force properties loading to find out if PAMR router should be started
ProActiveConfiguration.load();
if (!commandLine.hasOption(OPTION_NO_ROUTER)) {
startRouter();
}
hsqldbServer = new SchedulerHsqldbStarter();
hsqldbServer.startIfNeeded();
rmURL = getRmUrl(commandLine);
setCleanDatabaseProperties(commandLine);
setCleanNodesourcesProperty(commandLine);
rmURL = connectToOrStartResourceManager(commandLine, rmURL);
if (commandLine.hasOption(OPTION_RM_ONLY)) {
return;
}
schedulerURL = getSchedulerUrl(commandLine);
if (!commandLine.hasOption(OPTION_SCHEDULER_URL)) {
SchedulerAuthenticationInterface schedulerAuthenticationInterface = startScheduler(commandLine, rmURL);
schedulerURL = schedulerAuthenticationInterface.getHostURL();
schedAuthInter = schedulerAuthenticationInterface;
}
if (!commandLine.hasOption(OPTION_NO_REST)) {
startJetty(rmURL, schedulerURL);
}
addShutdownMessageHook();
executeStartScripts();
}
use of org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface in project scheduling by ow2-proactive.
the class AuthenticationTest method action.
@Test
public void action() throws Exception {
SchedulerAuthenticationInterface auth = schedulerHelper.getSchedulerAuth();
PublicKey pubKey = auth.getPublicKey();
loginAsAdmin(auth, pubKey);
loginAsUser(auth, pubKey);
loginAsAdminIncorrectPassword(auth, pubKey);
loginAsUserIncorrectPassword(auth, pubKey);
}
use of org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface in project scheduling by ow2-proactive.
the class AuthenticationTest method loginAsUserIncorrectPassword.
private void loginAsUserIncorrectPassword(SchedulerAuthenticationInterface auth, PublicKey pubKey) {
log("Test 4");
log("Trying to authorized as a user with incorrect user name and password");
try {
Credentials cred = Credentials.createCredentials(new CredData(TestUsers.USER.username, "b"), pubKey);
auth.login(cred);
fail("Error: successful authentication");
} catch (Exception e) {
log("Passed: expected error " + e.getMessage());
}
}
use of org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface 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("admin"));
admin.disconnect();
log("Passed: successful authentication");
}
use of org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface in project scheduling by ow2-proactive.
the class SmartProxyImpl method init.
private void init(String url, Credentials credentials, CredData credData) throws SchedulerException, LoginException {
if (this.connectionInfo == null) {
this.connectionInfo = new ConnectionInfo(url, null, null, null, false);
}
this.connectionInfo.setUrl(url);
this.credentials = credentials;
this.credData = credData;
SchedulerAuthenticationInterface auth = SchedulerConnection.join(url);
PublicKey pubKey = auth.getPublicKey();
if (this.credentials != null) {
this.credentials = credentials;
this.credData = null;
} else if (this.credData != null) {
this.credData = credData;
try {
this.credentials = Credentials.createCredentials(credData, pubKey);
} catch (KeyException e) {
throw new InternalSchedulerException(e);
}
} else {
throw new IllegalStateException("No valid credential available to connect to the scheduler");
}
this.schedulerProxy = auth.login(this.credentials);
jobTracker.loadJobs();
setInitialized(true);
registerAsListener();
syncAwaitedJobs();
}
Aggregations