use of org.ow2.proactive.authentication.crypto.CredData in project scheduling by ow2-proactive.
the class SchedulerAuthenticationGUIHelper method login.
/**
* This method will log a client to the scheduler by requesting his URL, username and password from a
* graphical interface.
*
* @param schedulerURL The default URL of the scheduler to connect
* @return The connection to the scheduler as a {@link Scheduler} if logging successful.
* If the username is empty or if the user cancel the authentication, this method will return null.
* @throws LoginException If a problem occurs while logging the user.
* @throws SchedulerException If a problem occurs at scheduler level.
*/
public static Scheduler login(String schedulerURL) throws LoginException, SchedulerException {
AuthResultContainer auth = connect(schedulerURL);
if (auth == null) {
return null;
} else {
SchedulerAuthenticationInterface schedAuth = auth.getAuth();
Credentials cred = null;
try {
cred = Credentials.createCredentials(new CredData(CredData.parseLogin(auth.getUsername()), CredData.parseDomain(auth.getUsername()), auth.getPassword()), schedAuth.getPublicKey());
} catch (LoginException e) {
throw new LoginException("Could not retrieve public key from Scheduler " + schedulerURL + ", contact the administrator" + e);
} catch (KeyException e) {
throw new LoginException("Could not encrypt credentials " + e);
}
return schedAuth.login(cred);
}
}
use of org.ow2.proactive.authentication.crypto.CredData in project scheduling by ow2-proactive.
the class ForkedTaskVariablesManagerTest method createCredentials.
private Decrypter createCredentials(String username, String password) throws NoSuchAlgorithmException, KeyException {
Map<String, String> thirdPartyCreds = new HashMap<>();
thirdPartyCreds.put(thirdPartyCred1Key, thirdPartyCred1Value);
CredData credData = new CredData(username, password, thirdPartyCreds);
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 ForkedTaskExecutorRunAsMeTest method createCredentials.
private Decrypter createCredentials(String username, String password) throws NoSuchAlgorithmException, KeyException {
CredData credData = new CredData(username, password);
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 SchedulerStateRest method getCreateCredential.
/**
* generates a credential file from user provided credentials
*
* @return the credential file generated by the scheduler
* @throws LoginException
* @throws SchedulerRestException
*/
@Override
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Path("createcredential")
@Produces("*/*")
public byte[] getCreateCredential(@MultipartForm LoginForm multipart) throws LoginException, SchedulerRestException {
String username = multipart.getUsername();
String password = multipart.getPassword();
byte[] privKey = multipart.getSshKey();
try {
String url = PortalConfiguration.SCHEDULER_URL.getValueAsString();
SchedulerAuthenticationInterface auth = SchedulerConnection.join(url);
PublicKey pubKey = auth.getPublicKey();
sessionStore.create(username);
Credentials cred = Credentials.createCredentials(new CredData(CredData.parseLogin(username), CredData.parseDomain(username), password, privKey), pubKey);
return cred.getBase64();
} catch (ConnectionException | KeyException e) {
throw new SchedulerRestException(e);
}
}
use of org.ow2.proactive.authentication.crypto.CredData in project scheduling by ow2-proactive.
the class SharedSessionStoreTestUtils method createValidSession.
public static String createValidSession(SchedulerProxyUserInterface scheduler) throws LoginException, ActiveObjectCreationException, SchedulerException, NodeException {
SchedulerRMProxyFactory schedulerFactory = mock(SchedulerRMProxyFactory.class);
when(schedulerFactory.connectToScheduler(Matchers.<CredData>any())).thenReturn(scheduler);
SharedSessionStore.getInstance().setSchedulerRMProxyFactory(schedulerFactory);
// login
Session session = SharedSessionStore.getInstance().createUnnamedSession();
session.connectToScheduler(new CredData());
return session.getSessionId();
}
Aggregations