Search in sources :

Example 16 with SecurityCheck

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

the class IamAdminServicesHandler method registerUser.

// ToDo: Will only be secure when using SSL between PGA and Airavata
@Override
@SecurityCheck
public boolean registerUser(AuthzToken authzToken, String username, String emailAddress, String firstName, String lastName, String newPassword) throws IamAdminServicesException, AuthorizationException {
    TenantManagementKeycloakImpl keycloakclient = new TenantManagementKeycloakImpl();
    String gatewayId = authzToken.getClaimsMap().get(Constants.GATEWAY_ID);
    try {
        PasswordCredential isRealmAdminCredentials = getTenantAdminPasswordCredential(gatewayId);
        if (keycloakclient.createUser(isRealmAdminCredentials, gatewayId, username, emailAddress, firstName, lastName, newPassword))
            return true;
        else
            return false;
    } catch (TException | ApplicationSettingsException ex) {
        String msg = "Error while registering user into Identity Server, reason: " + ex.getMessage();
        logger.error(msg, ex);
        throw new IamAdminServicesException(msg);
    }
}
Also used : TenantManagementKeycloakImpl(org.apache.airavata.service.profile.iam.admin.services.core.impl.TenantManagementKeycloakImpl) TException(org.apache.thrift.TException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) IamAdminServicesException(org.apache.airavata.service.profile.iam.admin.services.cpi.exception.IamAdminServicesException) PasswordCredential(org.apache.airavata.model.credential.store.PasswordCredential) SecurityCheck(org.apache.airavata.service.security.interceptor.SecurityCheck)

Example 17 with SecurityCheck

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

the class TenantProfileServiceHandler method updateGateway.

@Override
@SecurityCheck
public boolean updateGateway(AuthzToken authzToken, Gateway updatedGateway) throws TenantProfileServiceException, AuthorizationException, TException {
    try {
        // if admin password token changes then copy the admin password and store under this gateway id and then update the admin password token
        Gateway existingGateway = tenantProfileRepository.getGateway(updatedGateway.getAiravataInternalGatewayId());
        if (updatedGateway.getIdentityServerPasswordToken() != null && (existingGateway.getIdentityServerPasswordToken() == null || !existingGateway.getIdentityServerPasswordToken().equals(updatedGateway.getIdentityServerPasswordToken()))) {
            copyAdminPasswordToGateway(authzToken, updatedGateway);
        }
        if (tenantProfileRepository.update(updatedGateway) != null) {
            logger.debug("Updated gateway-profile with ID: " + updatedGateway.getGatewayId());
            // replicate tenant at end-places
            ProfileServiceUtils.getDbEventPublisher().publish(ProfileServiceUtils.getDBEventMessageContext(EntityType.TENANT, CrudType.UPDATE, updatedGateway), DBEventManagerConstants.getRoutingKey(DBEventService.DB_EVENT.toString()));
            return true;
        } else {
            return false;
        }
    } catch (Exception ex) {
        logger.error("Error updating gateway-profile, reason: " + ex.getMessage(), ex);
        TenantProfileServiceException exception = new TenantProfileServiceException();
        exception.setMessage("Error updating gateway-profile, reason: " + ex.getMessage());
        return false;
    }
}
Also used : TenantProfileServiceException(org.apache.airavata.service.profile.tenant.cpi.exception.TenantProfileServiceException) Gateway(org.apache.airavata.model.workspace.Gateway) CredentialStoreException(org.apache.airavata.credential.store.exception.CredentialStoreException) TenantProfileServiceException(org.apache.airavata.service.profile.tenant.cpi.exception.TenantProfileServiceException) TException(org.apache.thrift.TException) AuthorizationException(org.apache.airavata.model.error.AuthorizationException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) SecurityCheck(org.apache.airavata.service.security.interceptor.SecurityCheck)

Example 18 with SecurityCheck

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

the class UserProfileServiceHandler method deleteUserProfile.

@Override
@SecurityCheck
public boolean deleteUserProfile(AuthzToken authzToken, String userId, String gatewayId) throws UserProfileServiceException, AuthorizationException, TException {
    try {
        // find user-profile
        UserProfile userProfile = userProfileRepository.getUserProfileByIdAndGateWay(userId, gatewayId);
        // delete user
        boolean deleteSuccess = userProfileRepository.delete(userId);
        logger.info("Delete UserProfile with userId: " + userId + ", " + (deleteSuccess ? "Success!" : "Failed!"));
        if (deleteSuccess) {
            // delete userProfile at end-places
            ProfileServiceUtils.getDbEventPublisher().publish(ProfileServiceUtils.getDBEventMessageContext(EntityType.USER_PROFILE, CrudType.DELETE, userProfile), DBEventManagerConstants.getRoutingKey(DBEventService.DB_EVENT.toString()));
        }
        return deleteSuccess;
    } catch (Exception e) {
        logger.error("Error while deleting user profile", e);
        UserProfileServiceException exception = new UserProfileServiceException();
        exception.setMessage("Error while deleting user profile. More info : " + e.getMessage());
        throw exception;
    }
}
Also used : UserProfile(org.apache.airavata.model.user.UserProfile) UserProfileServiceException(org.apache.airavata.service.profile.user.cpi.exception.UserProfileServiceException) TException(org.apache.thrift.TException) AuthorizationException(org.apache.airavata.model.error.AuthorizationException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) IamAdminServicesException(org.apache.airavata.service.profile.iam.admin.services.cpi.exception.IamAdminServicesException) UserProfileServiceException(org.apache.airavata.service.profile.user.cpi.exception.UserProfileServiceException) SecurityCheck(org.apache.airavata.service.security.interceptor.SecurityCheck)

Example 19 with SecurityCheck

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

the class UserProfileServiceHandler method updateUserProfile.

@Override
@SecurityCheck
public boolean updateUserProfile(AuthzToken authzToken, UserProfile userProfile) throws UserProfileServiceException, AuthorizationException, TException {
    try {
        // After updating the user profile in the database but before committing the transaction, the
        // following will update the user profile in the IAM service also. If the update in the IAM service
        // fails then the transaction will be rolled back.
        Runnable iamUserProfileUpdater = getIAMUserProfileUpdater(authzToken, userProfile);
        if (userProfileRepository.updateUserProfile(userProfile, iamUserProfileUpdater) != null) {
            logger.info("Updated UserProfile with userId: " + userProfile.getUserId());
            // replicate userProfile at end-places
            ProfileServiceUtils.getDbEventPublisher().publish(ProfileServiceUtils.getDBEventMessageContext(EntityType.USER_PROFILE, CrudType.UPDATE, userProfile), DBEventManagerConstants.getRoutingKey(DBEventService.DB_EVENT.toString()));
            return true;
        }
        return false;
    } catch (Exception e) {
        logger.error("Error while Updating user profile", e);
        UserProfileServiceException exception = new UserProfileServiceException();
        exception.setMessage("Error while Updating user profile. More info : " + e.getMessage());
        throw exception;
    }
}
Also used : UserProfileServiceException(org.apache.airavata.service.profile.user.cpi.exception.UserProfileServiceException) TException(org.apache.thrift.TException) AuthorizationException(org.apache.airavata.model.error.AuthorizationException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) IamAdminServicesException(org.apache.airavata.service.profile.iam.admin.services.cpi.exception.IamAdminServicesException) UserProfileServiceException(org.apache.airavata.service.profile.user.cpi.exception.UserProfileServiceException) SecurityCheck(org.apache.airavata.service.security.interceptor.SecurityCheck)

Example 20 with SecurityCheck

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

the class AiravataServerHandler method getGateway.

@Override
@SecurityCheck
public Gateway getGateway(AuthzToken authzToken, String gatewayId) throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
    RegistryService.Client regClient = registryClientPool.getResource();
    try {
        Gateway result = regClient.getGateway(gatewayId);
        registryClientPool.returnResource(regClient);
        return result;
    } catch (Exception e) {
        logger.error("Error while getting the gateway", e);
        AiravataSystemException exception = new AiravataSystemException();
        exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
        exception.setMessage("Error while getting the gateway. More info : " + e.getMessage());
        registryClientPool.returnBrokenResource(regClient);
        throw exception;
    }
}
Also used : Gateway(org.apache.airavata.model.workspace.Gateway) 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