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));
}
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);
}
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;
}
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);
}
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);
}
}
Aggregations