Search in sources :

Example 6 with SchedulerAuthenticationInterface

use of org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface in project scheduling by ow2-proactive.

the class SchedulerStarter method start.

protected static void start(CommandLine commandLine) throws Exception {
    // force properties loading to find out if PAMR router should be started
    ProActiveConfiguration.load();
    if (!commandLine.hasOption(OPTION_NO_ROUTER)) {
        startRouter();
    }
    hsqldbServer = new SchedulerHsqldbStarter();
    hsqldbServer.startIfNeeded();
    rmURL = getRmUrl(commandLine);
    setCleanDatabaseProperties(commandLine);
    setCleanNodesourcesProperty(commandLine);
    rmURL = connectToOrStartResourceManager(commandLine, rmURL);
    if (commandLine.hasOption(OPTION_RM_ONLY)) {
        return;
    }
    schedulerURL = getSchedulerUrl(commandLine);
    if (!commandLine.hasOption(OPTION_SCHEDULER_URL)) {
        SchedulerAuthenticationInterface schedulerAuthenticationInterface = startScheduler(commandLine, rmURL);
        schedulerURL = schedulerAuthenticationInterface.getHostURL();
        schedAuthInter = schedulerAuthenticationInterface;
    }
    if (!commandLine.hasOption(OPTION_NO_REST)) {
        startJetty(rmURL, schedulerURL);
    }
    addShutdownMessageHook();
    executeStartScripts();
}
Also used : SchedulerAuthenticationInterface(org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface)

Example 7 with SchedulerAuthenticationInterface

use of org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface in project scheduling by ow2-proactive.

the class AuthenticationTest method action.

@Test
public void action() throws Exception {
    SchedulerAuthenticationInterface auth = schedulerHelper.getSchedulerAuth();
    PublicKey pubKey = auth.getPublicKey();
    loginAsAdmin(auth, pubKey);
    loginAsUser(auth, pubKey);
    loginAsAdminIncorrectPassword(auth, pubKey);
    loginAsUserIncorrectPassword(auth, pubKey);
}
Also used : PublicKey(java.security.PublicKey) SchedulerAuthenticationInterface(org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface) Test(org.junit.Test)

Example 8 with SchedulerAuthenticationInterface

use of org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface in project scheduling by ow2-proactive.

the class AuthenticationTest method loginAsUserIncorrectPassword.

private void loginAsUserIncorrectPassword(SchedulerAuthenticationInterface auth, PublicKey pubKey) {
    log("Test 4");
    log("Trying to authorized as a user with incorrect user name and password");
    try {
        Credentials cred = Credentials.createCredentials(new CredData(TestUsers.USER.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 9 with SchedulerAuthenticationInterface

use of org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface in project scheduling by ow2-proactive.

the class AuthenticationTest method loginAsAdmin.

private void loginAsAdmin(SchedulerAuthenticationInterface auth, PublicKey pubKey) throws KeyException, LoginException, AlreadyConnectedException, NotConnectedException, PermissionException {
    log("Test 1");
    log("Trying to authorized as an admin with correct user name and password");
    Credentials cred = Credentials.createCredentials(new CredData(TestUsers.DEMO.username, TestUsers.DEMO.password), pubKey);
    Scheduler admin = auth.login(cred);
    String userName = admin.getCurrentUser();
    Assert.assertEquals(TestUsers.DEMO.username, userName);
    UserData userData = admin.getCurrentUserData();
    Assert.assertNotNull(userData);
    Assert.assertNotNull(userData.getUserName());
    Assert.assertNotNull(userData.getGroups());
    Assert.assertTrue(userData.getGroups().contains("admin"));
    admin.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)

Example 10 with SchedulerAuthenticationInterface

use of org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface in project scheduling by ow2-proactive.

the class SmartProxyImpl method init.

private void init(String url, Credentials credentials, CredData credData) throws SchedulerException, LoginException {
    if (this.connectionInfo == null) {
        this.connectionInfo = new ConnectionInfo(url, null, null, null, false);
    }
    this.connectionInfo.setUrl(url);
    this.credentials = credentials;
    this.credData = credData;
    SchedulerAuthenticationInterface auth = SchedulerConnection.join(url);
    PublicKey pubKey = auth.getPublicKey();
    if (this.credentials != null) {
        this.credentials = credentials;
        this.credData = null;
    } else if (this.credData != null) {
        this.credData = credData;
        try {
            this.credentials = Credentials.createCredentials(credData, pubKey);
        } catch (KeyException e) {
            throw new InternalSchedulerException(e);
        }
    } else {
        throw new IllegalStateException("No valid credential available to connect to the scheduler");
    }
    this.schedulerProxy = auth.login(this.credentials);
    jobTracker.loadJobs();
    setInitialized(true);
    registerAsListener();
    syncAwaitedJobs();
}
Also used : InternalSchedulerException(org.ow2.proactive.scheduler.common.exception.InternalSchedulerException) PublicKey(java.security.PublicKey) SchedulerAuthenticationInterface(org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface) ConnectionInfo(org.ow2.proactive.authentication.ConnectionInfo) KeyException(java.security.KeyException)

Aggregations

SchedulerAuthenticationInterface (org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface)22 Credentials (org.ow2.proactive.authentication.crypto.Credentials)15 CredData (org.ow2.proactive.authentication.crypto.CredData)13 KeyException (java.security.KeyException)7 PublicKey (java.security.PublicKey)7 Test (org.junit.Test)6 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)6 LoginException (javax.security.auth.login.LoginException)5 JobId (org.ow2.proactive.scheduler.common.job.JobId)5 InternalSchedulerException (org.ow2.proactive.scheduler.common.exception.InternalSchedulerException)4 HashMap (java.util.HashMap)3 JMXConnector (javax.management.remote.JMXConnector)3 JMXServiceURL (javax.management.remote.JMXServiceURL)3 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)3 MBeanServerConnection (javax.management.MBeanServerConnection)2 ObjectName (javax.management.ObjectName)2 UserData (org.ow2.proactive.authentication.UserData)2 AlreadyConnectedException (org.ow2.proactive.scheduler.common.exception.AlreadyConnectedException)2 ConnectionException (org.ow2.proactive.scheduler.common.exception.ConnectionException)2 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)2