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;
}
}
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;
}
}
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;
}
}
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;
}
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;
}
}
Aggregations