use of org.apache.airavata.gfac.core.GFacException in project airavata by apache.
the class GfacServerHandler method submitProcess.
/**
* * After creating the experiment Data and Task Data in the orchestrator
* * Orchestrator has to invoke this operation for each Task per experiment to run
* * the actual Job related actions.
* *
* * @param experimentID
* * @param taskID
* * @param gatewayId:
* * The GatewayId is inferred from security context and passed onto gfac.
* * @return sucess/failure
* *
* *
*
* @param processId - processModel id in registry
* @param gatewayId - gateway Identification
*/
public boolean submitProcess(String processId, String gatewayId, String tokenId) throws TException {
MDC.put(MDCConstants.PROCESS_ID, processId);
MDC.put(MDCConstants.GATEWAY_ID, gatewayId);
MDC.put(MDCConstants.TOKEN_ID, tokenId);
try {
executorService.execute(MDCUtil.wrapWithMDC(new GFacWorker(processId, gatewayId, tokenId)));
} catch (GFacException e) {
log.error("Failed to submit process", e);
throw new TException("Failed to submit process", e);
} catch (CredentialStoreException e) {
log.error("Failed to submit process due to credential issue, " + "make sure you are passing a valid credentials");
throw new TException("Failed to submit process due to credential issue, " + "make sure you are passing a valid credential token", e);
} catch (Exception e) {
log.error("Error creating zookeeper nodes", e);
throw new TException("Error creating zookeeper nodes", e);
}
return true;
}
use of org.apache.airavata.gfac.core.GFacException in project airavata by apache.
the class DataTransferrer method uploadLocalFiles.
public void uploadLocalFiles() throws GFacException {
List<String> inFilePrms = new ArrayList<>();
// FIXME - remove hard coded file path.
inFilePrms.addAll(extractInFileParams());
// inFilePrms.add("file://home/airavata/test/hpcinput-localhost-uslims3_cauma3d-00950.tar");
for (String uri : inFilePrms) {
String fileName = new File(uri).getName();
if (uri.startsWith("file")) {
try {
String uriWithoutProtocol = uri.substring(uri.lastIndexOf("://") + 2, uri.length());
FileUploader fileUploader = new FileUploader(uriWithoutProtocol, fileName, Mode.overwrite, false);
log.info("Uploading file {}", fileName);
fileUploader.perform(storageClient);
} catch (FileNotFoundException e3) {
throw new GFacException("Error while staging-in, local file " + fileName + " not found", e3);
} catch (Exception e) {
throw new GFacException("Cannot upload files", e);
}
}
}
}
use of org.apache.airavata.gfac.core.GFacException in project airavata by apache.
the class DataTransferrer method downloadStdOuts.
public void downloadStdOuts() throws GFacException {
String stdoutFileName = new File(stdoutLocation).getName();
String stderrFileName = new File(stderrLocation).getName();
FileDownloader f1 = null;
log.info("Downloading stdout and stderr..");
log.info(stdoutFileName + " -> " + stdoutLocation);
f1 = new FileDownloader(stdoutFileName, stdoutLocation, Mode.overwrite);
try {
f1.perform(storageClient);
// String stdoutput = readFile(stdoutLocation);
} catch (Exception e) {
log.error("Error while downloading " + stdoutFileName + " to location " + stdoutLocation, e);
}
log.info(stderrFileName + " -> " + stderrLocation);
f1.setFrom(stderrFileName);
f1.setTo(stderrLocation);
try {
f1.perform(storageClient);
// String stderror = readFile(stderrLocation);
} catch (Exception e) {
log.error("Error while downloading " + stderrFileName + " to location " + stderrLocation);
}
String scriptExitCodeFName = "UNICORE_SCRIPT_EXIT_CODE";
String scriptCodeLocation = gatewayDownloadLocation + File.separator + scriptExitCodeFName;
if (UASDataStagingProcessor.isUnicoreEndpoint(processContext)) {
f1.setFrom(scriptExitCodeFName);
f1.setTo(scriptCodeLocation);
try {
f1.perform(storageClient);
OutputDataObjectType output = new OutputDataObjectType();
output.setName(scriptExitCodeFName);
output.setValue(scriptCodeLocation);
output.setType(DataType.URI);
output.setIsRequired(true);
processContext.getProcessModel().getProcessOutputs().add(output);
log.info("UNICORE_SCRIPT_EXIT_CODE -> " + scriptCodeLocation);
log.info("EXIT CODE: " + readFile(scriptCodeLocation));
} catch (Exception e) {
log.error("Error downloading file " + scriptExitCodeFName + " to location " + scriptCodeLocation, e);
}
}
}
use of org.apache.airavata.gfac.core.GFacException in project airavata by apache.
the class UNICORESecurityContext method getDefaultConfiguration.
public DefaultClientConfiguration getDefaultConfiguration(Boolean enableMessageLogging, UserConfigurationDataModel userDataModel) throws GFacException, ApplicationSettingsException {
X509Credential cred = null;
try {
boolean genCert = userDataModel.isGenerateCert();
if (genCert) {
String userDN = userDataModel.getUserDN();
if (userDN == null || "".equals(userDN)) {
log.warn("Cannot generate cert, falling back to GFAC configured MyProxy credentials");
return getDefaultConfiguration(enableMessageLogging);
} else {
log.info("Generating X.509 certificate for: " + userDN);
try {
String caCertPath = ServerSettings.getSetting(BESConstants.PROP_CA_CERT_PATH, "");
String caKeyPath = ServerSettings.getSetting(BESConstants.PROP_CA_KEY_PATH, "");
String caKeyPass = ServerSettings.getSetting(BESConstants.PROP_CA_KEY_PASS, "");
if (caCertPath.equals("") || caKeyPath.equals("")) {
throw new Exception("CA certificate or key file path missing in the properties file. " + "Please make sure " + BESConstants.PROP_CA_CERT_PATH + " or " + BESConstants.PROP_CA_KEY_PATH + " are not empty.");
}
if ("".equals(caKeyPass)) {
log.warn("Caution: CA key has no password. For security reasons it is highly recommended to set a CA key password");
}
cred = generateShortLivedCredential(userDN, caCertPath, caKeyPath, caKeyPass);
} catch (Exception e) {
throw new GFacException("Error occured while generating a short lived credential for user:" + userDN, e);
}
}
} else {
return getDefaultConfiguration(enableMessageLogging);
}
secProperties = new DefaultClientConfiguration(dcValidator, cred);
setExtraSettings();
} catch (Exception e) {
throw new GFacException(e.getMessage(), e);
}
secProperties.getETDSettings().setExtendTrustDelegation(true);
if (enableMessageLogging)
secProperties.setMessageLogging(true);
// secProperties.setDoSignMessage(true);
secProperties.getETDSettings().setIssuerCertificateChain(secProperties.getCredential().getCertificateChain());
return secProperties;
}
use of org.apache.airavata.gfac.core.GFacException in project airavata by apache.
the class X509SecurityContext method getX509Credentials.
/**
* Gets X509Credentials. The process is as follows;
* If credentials were queried for the first time create credentials.
* 1. Try creating credentials using certificates stored in the credential store
* 2. If 1 fails use user name and password to create credentials
* @return x509credentials (from CANL security API)
* @throws org.apache.airavata.common.exception.ApplicationSettingsException
*/
public X509Credential getX509Credentials() throws GFacException, ApplicationSettingsException {
if (getCredentialReader() == null) {
return getDefaultCredentials();
}
if (x509Credentials == null) {
try {
x509Credentials = getCredentialsFromStore();
} catch (Exception e) {
log.error("An exception occurred while retrieving credentials from the credential store. " + "Will continue with my proxy user name and password.", e);
}
// If store does not have credentials try to get from user name and password
if (x509Credentials == null) {
x509Credentials = getDefaultCredentials();
}
// if still null, throw an exception
if (x509Credentials == null) {
throw new GFacException("Unable to retrieve my proxy credentials to continue operation.");
}
} else {
try {
final long remainingTime = x509Credentials.getCertificate().getNotAfter().getTime() - new Date().getTime();
if (remainingTime < CREDENTIAL_RENEWING_THRESH_HOLD) {
// return renewCredentials();
log.warn("Do not support credentials renewal");
}
log.info("Fall back to get new default credentials");
try {
x509Credentials.getCertificate().checkValidity();
} catch (Exception e) {
x509Credentials = getDefaultCredentials();
}
} catch (Exception e) {
throw new GFacException("Unable to retrieve remaining life time from credentials.", e);
}
}
return x509Credentials;
}
Aggregations