Search in sources :

Example 1 with CheckPermissionByRequestProperty

use of com.sequenceiq.authorization.annotation.CheckPermissionByRequestProperty in project cloudbreak by hortonworks.

the class FreeIpaV1Controller method create.

@Override
@CheckPermissionByRequestProperty(path = "environmentCrn", type = CRN, action = EDIT_ENVIRONMENT)
public DescribeFreeIpaResponse create(@RequestObject @Valid CreateFreeIpaRequest request) {
    ValidationResult validationResult = createFreeIpaRequestValidator.validate(request);
    if (validationResult.getState() == State.ERROR) {
        LOGGER.debug("FreeIPA request has validation error(s): {}.", validationResult.getFormattedErrors());
        throw new BadRequestException(validationResult.getFormattedErrors());
    }
    String accountId = crnService.getCurrentAccountId();
    return freeIpaCreationService.launchFreeIpa(request, accountId);
}
Also used : BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) CheckPermissionByRequestProperty(com.sequenceiq.authorization.annotation.CheckPermissionByRequestProperty)

Example 2 with CheckPermissionByRequestProperty

use of com.sequenceiq.authorization.annotation.CheckPermissionByRequestProperty in project cloudbreak by hortonworks.

the class EnvironmentController method post.

@Override
@CheckPermissionByAccount(action = AuthorizationResourceAction.CREATE_ENVIRONMENT)
@CheckPermissionByRequestProperty(path = "credentialName", type = NAME, action = DESCRIBE_CREDENTIAL)
public DetailedEnvironmentResponse post(@RequestObject @Valid EnvironmentRequest request) {
    EnvironmentCreationDto environmentCreationDto = environmentApiConverter.initCreationDto(request);
    EnvironmentDto envDto = environmentCreationService.create(environmentCreationDto);
    return environmentResponseConverter.dtoToDetailedResponse(envDto);
}
Also used : EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) EnvironmentCreationDto(com.sequenceiq.environment.environment.dto.EnvironmentCreationDto) CheckPermissionByRequestProperty(com.sequenceiq.authorization.annotation.CheckPermissionByRequestProperty) CheckPermissionByAccount(com.sequenceiq.authorization.annotation.CheckPermissionByAccount)

Example 3 with CheckPermissionByRequestProperty

use of com.sequenceiq.authorization.annotation.CheckPermissionByRequestProperty in project cloudbreak by hortonworks.

the class EnvironmentController method changeCredentialByEnvironmentName.

@Override
@CheckPermissionByRequestProperty(path = "credentialName", type = NAME, action = DESCRIBE_CREDENTIAL)
@CheckPermissionByResourceName(action = AuthorizationResourceAction.CHANGE_CREDENTIAL)
public DetailedEnvironmentResponse changeCredentialByEnvironmentName(@ResourceName String environmentName, @RequestObject @Valid EnvironmentChangeCredentialRequest request) {
    String accountId = ThreadBasedUserCrnProvider.getAccountId();
    EnvironmentChangeCredentialDto dto = environmentApiConverter.convertEnvironmentChangeCredentialDto(request);
    EnvironmentDto result = environmentModificationService.changeCredentialByEnvironmentName(accountId, environmentName, dto);
    return environmentResponseConverter.dtoToDetailedResponse(result);
}
Also used : EnvironmentChangeCredentialDto(com.sequenceiq.environment.environment.dto.EnvironmentChangeCredentialDto) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) CheckPermissionByRequestProperty(com.sequenceiq.authorization.annotation.CheckPermissionByRequestProperty) CheckPermissionByResourceName(com.sequenceiq.authorization.annotation.CheckPermissionByResourceName)

Example 4 with CheckPermissionByRequestProperty

use of com.sequenceiq.authorization.annotation.CheckPermissionByRequestProperty in project cloudbreak by hortonworks.

the class SdxController method changeImageCatalog.

@Override
@CheckPermissionByResourceName(action = AuthorizationResourceAction.CHANGE_IMAGE_CATALOG_DATALAKE)
@CheckPermissionByRequestProperty(type = NAME, path = "imageCatalog", action = DESCRIBE_IMAGE_CATALOG)
public void changeImageCatalog(@ResourceName String name, @RequestObject SdxChangeImageCatalogRequest changeImageCatalogRequest) {
    SdxCluster sdxCluster = getSdxClusterByName(name);
    sdxImageCatalogService.changeImageCatalog(sdxCluster, changeImageCatalogRequest.getImageCatalog());
}
Also used : SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) CheckPermissionByRequestProperty(com.sequenceiq.authorization.annotation.CheckPermissionByRequestProperty) CheckPermissionByResourceName(com.sequenceiq.authorization.annotation.CheckPermissionByResourceName)

Example 5 with CheckPermissionByRequestProperty

use of com.sequenceiq.authorization.annotation.CheckPermissionByRequestProperty in project cloudbreak by hortonworks.

the class CredentialV1Controller method put.

@Override
@CheckPermissionByRequestProperty(path = "name", type = NAME, action = EDIT_CREDENTIAL)
public CredentialResponse put(@RequestObject @Valid EditCredentialRequest credentialRequest) {
    Credential credential = credentialConverter.convert(credentialRequest);
    credential.setType(ENVIRONMENT);
    credential = credentialService.updateByAccountId(credential, ThreadBasedUserCrnProvider.getAccountId(), ENVIRONMENT);
    notify(ResourceEvent.CREDENTIAL_MODIFIED);
    return credentialConverter.convert(credential);
}
Also used : Credential(com.sequenceiq.environment.credential.domain.Credential) CheckPermissionByRequestProperty(com.sequenceiq.authorization.annotation.CheckPermissionByRequestProperty)

Aggregations

CheckPermissionByRequestProperty (com.sequenceiq.authorization.annotation.CheckPermissionByRequestProperty)7 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)3 CheckPermissionByResourceName (com.sequenceiq.authorization.annotation.CheckPermissionByResourceName)2 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)2 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)2 CheckPermissionByAccount (com.sequenceiq.authorization.annotation.CheckPermissionByAccount)1 CheckPermissionByResourceCrn (com.sequenceiq.authorization.annotation.CheckPermissionByResourceCrn)1 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)1 Credential (com.sequenceiq.environment.credential.domain.Credential)1 EnvironmentChangeCredentialDto (com.sequenceiq.environment.environment.dto.EnvironmentChangeCredentialDto)1 EnvironmentCreationDto (com.sequenceiq.environment.environment.dto.EnvironmentCreationDto)1