Search in sources :

Example 51 with CredData

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

the class SmartProxyImpl method init.

@Override
public void init(ConnectionInfo connectionInfo) throws SchedulerException, LoginException {
    this.connectionInfo = connectionInfo;
    if (connectionInfo.getCredentialFile() != null) {
        try {
            Credentials credentials = Credentials.getCredentials(connectionInfo.getCredentialFile().getAbsolutePath());
            init(connectionInfo.getUrl(), credentials);
        } catch (KeyException e) {
            throw new LoginException(e.getMessage());
        }
    } else {
        CredData cred = new CredData(CredData.parseLogin(connectionInfo.getLogin()), CredData.parseDomain(connectionInfo.getLogin()), connectionInfo.getPassword());
        init(connectionInfo.getUrl(), cred);
    }
}
Also used : CredData(org.ow2.proactive.authentication.crypto.CredData) LoginException(javax.security.auth.login.LoginException) Credentials(org.ow2.proactive.authentication.crypto.Credentials) KeyException(java.security.KeyException)

Example 52 with CredData

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

the class SchedulerTestUser method connect.

/**
 * Connects the singleton using the given user
 */
public boolean connect(String username, String password, byte[] key, String schedulerUrl) throws LoginException, KeyException, ActiveObjectCreationException, NodeException, SchedulerException {
    this.connectedUserName = username;
    this.connectedUserPassword = password;
    this.connectedUserKey = key;
    disconnectFromScheduler();
    if (schedulerProxy == null) {
        schedulerProxy = PAActiveObject.newActive(SchedulerProxyUserInterface.class, new Object[0]);
    }
    SchedulerTHelper.log("Connecting user " + connectedUserName + " to the Scheduler at url " + schedulerUrl);
    CredData connectedUserCreds = new CredData(CredData.parseLogin(connectedUserName), CredData.parseDomain(connectedUserName), connectedUserPassword, connectedUserKey);
    schedulerProxy.init(schedulerUrl, connectedUserCreds);
    monitorsHandler = new SchedulerMonitorsHandler();
    if (eventReceiver != null) {
        PAActiveObject.terminateActiveObject(eventReceiver, true);
    }
    /**
     * create event receiver then turnActive to avoid deepCopy of MonitorsHandler object
     * 	(shared instance between event receiver and static helpers).
     */
    MonitorEventReceiver passiveEventReceiver = new MonitorEventReceiver(monitorsHandler);
    eventReceiver = PAActiveObject.turnActive(passiveEventReceiver);
    SchedulerState state = schedulerProxy.addEventListener(eventReceiver, true, true);
    monitorsHandler.init(state);
    return true;
}
Also used : MonitorEventReceiver(functionaltests.monitor.MonitorEventReceiver) SchedulerState(org.ow2.proactive.scheduler.common.SchedulerState) SchedulerProxyUserInterface(org.ow2.proactive.scheduler.common.util.SchedulerProxyUserInterface) CredData(org.ow2.proactive.authentication.crypto.CredData) PAActiveObject(org.objectweb.proactive.api.PAActiveObject) SchedulerMonitorsHandler(functionaltests.monitor.SchedulerMonitorsHandler)

Example 53 with CredData

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

the class TestScheduler method startLocalNodes.

private static void startLocalNodes(SchedulerTestConfiguration configuration) throws KeyException, LoginException, InterruptedException {
    if (configuration.hasLocalNodes()) {
        // Waiting while all the nodes will be registered in the RM.
        // Without waiting test can finish earlier than nodes are added.
        // It leads to test execution hang up on windows due to running processes.
        Credentials creds = Credentials.createCredentials(new CredData(CredData.parseLogin(TestUsers.DEMO.username), CredData.parseDomain(TestUsers.DEMO.username), TestUsers.DEMO.password), rmAuth.getPublicKey());
        ResourceManager rm = rmAuth.login(creds);
        while (rm.getState().getTotalAliveNodesNumber() < SchedulerStartForFunctionalTest.RM_NODE_NUMBER) {
            Thread.sleep(50);
        }
        PAFuture.waitFor(rm.disconnect());
        System.out.println("Nodes are deployed");
    }
}
Also used : CredData(org.ow2.proactive.authentication.crypto.CredData) ResourceManager(org.ow2.proactive.resourcemanager.frontend.ResourceManager) Credentials(org.ow2.proactive.authentication.crypto.Credentials)

Example 54 with CredData

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

the class AuthenticationTest method loginAsAdminIncorrectPassword.

private void loginAsAdminIncorrectPassword(SchedulerAuthenticationInterface auth, PublicKey pubKey) {
    // negative
    log("Test 3");
    log("Trying to authorized as an admin with incorrect user name and password");
    try {
        Credentials cred = Credentials.createCredentials(new CredData(TestUsers.DEMO.username, "b"), pubKey);
        auth.login(cred);
        fail("Error: successful authentication");
    } catch (Exception e) {
        log("Passed: expected error " + e.getMessage());
    }
}
Also used : CredData(org.ow2.proactive.authentication.crypto.CredData) Credentials(org.ow2.proactive.authentication.crypto.Credentials) LoginException(javax.security.auth.login.LoginException) KeyException(java.security.KeyException) PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) AlreadyConnectedException(org.ow2.proactive.scheduler.common.exception.AlreadyConnectedException)

Example 55 with CredData

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

the class AuthenticationTest method loginAsUser.

private void loginAsUser(SchedulerAuthenticationInterface auth, PublicKey pubKey) throws KeyException, LoginException, AlreadyConnectedException, NotConnectedException, PermissionException {
    log("Test 2");
    log("Trying to authorized as a user with correct user name and password");
    Credentials cred = Credentials.createCredentials(new CredData(TestUsers.USER.username, TestUsers.USER.password), pubKey);
    Scheduler user = auth.login(cred);
    String userName = user.getCurrentUser();
    Assert.assertEquals(TestUsers.USER.username, userName);
    UserData userData = user.getCurrentUserData();
    Assert.assertNotNull(userData);
    Assert.assertNotNull(userData.getUserName());
    Assert.assertNotNull(userData.getGroups());
    Assert.assertTrue(userData.getGroups().contains("user"));
    user.disconnect();
    log("Passed: successful authentication");
}
Also used : UserData(org.ow2.proactive.authentication.UserData) Scheduler(org.ow2.proactive.scheduler.common.Scheduler) CredData(org.ow2.proactive.authentication.crypto.CredData) Credentials(org.ow2.proactive.authentication.crypto.Credentials)

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