use of org.ow2.proactive.scheduler.common.exception.ConnectionException in project scheduling by ow2-proactive.
the class CredentialsCreator method createCredentials.
private byte[] createCredentials(String username, String password) throws ConnectionException, LoginException, KeyException {
String url = PortalConfiguration.SCHEDULER_URL.getValueAsString();
SchedulerAuthenticationInterface auth = SchedulerConnection.join(url);
PublicKey pubKey = auth.getPublicKey();
byte[] privateKey = auth.getPrivateKey();
Credentials cred = Credentials.createCredentials(new CredData(CredData.parseLogin(username), CredData.parseDomain(username), password, privateKey), pubKey);
byte[] credentialBytes = cred.getBase64();
return credentialBytes;
}
use of org.ow2.proactive.scheduler.common.exception.ConnectionException 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.scheduler.common.exception.ConnectionException in project scheduling by ow2-proactive.
the class SchedulerAwarePolicy method waitAndConnectToScheduler.
private void waitAndConnectToScheduler() throws Exception {
SchedulerAuthenticationInterface authentication;
boolean firstException = true;
int trialsNumber = 0;
while (scheduler == null && trialsNumber <= schedulerAwarePolicyNodeSourceRecoveryTrialsNumber) {
trialsNumber++;
try {
authentication = SchedulerConnection.join(schedulerUrl);
Credentials creds = Credentials.getCredentialsBase64(credentials);
scheduler = authentication.login(creds);
Thread.sleep(schedulerAwarePolicyNodeSourceRecoveryDelay);
} catch (Throwable t) {
if (firstException) {
logger.warn("Could not contact scheduler at url " + schedulerUrl + " this is normal if the scheduler has just been restarted", t);
firstException = false;
} else {
logger.debug("Could not contact scheduler", t);
}
}
if (trialsNumber > schedulerAwarePolicyNodeSourceRecoveryTrialsNumber)
throw new ConnectionException("Number of trials exceeded and could not contact scheduler");
}
}
Aggregations