Search in sources :

Example 46 with CredData

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

the class SessionSharingTest method setUp.

@Before
public void setUp() throws Exception {
    schedulerRest = new SchedulerStateRest();
    rmRest = new RMRest();
    studioRest = new StudioRest();
    SchedulerRMProxyFactory schedulerFactory = mock(SchedulerRMProxyFactory.class);
    rmMock = mock(RMProxyUserInterface.class);
    when(schedulerFactory.connectToRM(Matchers.<CredData>any())).thenReturn(rmMock);
    schedulerMock = mock(SchedulerProxyUserInterface.class);
    when(schedulerFactory.connectToScheduler(Matchers.<CredData>any())).thenReturn(schedulerMock);
    SharedSessionStore.getInstance().setSchedulerRMProxyFactory(schedulerFactory);
}
Also used : StudioRest(org.ow2.proactive_grid_cloud_portal.studio.StudioRest) SchedulerProxyUserInterface(org.ow2.proactive.scheduler.common.util.SchedulerProxyUserInterface) SchedulerStateRest(org.ow2.proactive_grid_cloud_portal.scheduler.SchedulerStateRest) RMProxyUserInterface(org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface) RMRest(org.ow2.proactive_grid_cloud_portal.rm.RMRest) SchedulerRMProxyFactory(org.ow2.proactive_grid_cloud_portal.common.SchedulerRMProxyFactory) Before(org.junit.Before)

Example 47 with CredData

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

the class SchedulerRMProxyFactory method connectToScheduler.

public SchedulerProxyUserInterface connectToScheduler(CredData credData) throws ActiveObjectCreationException, NodeException, LoginException, SchedulerException {
    SchedulerProxyUserInterface scheduler = PAActiveObject.newActive(SchedulerProxyUserInterface.class, new Object[] {});
    scheduler.init(PortalConfiguration.SCHEDULER_URL.getValueAsString(), credData);
    return scheduler;
}
Also used : SchedulerProxyUserInterface(org.ow2.proactive.scheduler.common.util.SchedulerProxyUserInterface)

Example 48 with CredData

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

the class SchedulerRMProxyFactory method connectToRM.

public RMProxyUserInterface connectToRM(CredData credData) throws ActiveObjectCreationException, NodeException, RMException, KeyException, LoginException {
    RMProxyUserInterface rm = PAActiveObject.newActive(RMProxyUserInterface.class, new Object[] {});
    rm.init(PortalConfiguration.RM_URL.getValueAsString(), credData);
    return rm;
}
Also used : RMProxyUserInterface(org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface)

Example 49 with CredData

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

the class RMStateCaching method init_.

private static void init_() {
    while (rm == null) {
        String url = PortalConfiguration.RM_URL.getValueAsString();
        String cred_path = PortalConfiguration.RM_CACHE_CREDENTIALS.getValueAsStringOrNull();
        try {
            if (rm == null) {
                rm = PAActiveObject.newActive(RMProxyUserInterface.class, new Object[] {});
                if (cred_path != null && !(new File(cred_path)).exists()) {
                    logger.error("Credentials path set in " + PortalConfiguration.RM_CACHE_CREDENTIALS.getKey() + " but file " + cred_path + " does not exist");
                }
                if (cred_path != null && new File(cred_path).exists()) {
                    Credentials cred = Credentials.getCredentials(cred_path);
                    rm.init(url, cred);
                } else {
                    String login = PortalConfiguration.RM_CACHE_LOGIN.getValueAsString();
                    String password = PortalConfiguration.RM_CACHE_PASSWORD.getValueAsString();
                    rm.init(url, new CredData(login, password));
                }
            }
        } catch (Exception e) {
            logger.warn("Could not connect to resource manager at " + url + " retrying in 8 seconds", e);
            if (rm != null) {
                PAActiveObject.terminateActiveObject(rm, true);
                rm = null;
            }
            new Sleeper(8 * 1000, logger).sleep();
            continue;
        }
    }
}
Also used : RMProxyUserInterface(org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface) CredData(org.ow2.proactive.authentication.crypto.CredData) PAActiveObject(org.objectweb.proactive.api.PAActiveObject) Sleeper(org.objectweb.proactive.utils.Sleeper) File(java.io.File) Credentials(org.ow2.proactive.authentication.crypto.Credentials)

Example 50 with CredData

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

the class JMXAuthenticatorImpl method authenticate.

/**
 * This method is automatically called when a JMX client tries to connect to the MBean Server referred
 * by the connector.
 * <p>
 * The only allowed credentials structure provided by the client is Object[] that contains
 * username/password (String/String) or username/{@link org.ow2.proactive.authentication.crypto.Credentials}
 *
 * @return a subject with the username as JMXPrincipal and the role as pubCredentials {@link javax.security.auth.Subject}
 * @param rawCredentials the credentials provided by the client
 */
public Subject authenticate(final Object rawCredentials) {
    // If not an array of object do not give any clues just throw exception
    if (rawCredentials == null || !(rawCredentials instanceof Object[])) {
        throw new SecurityException("Invalid credentials");
    }
    final Object[] arr = (Object[]) rawCredentials;
    if (arr[0] == null || arr[1] == null) {
        throw new SecurityException("Invalid credentials");
    }
    final String username = arr[0].toString();
    Credentials internalCredentials = null;
    // If username/Credentials
    if (arr[1] instanceof Credentials) {
        internalCredentials = (Credentials) arr[1];
    // If username/password (ex: JConsole)
    } else if (arr[1] instanceof String) {
        try {
            internalCredentials = Credentials.createCredentials(new CredData(CredData.parseLogin(username), CredData.parseDomain(username), (String) arr[1]), authentication.getPublicKey());
        } catch (Exception e) {
            throw new SecurityException("Invalid credentials", e);
        }
    } else {
        throw new SecurityException("Invalid credentials");
    }
    try {
        Subject s = this.authentication.authenticate(internalCredentials);
        if (permissionChecker != null) {
            boolean allowed = permissionChecker.checkPermission(internalCredentials);
            if (!allowed) {
                throw new SecurityException("Permission denied");
            }
        }
        return s;
    } catch (LoginException e) {
        throw new SecurityException("Unable to authenticate " + username);
    }
}
Also used : CredData(org.ow2.proactive.authentication.crypto.CredData) LoginException(javax.security.auth.login.LoginException) Credentials(org.ow2.proactive.authentication.crypto.Credentials) LoginException(javax.security.auth.login.LoginException) Subject(javax.security.auth.Subject)

Aggregations

CredData (org.ow2.proactive.authentication.crypto.CredData)53 Credentials (org.ow2.proactive.authentication.crypto.Credentials)41 PublicKey (java.security.PublicKey)15 Test (org.junit.Test)15 LoginException (javax.security.auth.login.LoginException)13 KeyException (java.security.KeyException)10 ResourceManager (org.ow2.proactive.resourcemanager.frontend.ResourceManager)10 SchedulerAuthenticationInterface (org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface)10 RMAuthentication (org.ow2.proactive.resourcemanager.authentication.RMAuthentication)9 HashMap (java.util.HashMap)8 RMFunctionalTest (functionaltests.utils.RMFunctionalTest)6 JMXServiceURL (javax.management.remote.JMXServiceURL)6 JMXConnector (javax.management.remote.JMXConnector)5 RMProxyUserInterface (org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface)5 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)5 SchedulerProxyUserInterface (org.ow2.proactive.scheduler.common.util.SchedulerProxyUserInterface)5 Decrypter (org.ow2.proactive.scheduler.task.utils.Decrypter)5 MBeanServerConnection (javax.management.MBeanServerConnection)4 ObjectName (javax.management.ObjectName)4 POST (javax.ws.rs.POST)4