use of org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface in project scheduling by ow2-proactive.
the class RestFuncTHelper method startRestfulSchedulerWebapp.
public static void startRestfulSchedulerWebapp(int nbNodes) throws Exception {
// Kill all children processes on exit
org.apache.log4j.BasicConfigurator.configure(new org.apache.log4j.varia.NullAppender());
CookieBasedProcessTreeKiller.registerKillChildProcessesOnShutdown("rest_tests");
List<String> cmd = new ArrayList<>();
String javaPath = RestFuncTUtils.getJavaPathFromSystemProperties();
cmd.add(javaPath);
cmd.add("-Djava.security.manager");
cmd.add(CentralPAPropertyRepository.JAVA_SECURITY_POLICY.getCmdLine() + toPath(serverJavaPolicy));
cmd.add(CentralPAPropertyRepository.PA_HOME.getCmdLine() + getSchedHome());
cmd.add(PASchedulerProperties.SCHEDULER_HOME.getCmdLine() + getSchedHome());
cmd.add(PAResourceManagerProperties.RM_HOME.getCmdLine() + getRmHome());
cmd.add(PAResourceManagerProperties.RM_DB_HIBERNATE_DROPDB.getCmdLine() + System.getProperty("rm.deploy.dropDB", "true"));
cmd.add(PAResourceManagerProperties.RM_DB_HIBERNATE_CONFIG.getCmdLine() + toPath(rmHibernateConfig));
cmd.add(PASchedulerProperties.SCHEDULER_DB_HIBERNATE_DROPDB.getCmdLine() + System.getProperty("scheduler.deploy.dropDB", "true"));
cmd.add(PASchedulerProperties.SCHEDULER_DB_HIBERNATE_CONFIG.getCmdLine() + toPath(schedHibernateConfig));
cmd.add(WebProperties.WEB_HTTPS.getCmdLine() + "true");
cmd.add(CentralPAPropertyRepository.PA_COMMUNICATION_PROTOCOL.getCmdLine() + "pnp");
cmd.add(PNPConfig.PA_PNP_PORT.getCmdLine() + "1200");
cmd.add("-cp");
cmd.add(getClassPath());
cmd.add(SchedulerStarter.class.getName());
cmd.add("-ln");
cmd.add("" + nbNodes);
ProcessBuilder processBuilder = new ProcessBuilder(cmd);
processBuilder.redirectErrorStream(true);
schedProcess = processBuilder.start();
ProcessStreamReader out = new ProcessStreamReader("scheduler-output: ", schedProcess.getInputStream());
out.start();
// RM and scheduler are on the same url
String port = "1200";
String url = "pnp://localhost:" + port + "/";
// Connect a scheduler client
SchedulerAuthenticationInterface schedAuth = SchedulerConnection.waitAndJoin(url, TimeUnit.SECONDS.toMillis(120));
schedulerPublicKey = schedAuth.getPublicKey();
Credentials schedCred = RestFuncTUtils.createCredentials("admin", "admin", schedulerPublicKey);
scheduler = schedAuth.login(schedCred);
// Connect a rm client
RMAuthentication rmAuth = RMConnection.waitAndJoin(url, TimeUnit.SECONDS.toMillis(120));
Credentials rmCredentials = getRmCredentials();
rm = rmAuth.login(rmCredentials);
restServerUrl = "https://localhost:8443/rest/";
restfulSchedulerUrl = restServerUrl + "scheduler";
await().atMost(Duration.FIVE_MINUTES).until(restIsStarted());
}
use of org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface in project scheduling by ow2-proactive.
the class CredentialsCreator method createCredentials.
private byte[] createCredentials(String username, String password) throws ConnectionException, LoginException, KeyException {
String url = PortalConfiguration.SCHEDULER_URL.getValueAsString();
SchedulerAuthenticationInterface auth = SchedulerConnection.join(url);
PublicKey pubKey = auth.getPublicKey();
byte[] privateKey = auth.getPrivateKey();
Credentials cred = Credentials.createCredentials(new CredData(CredData.parseLogin(username), CredData.parseDomain(username), password, privateKey), pubKey);
byte[] credentialBytes = cred.getBase64();
return credentialBytes;
}
use of org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface in project scheduling by ow2-proactive.
the class SchedulerProxyUserInterface method init.
/**
* initialize the connection the scheduler.
* Must be called only once
* @param url the scheduler's url
* @param credentials the credential to be passed to the scheduler
* @throws SchedulerException thrown if the scheduler is not available
* @throws LoginException thrown if the credential is invalid
*/
public void init(String url, Credentials credentials) throws SchedulerException, LoginException {
SchedulerAuthenticationInterface auth = SchedulerConnection.join(url);
this.uischeduler = auth.login(credentials);
mbeaninfoviewer = new MBeanInfoViewer(auth, null, credentials);
}
use of org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface in project scheduling by ow2-proactive.
the class SchedulerProxyUserInterface method init.
/**
* initialize the connection the scheduler.
* Must be called only once.
* Create the corresponding credential object before sending it
* to the scheduler.
* @param url the scheduler's url
* @param credData the credential object that contains user-related data
* @throws SchedulerException thrown if the scheduler is not available
* @throws LoginException if the couple username/password is invalid
* @since Scheduling 3.1.0
*/
public void init(String url, CredData credData) throws SchedulerException, LoginException {
SchedulerAuthenticationInterface auth = SchedulerConnection.join(url);
PublicKey pubKey = auth.getPublicKey();
try {
Credentials cred = Credentials.createCredentials(credData, pubKey);
this.uischeduler = auth.login(cred);
mbeaninfoviewer = new MBeanInfoViewer(auth, credData.getLogin(), cred);
} catch (KeyException e) {
throw new InternalSchedulerException(e);
}
}
use of org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface in project scheduling by ow2-proactive.
the class SchedulerStarter method startScheduler.
private static SchedulerAuthenticationInterface startScheduler(CommandLine commandLine, String rmUrl) throws URISyntaxException, InternalSchedulerException, ParseException, SocketException, UnknownHostException, IllegalArgumentException {
String policyFullName = getPolicyFullName(commandLine);
LOGGER.info("Scheduler version is " + getSchedulerVersion());
LOGGER.info("Starting the scheduler...");
SchedulerAuthenticationInterface sai = null;
try {
sai = SchedulerFactory.startLocal(new URI(rmUrl), policyFullName);
startDiscovery(commandLine, rmUrl);
LOGGER.info("The scheduler created on " + sai.getHostURL());
} catch (Exception e) {
e.printStackTrace();
}
return sai;
}
Aggregations