Search in sources :

Example 16 with Credentials

use of org.ow2.proactive.authentication.crypto.Credentials in project scheduling by ow2-proactive.

the class SchedulerNodeClient method connect.

/**
 * Connects to the scheduler at the specified schedulerRestUrl, using the current user credentials
 * @param url schedulerRestUrl of the scheduler
 * @throws Exception
 */
public void connect(String url) throws Exception {
    CredData userCreds = decrypter.decrypt();
    client = SchedulerClient.createInstance();
    client.init(new ConnectionInfo(url, userCreds.getLogin(), userCreds.getPassword(), null, true));
}
Also used : CredData(org.ow2.proactive.authentication.crypto.CredData) ConnectionInfo(org.ow2.proactive.authentication.ConnectionInfo)

Example 17 with Credentials

use of org.ow2.proactive.authentication.crypto.Credentials in project scheduling by ow2-proactive.

the class TaskContextVariableExtractor method extractVariablesThirdPartyCredentialsAndSystemEnvironmentVariables.

/**
 * Retrieve all third party credential variables in a map.
 *
 * @param taskContext all information to extract third party credentials is here.
 *
 * @return map containing thirdPartyCredentials
 */
public Map<String, String> extractVariablesThirdPartyCredentialsAndSystemEnvironmentVariables(TaskContext taskContext) {
    ForkEnvironment forkEnvironment = taskContext.getInitializer().getForkEnvironment();
    Map<String, Serializable> variables = new HashMap<>();
    try {
        variables = extractAllVariables(taskContext, null, "");
    } catch (IOException | ClassNotFoundException e) {
        logger.error(ERROR_READING_VARIABLES, e);
    }
    Map<String, String> thirdPartyCredentials = new HashMap<>();
    try {
        thirdPartyCredentials = forkedTaskVariablesManager.extractThirdPartyCredentials(taskContext);
    } catch (Exception e) {
        logger.error(ERROR_READING_VARIABLES, e);
    }
    HashMap<String, Serializable> systemEnvironmentVariables = new HashMap<String, Serializable>(System.getenv());
    systemEnvironmentVariables.putAll(variables);
    systemEnvironmentVariables.putAll(thirdPartyCredentials);
    return VariableSubstitutor.filterAndUpdate(forkEnvironment.getSystemEnvironment(), systemEnvironmentVariables);
}
Also used : Serializable(java.io.Serializable) HashMap(java.util.HashMap) IOException(java.io.IOException) ForkEnvironment(org.ow2.proactive.scheduler.common.task.ForkEnvironment) IOException(java.io.IOException)

Example 18 with Credentials

use of org.ow2.proactive.authentication.crypto.Credentials in project scheduling by ow2-proactive.

the class ForkedProcessBuilderCreator method executeForkEnvironmentScriptAndExtractVariables.

private ScriptResult executeForkEnvironmentScriptAndExtractVariables(TaskContext context, PrintStream outputSink, PrintStream errorSink, OSProcessBuilder processBuilder) throws Exception {
    ScriptResult forkEnvironmentScriptResult = null;
    ForkEnvironment forkEnvironment = context.getInitializer().getForkEnvironment();
    if (forkEnvironment != null) {
        if (forkEnvironment.getEnvScript() != null) {
            if (!context.getInitializer().isAuthorizedForkEnvironmentScript()) {
                throw new SecurityException("Unauthorized fork environment script: " + System.getProperty("line.separator") + forkEnvironment.getEnvScript().fetchScript());
            }
            forkEnvironmentScriptResult = forkEnvironmentScriptExecutor.executeForkEnvironmentScript(context, outputSink, errorSink);
        }
        try {
            processBuilder.environment().putAll(// by existing environment variables, variables and credentials
            taskContextVariableExtractor.extractVariablesThirdPartyCredentialsAndSystemEnvironmentVariables(context));
        } catch (IllegalArgumentException processEnvironmentReadOnly) {
            throw new IllegalStateException("Cannot use runAsMe mode and set system environment properties", processEnvironmentReadOnly);
        }
    }
    return forkEnvironmentScriptResult;
}
Also used : ScriptResult(org.ow2.proactive.scripting.ScriptResult) ForkEnvironment(org.ow2.proactive.scheduler.common.task.ForkEnvironment)

Example 19 with Credentials

use of org.ow2.proactive.authentication.crypto.Credentials 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 20 with Credentials

use of org.ow2.proactive.authentication.crypto.Credentials 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)

Aggregations

Credentials (org.ow2.proactive.authentication.crypto.Credentials)50 CredData (org.ow2.proactive.authentication.crypto.CredData)42 KeyException (java.security.KeyException)17 ResourceManager (org.ow2.proactive.resourcemanager.frontend.ResourceManager)17 PublicKey (java.security.PublicKey)15 LoginException (javax.security.auth.login.LoginException)15 Test (org.junit.Test)14 SchedulerAuthenticationInterface (org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface)13 RMAuthentication (org.ow2.proactive.resourcemanager.authentication.RMAuthentication)12 IOException (java.io.IOException)11 HashMap (java.util.HashMap)11 File (java.io.File)9 RMFunctionalTest (functionaltests.utils.RMFunctionalTest)6 JMXServiceURL (javax.management.remote.JMXServiceURL)6 JMXConnector (javax.management.remote.JMXConnector)5 Node (org.objectweb.proactive.core.node.Node)5 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)5 MBeanServerConnection (javax.management.MBeanServerConnection)4 ObjectName (javax.management.ObjectName)4 POST (javax.ws.rs.POST)4