use of org.ow2.proactive.authentication.crypto.Credentials in project scheduling by ow2-proactive.
the class RMStateCaching method init_.
private static void init_() {
while (rm == null) {
String url = PortalConfiguration.RM_URL.getValueAsString();
String cred_path = PortalConfiguration.RM_CACHE_CREDENTIALS.getValueAsStringOrNull();
try {
if (rm == null) {
rm = PAActiveObject.newActive(RMProxyUserInterface.class, new Object[] {});
if (cred_path != null && !(new File(cred_path)).exists()) {
logger.error("Credentials path set in " + PortalConfiguration.RM_CACHE_CREDENTIALS.getKey() + " but file " + cred_path + " does not exist");
}
if (cred_path != null && new File(cred_path).exists()) {
Credentials cred = Credentials.getCredentials(cred_path);
rm.init(url, cred);
} else {
String login = PortalConfiguration.RM_CACHE_LOGIN.getValueAsString();
String password = PortalConfiguration.RM_CACHE_PASSWORD.getValueAsString();
rm.init(url, new CredData(login, password));
}
}
} catch (Exception e) {
logger.warn("Could not connect to resource manager at " + url + " retrying in 8 seconds", e);
if (rm != null) {
PAActiveObject.terminateActiveObject(rm, true);
rm = null;
}
new Sleeper(8 * 1000, logger).sleep();
continue;
}
}
}
use of org.ow2.proactive.authentication.crypto.Credentials in project scheduling by ow2-proactive.
the class SchedulerStateListener method connect.
private void connect() throws InterruptedException {
String url = PortalConfiguration.SCHEDULER_URL.getValueAsString();
String cred_path = PortalConfiguration.SCHEDULER_CACHE_CREDENTIALS.getValueAsStringOrNull();
while (scheduler == null && !killed) {
try {
scheduler = PAActiveObject.newActive(SchedulerProxyUserInterface.class, new Object[] {});
if (cred_path != null && !(new File(cred_path)).exists()) {
logger.error("Credentials path set in " + PortalConfiguration.SCHEDULER_CACHE_CREDENTIALS.getKey() + " but file " + cred_path + " does not exist");
}
// check is we use a credential file
if (cred_path != null && (new File(cred_path)).exists()) {
Credentials credential = Credentials.getCredentials(cred_path);
scheduler.init(url, credential);
} else {
String login = PortalConfiguration.SCHEDULER_CACHE_LOGIN.getValueAsString();
String password = PortalConfiguration.SCHEDULER_CACHE_PASSWORD.getValueAsString();
scheduler.init(url, login, password);
}
eventListener = new EventListener(state);
// for PROACTIVE-1027 PROACTIVE-1233
synchronized (MOPClassLoader.getMOPClassLoader()) {
eventListener = PAActiveObject.turnActive(eventListener);
}
scheduler.addEventListener(eventListener, false, false);
} catch (Exception e) {
logger.warn("no scheduler found on " + url + " retrying in 8 seconds", e);
if (scheduler != null) {
PAActiveObject.terminateActiveObject(scheduler, true);
scheduler = null;
}
Thread.sleep(8000);
continue;
}
}
}
use of org.ow2.proactive.authentication.crypto.Credentials in project scheduling by ow2-proactive.
the class SchedulerAuthenticationGUIHelper method login.
/**
* This method will log a client to the scheduler by requesting his URL, username and password from a
* graphical interface.
*
* @param schedulerURL The default URL of the scheduler to connect
* @return The connection to the scheduler as a {@link Scheduler} if logging successful.
* If the username is empty or if the user cancel the authentication, this method will return null.
* @throws LoginException If a problem occurs while logging the user.
* @throws SchedulerException If a problem occurs at scheduler level.
*/
public static Scheduler login(String schedulerURL) throws LoginException, SchedulerException {
AuthResultContainer auth = connect(schedulerURL);
if (auth == null) {
return null;
} else {
SchedulerAuthenticationInterface schedAuth = auth.getAuth();
Credentials cred = null;
try {
cred = Credentials.createCredentials(new CredData(CredData.parseLogin(auth.getUsername()), CredData.parseDomain(auth.getUsername()), auth.getPassword()), schedAuth.getPublicKey());
} catch (LoginException e) {
throw new LoginException("Could not retrieve public key from Scheduler " + schedulerURL + ", contact the administrator" + e);
} catch (KeyException e) {
throw new LoginException("Could not encrypt credentials " + e);
}
return schedAuth.login(cred);
}
}
use of org.ow2.proactive.authentication.crypto.Credentials 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.Credentials in project scheduling by ow2-proactive.
the class SchedulerStartForFunctionalTest method createRMAndScheduler.
private static void createRMAndScheduler(String[] args) throws Exception {
final boolean deployLocalNodes = Boolean.valueOf(args[0]);
String schedPropPath = args[1];
String rmPropPath = args[2];
PAResourceManagerProperties.updateProperties(rmPropPath);
PASchedulerProperties.updateProperties(schedPropPath);
RMFactory.setOsJavaProperty();
new SchedulerHsqldbStarter().startIfNeeded();
new Thread() {
public void run() {
try {
RMFactory.startLocal();
// waiting the initialization
RMAuthentication rmAuth = RMConnection.waitAndJoin(schedulerUrl);
if (deployLocalNodes) {
Credentials credentials = Credentials.getCredentials(PAResourceManagerProperties.getAbsolutePath(PAResourceManagerProperties.RM_CREDS.getValueAsString()));
ResourceManager rmAdmin = rmAuth.login(credentials);
rmAdmin.createNodeSource(RM_NODE_NAME, LocalInfrastructure.class.getName(), new Object[] { credentials.getBase64(), RM_NODE_NUMBER, RM_NODE_DEPLOYMENT_TIMEOUT, getJavaPropertiesLine() }, StaticPolicy.class.getName(), new Object[] { "ALL", "ALL" }, NODES_NOT_RECOVERABLE);
rmAdmin.disconnect();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}.start();
schedulerUrl = "pnp://localhost:" + PNPConfig.PA_PNP_PORT.getValue() + "/";
SchedulerFactory.createScheduler(new URI(schedulerUrl), PASchedulerProperties.SCHEDULER_DEFAULT_POLICY.getValueAsString(), SchedulerStatus.STARTED);
SchedulerConnection.waitAndJoin(schedulerUrl);
}
Aggregations