Search in sources :

Example 46 with Credentials

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;
    }
}
Also used : NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) RMException(org.ow2.proactive.resourcemanager.exception.RMException) Session(org.ow2.proactive_grid_cloud_portal.common.Session)

Example 47 with Credentials

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);
    }
}
Also used : URISyntaxException(java.net.URISyntaxException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) RMException(org.ow2.proactive.resourcemanager.exception.RMException) Session(org.ow2.proactive_grid_cloud_portal.common.Session)

Example 48 with Credentials

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

Example 49 with Credentials

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;
}
Also used : HashMap(java.util.HashMap) SchedulerNodeClient(org.ow2.proactive.scheduler.task.client.SchedulerNodeClient) ScriptHandler(org.ow2.proactive.scripting.ScriptHandler)

Example 50 with Credentials

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;
}
Also used : RMProxyUserInterface(org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface)

Aggregations

Credentials (org.ow2.proactive.authentication.crypto.Credentials)52 CredData (org.ow2.proactive.authentication.crypto.CredData)45 KeyException (java.security.KeyException)20 ResourceManager (org.ow2.proactive.resourcemanager.frontend.ResourceManager)18 LoginException (javax.security.auth.login.LoginException)17 PublicKey (java.security.PublicKey)15 Test (org.junit.Test)15 RMAuthentication (org.ow2.proactive.resourcemanager.authentication.RMAuthentication)14 HashMap (java.util.HashMap)13 IOException (java.io.IOException)12 SchedulerAuthenticationInterface (org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface)12 File (java.io.File)9 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)8 RMFunctionalTest (functionaltests.utils.RMFunctionalTest)6 JMXServiceURL (javax.management.remote.JMXServiceURL)6 ActiveObjectCreationException (org.objectweb.proactive.ActiveObjectCreationException)6 Node (org.objectweb.proactive.core.node.Node)6 RMException (org.ow2.proactive.resourcemanager.exception.RMException)6 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)6 JMXConnector (javax.management.remote.JMXConnector)5