Search in sources :

Example 1 with SecurityCheck

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

the class AiravataServerHandler method getApplicationInterface.

/**
 * Fetch a Application Interface.
 *
 * @param appInterfaceId The identifier for the requested application module
 * @return applicationInterface
 * Returns a application Interface Object.
 */
@Override
@SecurityCheck
public ApplicationInterfaceDescription getApplicationInterface(AuthzToken authzToken, String appInterfaceId) throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
    RegistryService.Client regClient = registryClientPool.getResource();
    try {
        ApplicationInterfaceDescription result = regClient.getApplicationInterface(appInterfaceId);
        registryClientPool.returnResource(regClient);
        return result;
    } catch (Exception e) {
        logger.error(appInterfaceId, "Error while retrieving application interface...", e);
        AiravataSystemException exception = new AiravataSystemException();
        exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
        exception.setMessage("Error while retrieving application interface. More info : " + e.getMessage());
        registryClientPool.returnBrokenResource(regClient);
        throw exception;
    }
}
Also used : ApplicationInterfaceDescription(org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDescription) 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 2 with SecurityCheck

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

the class AiravataServerHandler method getApplicationDeployment.

/**
 * Fetch a Application Deployment.
 *
 * @param appDeploymentId The identifier for the requested application module
 * @return applicationDeployment
 * Returns a application Deployment Object.
 */
@Override
@SecurityCheck
public ApplicationDeploymentDescription getApplicationDeployment(AuthzToken authzToken, String appDeploymentId) throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
    RegistryService.Client regClient = registryClientPool.getResource();
    try {
        ApplicationDeploymentDescription result = regClient.getApplicationDeployment(appDeploymentId);
        registryClientPool.returnResource(regClient);
        return result;
    } catch (Exception e) {
        logger.error(appDeploymentId, "Error while retrieving application deployment...", e);
        AiravataSystemException exception = new AiravataSystemException();
        exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
        exception.setMessage("Error while retrieving application deployment. More info : " + e.getMessage());
        registryClientPool.returnBrokenResource(regClient);
        throw exception;
    }
}
Also used : ApplicationDeploymentDescription(org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription) 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 3 with SecurityCheck

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

the class AiravataServerHandler method deleteProject.

@Override
@SecurityCheck
public boolean deleteProject(AuthzToken authzToken, String projectId) throws InvalidRequestException, AiravataClientException, AiravataSystemException, ProjectNotFoundException, AuthorizationException, TException {
    RegistryService.Client regClient = registryClientPool.getResource();
    SharingRegistryService.Client sharingClient = sharingClientPool.getResource();
    try {
        Project existingProject = regClient.getProject(projectId);
        if (ServerSettings.isEnableSharing() && !authzToken.getClaimsMap().get(org.apache.airavata.common.utils.Constants.USER_NAME).equals(existingProject.getOwner()) || !authzToken.getClaimsMap().get(org.apache.airavata.common.utils.Constants.GATEWAY_ID).equals(existingProject.getGatewayId())) {
            try {
                String gatewayId = authzToken.getClaimsMap().get(Constants.GATEWAY_ID);
                String userId = authzToken.getClaimsMap().get(Constants.USER_NAME);
                if (!sharingClient.userHasAccess(gatewayId, userId + "@" + gatewayId, projectId, gatewayId + ":WRITE")) {
                    throw new AuthorizationException("User does not have permission to access this resource");
                }
            } catch (Exception e) {
                throw new AuthorizationException("User does not have permission to access this resource");
            }
        }
        boolean ret = regClient.deleteProject(projectId);
        logger.debug("Airavata deleted project with project Id : " + projectId);
        registryClientPool.returnResource(regClient);
        sharingClientPool.returnResource(sharingClient);
        return ret;
    } catch (Exception e) {
        logger.error("Error while removing the project", e);
        ProjectNotFoundException exception = new ProjectNotFoundException();
        exception.setMessage("Error while removing the project. More info : " + e.getMessage());
        registryClientPool.returnBrokenResource(regClient);
        sharingClientPool.returnBrokenResource(sharingClient);
        throw exception;
    }
}
Also used : Project(org.apache.airavata.model.workspace.Project) SharingRegistryService(org.apache.airavata.sharing.registry.service.cpi.SharingRegistryService) 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 4 with SecurityCheck

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

the class AiravataServerHandler method getGatewayStoragePreference.

@Override
@SecurityCheck
public StoragePreference getGatewayStoragePreference(AuthzToken authzToken, String gatewayID, String storageId) throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
    RegistryService.Client regClient = registryClientPool.getResource();
    try {
        StoragePreference result = regClient.getGatewayStoragePreference(gatewayID, storageId);
        registryClientPool.returnResource(regClient);
        return result;
    } catch (Exception e) {
        logger.error(gatewayID, "Error while reading gateway data storage preference...", e);
        AiravataSystemException exception = new AiravataSystemException();
        exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
        exception.setMessage("Error while reading gateway data storage preference. 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) UserStoragePreference(org.apache.airavata.model.appcatalog.userresourceprofile.UserStoragePreference) StoragePreference(org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference) 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 5 with SecurityCheck

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

the class AiravataServerHandler method getGatewayResourceProfile.

/**
 * Fetch the given Gateway Resource Profile.
 *
 * @param gatewayID The identifier for the requested gateway resource
 * @return gatewayResourceProfile
 * Gateway Resource Profile Object.
 */
@Override
@SecurityCheck
public GatewayResourceProfile getGatewayResourceProfile(AuthzToken authzToken, String gatewayID) throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
    RegistryService.Client regClient = registryClientPool.getResource();
    try {
        GatewayResourceProfile result = regClient.getGatewayResourceProfile(gatewayID);
        registryClientPool.returnResource(regClient);
        return result;
    } catch (Exception e) {
        logger.error(gatewayID, "Error while retrieving gateway resource profile...", e);
        AiravataSystemException exception = new AiravataSystemException();
        exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
        exception.setMessage("Error while retrieving gateway resource profile. More info : " + e.getMessage());
        registryClientPool.returnBrokenResource(regClient);
        throw exception;
    }
}
Also used : GatewayResourceProfile(org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile) 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