Search in sources :

Example 26 with SecurityCheck

use of org.apache.airavata.service.security.interceptor.SecurityCheck in project airavata by apache.

the class AiravataServerHandler method addGateway.

@Override
@SecurityCheck
public String addGateway(AuthzToken authzToken, Gateway gateway) throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
    SharingRegistryService.Client sharingClient = sharingClientPool.getResource();
    RegistryService.Client registryClient = registryClientPool.getResource();
    try {
        String gatewayId = registryClient.addGateway(gateway);
        Domain domain = new Domain();
        domain.setDomainId(gateway.getGatewayId());
        domain.setName(gateway.getGatewayName());
        domain.setDescription("Domain entry for " + domain.name);
        sharingClient.createDomain(domain);
        // Creating Entity Types for each domain
        EntityType entityType = new EntityType();
        entityType.setEntityTypeId(domain.domainId + ":PROJECT");
        entityType.setDomainId(domain.domainId);
        entityType.setName("PROJECT");
        entityType.setDescription("Project entity type");
        sharingClient.createEntityType(entityType);
        entityType = new EntityType();
        entityType.setEntityTypeId(domain.domainId + ":EXPERIMENT");
        entityType.setDomainId(domain.domainId);
        entityType.setName("EXPERIMENT");
        entityType.setDescription("Experiment entity type");
        sharingClient.createEntityType(entityType);
        entityType = new EntityType();
        entityType.setEntityTypeId(domain.domainId + ":FILE");
        entityType.setDomainId(domain.domainId);
        entityType.setName("FILE");
        entityType.setDescription("File entity type");
        sharingClient.createEntityType(entityType);
        // Creating Permission Types for each domain
        PermissionType permissionType = new PermissionType();
        permissionType.setPermissionTypeId(domain.domainId + ":READ");
        permissionType.setDomainId(domain.domainId);
        permissionType.setName("READ");
        permissionType.setDescription("Read permission type");
        sharingClient.createPermissionType(permissionType);
        permissionType = new PermissionType();
        permissionType.setPermissionTypeId(domain.domainId + ":WRITE");
        permissionType.setDomainId(domain.domainId);
        permissionType.setName("WRITE");
        permissionType.setDescription("Write permission type");
        sharingClient.createPermissionType(permissionType);
        registryClientPool.returnResource(registryClient);
        sharingClientPool.returnResource(sharingClient);
        return gatewayId;
    } catch (Exception e) {
        logger.error("Error while adding gateway", e);
        AiravataSystemException exception = new AiravataSystemException();
        exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
        exception.setMessage("Error while adding gateway. More info : " + e.getMessage());
        sharingClientPool.returnBrokenResource(sharingClient);
        registryClientPool.returnBrokenResource(registryClient);
        throw exception;
    }
}
Also used : SharingRegistryService(org.apache.airavata.sharing.registry.service.cpi.SharingRegistryService) ResourcePermissionType(org.apache.airavata.model.group.ResourcePermissionType) RegistryService(org.apache.airavata.registry.api.RegistryService) SharingRegistryService(org.apache.airavata.sharing.registry.service.cpi.SharingRegistryService) RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException) CredentialStoreException(org.apache.airavata.credential.store.exception.CredentialStoreException) AiravataException(org.apache.airavata.common.exception.AiravataException) TException(org.apache.thrift.TException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) SecurityCheck(org.apache.airavata.service.security.interceptor.SecurityCheck)

Example 27 with SecurityCheck

use of org.apache.airavata.service.security.interceptor.SecurityCheck in project airavata by apache.

the class AiravataServerHandler method getUserComputeResourcePreference.

/**
 * Fetch a Compute Resource Preference of a registered User Resource profile.
 *
 * @param userId : The identifier for the User Resource profile to be requested
 * @param gatewayID The identifier to link a gateway for the requested User resource
 * @param userComputeResourceId Preferences related to a particular compute resource
 * @return computeResourcePreference
 * Returns the ComputeResourcePreference object.
 */
@Override
@SecurityCheck
public UserComputeResourcePreference getUserComputeResourcePreference(AuthzToken authzToken, String userId, String gatewayID, String userComputeResourceId) throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
    RegistryService.Client regClient = registryClientPool.getResource();
    try {
        UserComputeResourcePreference result = regClient.getUserComputeResourcePreference(userId, gatewayID, userComputeResourceId);
        registryClientPool.returnResource(regClient);
        return result;
    } catch (Exception e) {
        logger.error(userId, "Error while reading user compute resource preference...", e);
        AiravataSystemException exception = new AiravataSystemException();
        exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
        exception.setMessage("Error while reading user compute resource preference. More info : " + e.getMessage());
        registryClientPool.returnBrokenResource(regClient);
        throw exception;
    }
}
Also used : UserComputeResourcePreference(org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference) RegistryService(org.apache.airavata.registry.api.RegistryService) SharingRegistryService(org.apache.airavata.sharing.registry.service.cpi.SharingRegistryService) RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException) CredentialStoreException(org.apache.airavata.credential.store.exception.CredentialStoreException) AiravataException(org.apache.airavata.common.exception.AiravataException) TException(org.apache.thrift.TException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) SecurityCheck(org.apache.airavata.service.security.interceptor.SecurityCheck)

Example 28 with SecurityCheck

use of org.apache.airavata.service.security.interceptor.SecurityCheck in project airavata by apache.

the class AiravataServerHandler method getApplicationModule.

/**
 * Fetch a Application Module.
 *
 * @param appModuleId The identifier for the requested application module
 * @return applicationModule
 * Returns a application Module Object.
 */
@Override
@SecurityCheck
public ApplicationModule getApplicationModule(AuthzToken authzToken, String appModuleId) throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
    RegistryService.Client regClient = registryClientPool.getResource();
    try {
        ApplicationModule result = regClient.getApplicationModule(appModuleId);
        registryClientPool.returnResource(regClient);
        return result;
    } catch (Exception e) {
        logger.error(appModuleId, "Error while retrieving application module...", e);
        AiravataSystemException exception = new AiravataSystemException();
        exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
        exception.setMessage("Error while retrieving the adding application module. More info : " + e.getMessage());
        registryClientPool.returnBrokenResource(regClient);
        throw exception;
    }
}
Also used : RegistryService(org.apache.airavata.registry.api.RegistryService) SharingRegistryService(org.apache.airavata.sharing.registry.service.cpi.SharingRegistryService) RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException) CredentialStoreException(org.apache.airavata.credential.store.exception.CredentialStoreException) AiravataException(org.apache.airavata.common.exception.AiravataException) TException(org.apache.thrift.TException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) ApplicationModule(org.apache.airavata.model.appcatalog.appdeployment.ApplicationModule) SecurityCheck(org.apache.airavata.service.security.interceptor.SecurityCheck)

Example 29 with SecurityCheck

use of org.apache.airavata.service.security.interceptor.SecurityCheck in project airavata by apache.

the class AiravataServerHandler method getSSHAccountProvisioners.

@Override
@SecurityCheck
public List<SSHAccountProvisioner> getSSHAccountProvisioners(AuthzToken authzToken) throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
    List<SSHAccountProvisioner> sshAccountProvisioners = new ArrayList<>();
    List<SSHAccountProvisionerProvider> sshAccountProvisionerProviders = SSHAccountProvisionerFactory.getSSHAccountProvisionerProviders();
    for (SSHAccountProvisionerProvider provider : sshAccountProvisionerProviders) {
        // TODO: Move this Thrift conversion to utility class
        SSHAccountProvisioner sshAccountProvisioner = new SSHAccountProvisioner();
        sshAccountProvisioner.setCanCreateAccount(provider.canCreateAccount());
        sshAccountProvisioner.setCanInstallSSHKey(provider.canInstallSSHKey());
        sshAccountProvisioner.setName(provider.getName());
        List<SSHAccountProvisionerConfigParam> sshAccountProvisionerConfigParams = new ArrayList<>();
        for (ConfigParam configParam : provider.getConfigParams()) {
            SSHAccountProvisionerConfigParam sshAccountProvisionerConfigParam = new SSHAccountProvisionerConfigParam();
            sshAccountProvisionerConfigParam.setName(configParam.getName());
            sshAccountProvisionerConfigParam.setDescription(configParam.getDescription());
            sshAccountProvisionerConfigParam.setIsOptional(configParam.isOptional());
            switch(configParam.getType()) {
                case STRING:
                    sshAccountProvisionerConfigParam.setType(SSHAccountProvisionerConfigParamType.STRING);
                    break;
                case CRED_STORE_PASSWORD_TOKEN:
                    sshAccountProvisionerConfigParam.setType(SSHAccountProvisionerConfigParamType.CRED_STORE_PASSWORD_TOKEN);
                    break;
            }
            sshAccountProvisionerConfigParams.add(sshAccountProvisionerConfigParam);
        }
        sshAccountProvisioner.setConfigParams(sshAccountProvisionerConfigParams);
        sshAccountProvisioners.add(sshAccountProvisioner);
    }
    return sshAccountProvisioners;
}
Also used : SSHAccountProvisionerConfigParam(org.apache.airavata.model.appcatalog.accountprovisioning.SSHAccountProvisionerConfigParam) SSHAccountProvisionerConfigParam(org.apache.airavata.model.appcatalog.accountprovisioning.SSHAccountProvisionerConfigParam) SSHAccountProvisioner(org.apache.airavata.model.appcatalog.accountprovisioning.SSHAccountProvisioner) SecurityCheck(org.apache.airavata.service.security.interceptor.SecurityCheck)

Example 30 with SecurityCheck

use of org.apache.airavata.service.security.interceptor.SecurityCheck in project airavata by apache.

the class AiravataServerHandler method getStorageResource.

/**
 * Fetch the given Storage Resource.
 *
 * @param authzToken
 * @param storageResourceId The identifier for the requested storage resource
 * @return storageResourceDescription
 * Storage Resource Object created from the datamodel..
 */
@Override
@SecurityCheck
public StorageResourceDescription getStorageResource(AuthzToken authzToken, String storageResourceId) throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
    RegistryService.Client regClient = registryClientPool.getResource();
    try {
        StorageResourceDescription result = regClient.getStorageResource(storageResourceId);
        registryClientPool.returnResource(regClient);
        return result;
    } catch (Exception e) {
        logger.error(storageResourceId, "Error while retrieving storage resource...", e);
        AiravataSystemException exception = new AiravataSystemException();
        exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
        exception.setMessage("Error while retrieving storage resource. More info : " + e.getMessage());
        registryClientPool.returnBrokenResource(regClient);
        throw exception;
    }
}
Also used : StorageResourceDescription(org.apache.airavata.model.appcatalog.storageresource.StorageResourceDescription) RegistryService(org.apache.airavata.registry.api.RegistryService) SharingRegistryService(org.apache.airavata.sharing.registry.service.cpi.SharingRegistryService) RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException) CredentialStoreException(org.apache.airavata.credential.store.exception.CredentialStoreException) AiravataException(org.apache.airavata.common.exception.AiravataException) TException(org.apache.thrift.TException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) SecurityCheck(org.apache.airavata.service.security.interceptor.SecurityCheck)

Aggregations

SecurityCheck (org.apache.airavata.service.security.interceptor.SecurityCheck)40 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)39 TException (org.apache.thrift.TException)38 CredentialStoreException (org.apache.airavata.credential.store.exception.CredentialStoreException)28 RegistryServiceException (org.apache.airavata.registry.api.exception.RegistryServiceException)25 AiravataException (org.apache.airavata.common.exception.AiravataException)24 SharingRegistryService (org.apache.airavata.sharing.registry.service.cpi.SharingRegistryService)23 RegistryService (org.apache.airavata.registry.api.RegistryService)22 IamAdminServicesException (org.apache.airavata.service.profile.iam.admin.services.cpi.exception.IamAdminServicesException)12 PasswordCredential (org.apache.airavata.model.credential.store.PasswordCredential)9 TenantManagementKeycloakImpl (org.apache.airavata.service.profile.iam.admin.services.core.impl.TenantManagementKeycloakImpl)9 AuthorizationException (org.apache.airavata.model.error.AuthorizationException)7 Gateway (org.apache.airavata.model.workspace.Gateway)4 Project (org.apache.airavata.model.workspace.Project)4 UserComputeResourcePreference (org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference)3 TenantProfileServiceException (org.apache.airavata.service.profile.tenant.cpi.exception.TenantProfileServiceException)3 UserProfileServiceException (org.apache.airavata.service.profile.user.cpi.exception.UserProfileServiceException)3 CredentialStoreService (org.apache.airavata.credential.store.cpi.CredentialStoreService)2 ApplicationInterfaceDescription (org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDescription)2 UserStoragePreference (org.apache.airavata.model.appcatalog.userresourceprofile.UserStoragePreference)2