Search in sources :

Example 1 with SchedulerAuthenticationInterface

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());
}
Also used : SchedulerStarter(org.ow2.proactive.scheduler.util.SchedulerStarter) RMAuthentication(org.ow2.proactive.resourcemanager.authentication.RMAuthentication) ProcessStreamReader(functionaltests.utils.ProcessStreamReader) SchedulerAuthenticationInterface(org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface) Credentials(org.ow2.proactive.authentication.crypto.Credentials)

Example 2 with SchedulerAuthenticationInterface

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;
}
Also used : PublicKey(java.security.PublicKey) CredData(org.ow2.proactive.authentication.crypto.CredData) SchedulerAuthenticationInterface(org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface) Credentials(org.ow2.proactive.authentication.crypto.Credentials)

Example 3 with SchedulerAuthenticationInterface

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);
}
Also used : MBeanInfoViewer(org.ow2.proactive.utils.console.MBeanInfoViewer) SchedulerAuthenticationInterface(org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface)

Example 4 with SchedulerAuthenticationInterface

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);
    }
}
Also used : InternalSchedulerException(org.ow2.proactive.scheduler.common.exception.InternalSchedulerException) MBeanInfoViewer(org.ow2.proactive.utils.console.MBeanInfoViewer) PublicKey(java.security.PublicKey) SchedulerAuthenticationInterface(org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface) Credentials(org.ow2.proactive.authentication.crypto.Credentials) KeyException(java.security.KeyException)

Example 5 with SchedulerAuthenticationInterface

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;
}
Also used : SchedulerAuthenticationInterface(org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface) URI(java.net.URI) LoginException(javax.security.auth.login.LoginException) KeyException(java.security.KeyException) URISyntaxException(java.net.URISyntaxException) InternalSchedulerException(org.ow2.proactive.scheduler.common.exception.InternalSchedulerException) ParseException(org.apache.commons.cli.ParseException) InvalidScriptException(org.ow2.proactive.scripting.InvalidScriptException) SocketException(java.net.SocketException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) ProActiveException(org.objectweb.proactive.core.ProActiveException) AlreadyBoundException(java.rmi.AlreadyBoundException)

Aggregations

SchedulerAuthenticationInterface (org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface)22 Credentials (org.ow2.proactive.authentication.crypto.Credentials)15 CredData (org.ow2.proactive.authentication.crypto.CredData)13 KeyException (java.security.KeyException)7 PublicKey (java.security.PublicKey)7 Test (org.junit.Test)6 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)6 LoginException (javax.security.auth.login.LoginException)5 JobId (org.ow2.proactive.scheduler.common.job.JobId)5 InternalSchedulerException (org.ow2.proactive.scheduler.common.exception.InternalSchedulerException)4 HashMap (java.util.HashMap)3 JMXConnector (javax.management.remote.JMXConnector)3 JMXServiceURL (javax.management.remote.JMXServiceURL)3 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)3 MBeanServerConnection (javax.management.MBeanServerConnection)2 ObjectName (javax.management.ObjectName)2 UserData (org.ow2.proactive.authentication.UserData)2 AlreadyConnectedException (org.ow2.proactive.scheduler.common.exception.AlreadyConnectedException)2 ConnectionException (org.ow2.proactive.scheduler.common.exception.ConnectionException)2 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)2