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);
}
}
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);
}
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));
}
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;
}
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;
}
Aggregations