Search in sources :

Example 21 with AuthzToken

use of org.apache.airavata.model.security.AuthzToken in project airavata by apache.

the class AuthResponse method main.

public static void main(String[] args) throws AuthenticationException, AiravataSecurityException, AxisFault {
    String accessToken = authenticate("master@master.airavata", "master").getAccess_token();
    ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
    DefaultOAuthClient defaultOAuthClient = new DefaultOAuthClient(hostName + "/services/", username, password, configContext);
    OAuth2TokenValidationResponseDTO tokenValidationRequestDTO = defaultOAuthClient.validateAccessToken(accessToken);
    String authorizedUser = tokenValidationRequestDTO.getAuthorizedUser();
    AuthzToken authzToken = new AuthzToken();
    authzToken.setAccessToken(accessToken);
    Map<String, String> claimsMap = new HashMap<>();
    claimsMap.put(Constants.USER_NAME, "scigap_admin");
    claimsMap.put(Constants.API_METHOD_NAME, "/airavata/getAPIVersion");
    authzToken.setClaimsMap(claimsMap);
    DefaultXACMLPEP defaultXACMLPEP = new DefaultXACMLPEP(hostName + "/services/", username, password, configContext);
    HashMap<String, String> metaDataMap = new HashMap();
    boolean result = defaultXACMLPEP.getAuthorizationDecision(authzToken, metaDataMap);
    System.out.println(result);
}
Also used : DefaultOAuthClient(org.apache.airavata.service.security.oauth.DefaultOAuthClient) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) DefaultXACMLPEP(org.apache.airavata.service.security.xacml.DefaultXACMLPEP) HashMap(java.util.HashMap) AuthzToken(org.apache.airavata.model.security.AuthzToken) OAuth2TokenValidationResponseDTO(org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationResponseDTO)

Example 22 with AuthzToken

use of org.apache.airavata.model.security.AuthzToken in project airavata by apache.

the class CreateLaunchBES method createMPIExperimentForFSD.

public static String createMPIExperimentForFSD(Airavata.Client client) throws TException {
    try {
        List<InputDataObjectType> exInputs = client.getApplicationInputs(new AuthzToken(""), mpiAppId);
        for (InputDataObjectType inputDataObjectType : exInputs) {
            // }
            if (inputDataObjectType.getName().equalsIgnoreCase("NumberOfProcesses")) {
                inputDataObjectType.setValue("32");
            }
            if (inputDataObjectType.getName().equalsIgnoreCase("US3INPUT")) {
                inputDataObjectType.setValue("file://home/m.memon/us3input/smallerdata/hpcinput-uslims3.uthscsa.edu-uslims3_cauma3-01594.tar");
            }
            if (inputDataObjectType.getName().equalsIgnoreCase("US3INPUTARG")) {
                inputDataObjectType.setValue("hpcinput-uslims3.uthscsa.edu-uslims3_cauma3-01594.tar");
            }
        }
        List<OutputDataObjectType> exOut = client.getApplicationOutputs(new AuthzToken(""), mpiAppId);
        for (OutputDataObjectType outputDataObjectType : exOut) {
            if (outputDataObjectType.getName().equals("US3OUT")) {
                outputDataObjectType.setValue("output/analysis-results.tar");
            }
        }
        ExperimentModel simpleExperiment = ExperimentModelUtil.createSimpleExperiment(DEFAULT_GATEWAY, "default", "admin", "mpiExperiment", "HelloMPI", mpiAppId, exInputs);
        simpleExperiment.setExperimentOutputs(exOut);
        Map<String, String> computeResources = airavataClient.getAvailableAppInterfaceComputeResources(new AuthzToken(""), mpiAppId);
        if (computeResources != null && computeResources.size() != 0) {
            for (String id : computeResources.keySet()) {
                String resourceName = computeResources.get(id);
                if (resourceName.equals(unicoreHostName)) {
                    ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling(id, 0, 4, 0, null, 10, 0);
                    UserConfigurationDataModel userConfigurationData = new UserConfigurationDataModel();
                    userConfigurationData.setAiravataAutoSchedule(false);
                    userConfigurationData.setOverrideManualScheduledParams(false);
                    userConfigurationData.setComputationalResourceScheduling(scheduling);
                    userConfigurationData.setGenerateCert(true);
                    userConfigurationData.setUserDN("CN=m.memon, O=Ultrascan Gateway, C=DE");
                    simpleExperiment.setUserConfigurationData(userConfigurationData);
                    return client.createExperiment(new AuthzToken(""), DEFAULT_GATEWAY, simpleExperiment);
                }
            }
        }
    } catch (AiravataSystemException e) {
        logger.error("Error occured while creating the experiment...", e.getMessage());
        throw new AiravataSystemException(e);
    } catch (InvalidRequestException e) {
        logger.error("Error occured while creating the experiment...", e.getMessage());
        throw new InvalidRequestException(e);
    } catch (AiravataClientException e) {
        logger.error("Error occured while creating the experiment...", e.getMessage());
        throw new AiravataClientException(e);
    } catch (TException e) {
        logger.error("Error occured while creating the experiment...", e.getMessage());
        throw new TException(e);
    }
    return null;
}
Also used : TException(org.apache.thrift.TException) InputDataObjectType(org.apache.airavata.model.application.io.InputDataObjectType) ExperimentModel(org.apache.airavata.model.experiment.ExperimentModel) OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType) UserConfigurationDataModel(org.apache.airavata.model.experiment.UserConfigurationDataModel) AuthzToken(org.apache.airavata.model.security.AuthzToken) ComputationalResourceSchedulingModel(org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel)

Example 23 with AuthzToken

use of org.apache.airavata.model.security.AuthzToken in project airavata by apache.

the class CreateLaunchBES method getExperiment.

public static void getExperiment(Airavata.Client client, String expId) throws Exception {
    try {
        ExperimentModel experiment = client.getExperiment(new AuthzToken(""), expId);
        List<ErrorModel> errors = experiment.getErrors();
        if (errors != null && !errors.isEmpty()) {
            for (ErrorModel error : errors) {
                System.out.println("ERROR MESSAGE : " + error.getActualErrorMessage());
            }
        }
    } catch (ExperimentNotFoundException e) {
        logger.error("Experiment does not exist", e);
        throw new ExperimentNotFoundException("Experiment does not exist");
    } catch (AiravataSystemException e) {
        logger.error("Error while retrieving experiment", e);
        throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
    } catch (InvalidRequestException e) {
        logger.error("Error while retrieving experiment", e);
        throw new InvalidRequestException("Error while retrieving experiment");
    } catch (AiravataClientException e) {
        logger.error("Error while retrieving experiment", e);
        throw new AiravataClientException(AiravataErrorType.INTERNAL_ERROR);
    }
}
Also used : ExperimentModel(org.apache.airavata.model.experiment.ExperimentModel) AuthzToken(org.apache.airavata.model.security.AuthzToken) ErrorModel(org.apache.airavata.model.commons.ErrorModel)

Example 24 with AuthzToken

use of org.apache.airavata.model.security.AuthzToken in project airavata by apache.

the class CreateLaunchBES method getAvailableAppInterfaceComputeResources.

public static void getAvailableAppInterfaceComputeResources(String appInterfaceId) {
    try {
        Map<String, String> availableAppInterfaceComputeResources = airavataClient.getAvailableAppInterfaceComputeResources(new AuthzToken(""), appInterfaceId);
        for (String key : availableAppInterfaceComputeResources.keySet()) {
            System.out.println("id : " + key);
            System.out.println("name : " + availableAppInterfaceComputeResources.get(key));
        }
    } catch (AiravataSystemException e) {
        e.printStackTrace();
    } catch (InvalidRequestException e) {
        e.printStackTrace();
    } catch (AiravataClientException e) {
        e.printStackTrace();
    } catch (TException e) {
        e.printStackTrace();
    }
}
Also used : TException(org.apache.thrift.TException) AuthzToken(org.apache.airavata.model.security.AuthzToken)

Example 25 with AuthzToken

use of org.apache.airavata.model.security.AuthzToken in project airavata by apache.

the class CreateLaunchBES method registerUnicoreEndpoint.

public static String registerUnicoreEndpoint(String hostName, String hostDesc, JobSubmissionProtocol protocol, SecurityProtocol securityProtocol) throws TException {
    ComputeResourceDescription computeResourceDescription = RegisterSampleApplicationsUtils.createComputeResourceDescription(hostName, hostDesc, null, null);
    fsdResourceId = airavataClient.registerComputeResource(new AuthzToken(""), computeResourceDescription);
    if (fsdResourceId.isEmpty())
        throw new AiravataClientException();
    System.out.println("FSD Compute ResourceID: " + fsdResourceId);
    JobSubmissionInterface jobSubmission = RegisterSampleApplicationsUtils.createJobSubmissionInterface(fsdResourceId, protocol, 2);
    UnicoreJobSubmission ucrJobSubmission = new UnicoreJobSubmission();
    ucrJobSubmission.setSecurityProtocol(securityProtocol);
    ucrJobSubmission.setUnicoreEndPointURL(unicoreEndPointURL);
    return jobSubmission.getJobSubmissionInterfaceId();
}
Also used : UnicoreJobSubmission(org.apache.airavata.model.appcatalog.computeresource.UnicoreJobSubmission) JobSubmissionInterface(org.apache.airavata.model.appcatalog.computeresource.JobSubmissionInterface) ComputeResourceDescription(org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription) AuthzToken(org.apache.airavata.model.security.AuthzToken)

Aggregations

AuthzToken (org.apache.airavata.model.security.AuthzToken)92 TException (org.apache.thrift.TException)71 InputDataObjectType (org.apache.airavata.model.application.io.InputDataObjectType)46 OutputDataObjectType (org.apache.airavata.model.application.io.OutputDataObjectType)44 ExperimentModel (org.apache.airavata.model.experiment.ExperimentModel)33 UserConfigurationDataModel (org.apache.airavata.model.experiment.UserConfigurationDataModel)28 ComputationalResourceSchedulingModel (org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel)28 AiravataClientException (org.apache.airavata.model.error.AiravataClientException)15 Project (org.apache.airavata.model.workspace.Project)13 ArrayList (java.util.ArrayList)12 InvalidRequestException (org.apache.airavata.model.error.InvalidRequestException)8 HashMap (java.util.HashMap)7 AiravataSystemException (org.apache.airavata.model.error.AiravataSystemException)7 Gateway (org.apache.airavata.model.workspace.Gateway)6 CommandObject (org.apache.airavata.model.appcatalog.appdeployment.CommandObject)5 SCPDataMovement (org.apache.airavata.model.data.movement.SCPDataMovement)5 ComputeResourcePreference (org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference)4 GatewayResourceProfile (org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile)4 ComputeResourceDescription (org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription)2 JobSubmissionInterface (org.apache.airavata.model.appcatalog.computeresource.JobSubmissionInterface)2