use of org.ow2.proactive.authentication.crypto.Credentials in project scheduling by ow2-proactive.
the class PerUserConnectionRMProxiesManager method getUserRMProxy.
@Override
public RMProxy getUserRMProxy(String user, Credentials credentials) throws RMProxyCreationException {
synchronized (userProxiesMap) {
RMProxy proxy = userProxiesMap.get(user);
if (proxy == null) {
try {
proxy = new RMProxy(rmURI, credentials);
} catch (RMException e) {
throw new RMProxyCreationException(e);
}
createUserSession(user, credentials, proxy);
userProxiesMap.put(user, proxy);
} else {
if (!"true".equals(System.getProperty(SchedulerStarter.REST_DISABLED_PROPERTY))) {
// Rest session management works only if the rest server is launched in the same JVM as the scheduler server
Session currentSession = userSessions.get(user);
if (sessionStore.exists(currentSession.getSessionId())) {
// current session still referenced in SessionStore, renewing it
try {
currentSession.renewSession();
} catch (NotConnectedException e) {
// current session is not connected to the scheduler, creating a new one
createUserSession(user, credentials, proxy);
}
} else {
// current session has been removed from SessionStore due to inactivity, creating a new one
createUserSession(user, credentials, proxy);
}
}
}
return proxy;
}
}
use of org.ow2.proactive.authentication.crypto.Credentials in project scheduling by ow2-proactive.
the class PerUserConnectionRMProxiesManager method createUserSession.
private void createUserSession(String user, Credentials credentials, RMProxy proxy) throws RMProxyCreationException {
try {
if (!"true".equals(System.getProperty(SchedulerStarter.REST_DISABLED_PROPERTY))) {
// Rest session management works only if the rest server is launched in the same JVM as the scheduler server
Session session = sessionStore.create(user);
session.connectToRM(credentials);
proxy.setSessionid(session.getSessionId());
userSessions.put(user, session);
}
} catch (Exception e) {
throw new RMProxyCreationException(e);
}
}
use of org.ow2.proactive.authentication.crypto.Credentials in project scheduling by ow2-proactive.
the class TimedDoTaskAction method createAndSetCredentials.
private void createAndSetCredentials() throws KeyException, NoSuchAlgorithmException {
CredData decryptedUserCredentials = job.getCredentials().decrypt(corePrivateKey);
if (PASchedulerProperties.SCHEDULER_AUTH_GLOBAL_DOMAIN.isSet() && decryptedUserCredentials.getDomain() == null) {
decryptedUserCredentials.setDomain(PASchedulerProperties.SCHEDULER_AUTH_GLOBAL_DOMAIN.getValueAsString());
}
enrichWithThirdPartyCredentials(decryptedUserCredentials);
PublicKey nodePublicKey = launcher.generatePublicKey();
Credentials nodeEncryptedUserCredentials = Credentials.createCredentials(decryptedUserCredentials, nodePublicKey);
container.setCredentials(nodeEncryptedUserCredentials);
}
use of org.ow2.proactive.authentication.crypto.Credentials in project scheduling by ow2-proactive.
the class ForkedTaskVariablesManagerTest method initializeForkedTaskVariableManager.
private Map<String, Object> initializeForkedTaskVariableManager(ScriptHandler scriptHandler, TaskContext taskContext, VariablesMap variables, Map<String, String> credentials, Map<String, String> resultMetadata) throws IllegalAccessException, NoSuchFieldException {
// Create class
ForkedTaskVariablesManager forkedTaskVariablesManager = new ForkedTaskVariablesManager();
// Replace additionalBindings to hold a reference to it
Map<String, Object> scriptHandlerBindings = new HashMap<>();
setPrivateField(ScriptHandler.class.getDeclaredField("additionalBindings"), scriptHandler, scriptHandlerBindings);
SchedulerNodeClient schedulerNodeClient = forkedTaskVariablesManager.createSchedulerNodeClient(taskContext);
// Execute method which adds bindings
forkedTaskVariablesManager.addBindingsToScriptHandler(scriptHandler, taskContext, variables, credentials, schedulerNodeClient, forkedTaskVariablesManager.createDataSpaceNodeClient(taskContext, schedulerNodeClient, IDataSpaceClient.Dataspace.USER), forkedTaskVariablesManager.createDataSpaceNodeClient(taskContext, schedulerNodeClient, IDataSpaceClient.Dataspace.GLOBAL), resultMetadata);
return scriptHandlerBindings;
}
use of org.ow2.proactive.authentication.crypto.Credentials in project scheduling by ow2-proactive.
the class SchedulerRMProxyFactory method connectToRM.
public RMProxyUserInterface connectToRM(Credentials credentials) throws ActiveObjectCreationException, NodeException, RMException, KeyException, LoginException {
RMProxyUserInterface rm = PAActiveObject.newActive(RMProxyUserInterface.class, new Object[] {});
rm.init(PortalConfiguration.RM_URL.getValueAsString(), credentials);
return rm;
}
Aggregations