use of org.ow2.proactive.authentication.crypto.Credentials in project scheduling by ow2-proactive.
the class SchedulingService method addThirdPartyCredentials.
/**
* Create a new Credential object containing users' 3rd Party Credentials.
*
* @param creds credentials for specific user
* @return in case of success new object containing the 3rd party credentials used to create bindings
* at clean script
*/
Credentials addThirdPartyCredentials(Credentials creds) throws KeyException, IllegalAccessException {
// retrieve scheduler key pair
String privateKeyPath = PASchedulerProperties.getAbsolutePath(PASchedulerProperties.SCHEDULER_AUTH_PRIVKEY_PATH.getValueAsString());
String publicKeyPath = PASchedulerProperties.getAbsolutePath(PASchedulerProperties.SCHEDULER_AUTH_PUBKEY_PATH.getValueAsString());
// get keys from task
PrivateKey privateKey = Credentials.getPrivateKey(privateKeyPath);
PublicKey publicKey = Credentials.getPublicKey(publicKeyPath);
// retrieve the current creData from task
CredData credData = creds.decrypt(privateKey);
// retrive database to get third party credentials from
SchedulerDBManager dbManager = getInfrastructure().getDBManager();
if (dbManager != null) {
Map<String, HybridEncryptedData> thirdPartyCredentials = dbManager.thirdPartyCredentialsMap(credData.getLogin());
if (thirdPartyCredentials == null) {
logger.error("Failed to retrieve Third Party Credentials!");
throw new KeyException("Failed to retrieve thirdPartyCredentials!");
} else {
// cycle third party credentials, add one-by-one to the decrypter
for (Map.Entry<String, HybridEncryptedData> thirdPartyCredential : thirdPartyCredentials.entrySet()) {
String decryptedValue = HybridEncryptionUtil.decryptString(thirdPartyCredential.getValue(), privateKey);
credData.addThirdPartyCredential(thirdPartyCredential.getKey(), decryptedValue);
}
}
}
return Credentials.createCredentials(credData, publicKey);
}
use of org.ow2.proactive.authentication.crypto.Credentials in project scheduling by ow2-proactive.
the class InternalJob method getUserCredentials.
private UserCredentials getUserCredentials() {
UserCredentials userCredentials = null;
try {
CredData decryptedUserCredentials = credentials.decrypt(corePrivateKey);
if (PASchedulerProperties.SCHEDULER_AUTH_GLOBAL_DOMAIN.isSet() && decryptedUserCredentials.getDomain() == null) {
decryptedUserCredentials.setDomain(PASchedulerProperties.SCHEDULER_AUTH_GLOBAL_DOMAIN.getValueAsString());
}
userCredentials = new UserCredentials(decryptedUserCredentials.getLogin(), decryptedUserCredentials.getPassword(), decryptedUserCredentials.getDomain(), decryptedUserCredentials.getKey());
} catch (Exception e) {
LOGGER.error("Could not decrypt user credentials", e);
}
return userCredentials;
}
use of org.ow2.proactive.authentication.crypto.Credentials in project scheduling by ow2-proactive.
the class RMProxyActiveObject method cleanCallBack.
/**
* Called when a script has returned (call is made as an active object call)
* <p>
* Check the nodes to release and release the one that have to (clean script has returned)
* Take care when renaming this method, method name is linked to
* {@link #handleCleaningScript(NodeSet, Script, VariablesMap, Map, TaskId, Credentials, Synchronization, SignalApi)}
*/
@ImmediateService
public synchronized void cleanCallBack(Future<ScriptResult<?>> future, NodeSet nodes) {
String nodeUrl = nodes.get(0).getNodeInformation().getURL();
ScriptResult<?> sResult = null;
TaskId taskId = nodesTaskId.get(nodes);
try {
sResult = future.get();
} catch (Exception e) {
logger.error("Exception occurred while executing cleaning script on node " + nodeUrl + ":", e);
}
printCleaningScriptInformations(nodes, sResult, taskId);
closeTaskLogger(taskId);
releaseNodes(nodes);
}
use of org.ow2.proactive.authentication.crypto.Credentials 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.Credentials 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;
}
Aggregations