Search in sources :

Example 16 with CredData

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

the class SchedulerProxyUserInterface method init.

/**
 * initialize the connection the scheduler.
 * Must be called only once.
 * Create the corresponding credential object before sending it
 * to the scheduler.
 * @param url the scheduler's url
 * @param credData the credential object that contains user-related data
 * @throws SchedulerException thrown if the scheduler is not available
 * @throws LoginException if the couple username/password is invalid
 * @since Scheduling 3.1.0
 */
public void init(String url, CredData credData) throws SchedulerException, LoginException {
    SchedulerAuthenticationInterface auth = SchedulerConnection.join(url);
    PublicKey pubKey = auth.getPublicKey();
    try {
        Credentials cred = Credentials.createCredentials(credData, pubKey);
        this.uischeduler = auth.login(cred);
        mbeaninfoviewer = new MBeanInfoViewer(auth, credData.getLogin(), cred);
    } catch (KeyException e) {
        throw new InternalSchedulerException(e);
    }
}
Also used : InternalSchedulerException(org.ow2.proactive.scheduler.common.exception.InternalSchedulerException) MBeanInfoViewer(org.ow2.proactive.utils.console.MBeanInfoViewer) PublicKey(java.security.PublicKey) SchedulerAuthenticationInterface(org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface) Credentials(org.ow2.proactive.authentication.crypto.Credentials) KeyException(java.security.KeyException)

Example 17 with CredData

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

the class SchedulerProxyUserInterface method init.

/**
 * initialize the connection the scheduler.
 * Must be called only once.
 * Create the corresponding credential object before sending it
 * to the scheduler.
 * @param url the scheduler's url
 * @param user the username to use
 * @param pwd the password to use
 * @throws SchedulerException thrown if the scheduler is not available
 * @throws LoginException if the couple username/password is invalid
 */
public void init(String url, String user, String pwd) throws SchedulerException, LoginException {
    CredData cred = new CredData(CredData.parseLogin(user), CredData.parseDomain(user), pwd);
    init(url, cred);
}
Also used : CredData(org.ow2.proactive.authentication.crypto.CredData)

Example 18 with CredData

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

the class TaskLauncherTest method thirdPartyCredentials.

@Test
public void thirdPartyCredentials() throws Throwable {
    ScriptExecutableContainer executableContainer = new ScriptExecutableContainer(new TaskScript(new SimpleScript("print(credentials.get('password'))", "groovy")));
    TaskLauncherInitializer initializer = new TaskLauncherInitializer();
    initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));
    createLauncherWithInjectedMocks(initializer, new TestTaskLauncherFactory());
    CredData credData = new CredData("john", "pwd");
    credData.addThirdPartyCredential("password", "r00t");
    final KeyPairProducer keyPairProducer = new KeyPairProducer();
    final TaskLauncher spy = spy(taskLauncher);
    doReturn(keyPairProducer.getKeyPair()).when(spy).getKeyPair();
    Credentials thirdPartyCredentials = Credentials.createCredentials(credData, spy.generatePublicKey());
    executableContainer.setCredentials(thirdPartyCredentials);
    TaskResult taskResult = runTaskLauncher(spy, executableContainer);
    final String allLogs = taskResult.getOutput().getAllLogs(false);
    assertThat(allLogs.contains(String.format("r00t%n")), is(true));
}
Also used : TaskScript(org.ow2.proactive.scripting.TaskScript) SimpleScript(org.ow2.proactive.scripting.SimpleScript) CredData(org.ow2.proactive.authentication.crypto.CredData) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) KeyPairProducer(org.ow2.proactive.resourcemanager.utils.KeyPairProducer) Credentials(org.ow2.proactive.authentication.crypto.Credentials) Test(org.junit.Test)

Example 19 with CredData

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

the class ForkedTaskExecutorTest method createCredentials.

private Decrypter createCredentials(String username) throws NoSuchAlgorithmException, KeyException {
    CredData credData = new CredData(username, "pwd");
    KeyPairGenerator keyGen;
    keyGen = KeyPairGenerator.getInstance("RSA");
    keyGen.initialize(512, new SecureRandom());
    KeyPair keyPair = keyGen.generateKeyPair();
    Decrypter decrypter = new Decrypter(keyPair.getPrivate());
    Credentials credentials = Credentials.createCredentials(credData, keyPair.getPublic());
    decrypter.setCredentials(credentials);
    return decrypter;
}
Also used : KeyPair(java.security.KeyPair) CredData(org.ow2.proactive.authentication.crypto.CredData) SecureRandom(java.security.SecureRandom) Decrypter(org.ow2.proactive.scheduler.task.utils.Decrypter) KeyPairGenerator(java.security.KeyPairGenerator) Credentials(org.ow2.proactive.authentication.crypto.Credentials)

Example 20 with CredData

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

the class InProcessTaskExecutorTest method createCredentials.

private Decrypter createCredentials(String username) throws NoSuchAlgorithmException, KeyException {
    CredData credData = new CredData(username, "pwd");
    credData.addThirdPartyCredential("PASSWORD", "p4ssw0rd");
    KeyPairGenerator keyGen;
    keyGen = KeyPairGenerator.getInstance("RSA");
    keyGen.initialize(512, new SecureRandom());
    KeyPair keyPair = keyGen.generateKeyPair();
    Decrypter decrypter = new Decrypter(keyPair.getPrivate());
    Credentials credentials = Credentials.createCredentials(credData, keyPair.getPublic());
    decrypter.setCredentials(credentials);
    return decrypter;
}
Also used : KeyPair(java.security.KeyPair) CredData(org.ow2.proactive.authentication.crypto.CredData) SecureRandom(java.security.SecureRandom) Decrypter(org.ow2.proactive.scheduler.task.utils.Decrypter) KeyPairGenerator(java.security.KeyPairGenerator) 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