Search in sources :

Example 1 with RequestData

use of org.apache.airavata.gfac.core.RequestData in project airavata by apache.

the class SecurityUtils method getSecurityContext.

public static UNICORESecurityContext getSecurityContext(ProcessContext processContext) throws GFacException {
    if (processContext.getJobSubmissionProtocol().equals(JobSubmissionProtocol.UNICORE)) {
        // set by the framework
        String credentialStoreToken = processContext.getTokenId();
        RequestData requestData;
        requestData = new RequestData(processContext.getProcessModel().getUserDn());
        requestData.setTokenId(credentialStoreToken);
        CredentialReader credentialReader = null;
        try {
            credentialReader = GFacUtils.getCredentialReader();
            if (credentialReader == null) {
                throw new GFacException("Credential reader returns null");
            }
        } catch (Exception e) {
            throw new GFacException("Error while initializing credential reader");
        }
        return new UNICORESecurityContext(credentialReader, requestData);
    } else {
        throw new GFacException("Only support UNICORE job submissions, invalid job submission protocol " + processContext.getJobSubmissionProtocol().name());
    }
}
Also used : GFacException(org.apache.airavata.gfac.core.GFacException) RequestData(org.apache.airavata.gfac.core.RequestData) CredentialReader(org.apache.airavata.credential.store.store.CredentialReader) GFacException(org.apache.airavata.gfac.core.GFacException) IOException(java.io.IOException) InvalidKeyException(java.security.InvalidKeyException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException)

Example 2 with RequestData

use of org.apache.airavata.gfac.core.RequestData in project airavata by apache.

the class SecurityUtils method addSecurityContext.

public static void addSecurityContext(ProcessContext processContext) throws GFacException {
    if (!processContext.getJobSubmissionProtocol().equals(JobSubmissionProtocol.UNICORE)) {
        logger.error("This is a wrong method to invoke for UNICORE host types,please check your gfac-config.xml");
    } else {
        // set by the framework
        String credentialStoreToken = processContext.getTokenId();
        RequestData requestData;
        try {
            requestData = new RequestData(ServerSettings.getDefaultUserGateway());
        } catch (ApplicationSettingsException e1) {
            throw new GFacException(e1);
        }
        // coming from top tier
        requestData.setTokenId(credentialStoreToken);
        CredentialReader credentialReader = null;
        try {
            credentialReader = GFacUtils.getCredentialReader();
        } catch (Exception e) {
            logger.warn("Cannot get credential reader instance");
        }
        UNICORESecurityContext secCtx = new UNICORESecurityContext(credentialReader, requestData);
    // processContext.addSecurityContext(X509SecurityContext.X509_SECURITY_CONTEXT, secCtx);
    }
}
Also used : ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) GFacException(org.apache.airavata.gfac.core.GFacException) UNICORESecurityContext(org.apache.airavata.gfac.bes.security.UNICORESecurityContext) RequestData(org.apache.airavata.gfac.core.RequestData) CredentialReader(org.apache.airavata.credential.store.store.CredentialReader) GFacException(org.apache.airavata.gfac.core.GFacException) IOException(java.io.IOException) InvalidKeyException(java.security.InvalidKeyException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException)

Aggregations

IOException (java.io.IOException)2 InvalidKeyException (java.security.InvalidKeyException)2 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)2 CredentialReader (org.apache.airavata.credential.store.store.CredentialReader)2 GFacException (org.apache.airavata.gfac.core.GFacException)2 RequestData (org.apache.airavata.gfac.core.RequestData)2 UNICORESecurityContext (org.apache.airavata.gfac.bes.security.UNICORESecurityContext)1