Search in sources :

Example 16 with SecurityAccessDto

use of com.sequenceiq.environment.environment.dto.SecurityAccessDto in project cloudbreak by hortonworks.

the class AzureEnvironmentSecurityGroupValidator method validate.

@Override
public void validate(EnvironmentValidationDto environmentValidationDto, ValidationResult.ValidationResultBuilder resultBuilder) {
    EnvironmentDto environmentDto = environmentValidationDto.getEnvironmentDto();
    SecurityAccessDto securityAccessDto = environmentDto.getSecurityAccess();
    if (securityAccessDto != null) {
        if (onlyOneSecurityGroupIdDefined(securityAccessDto)) {
            resultBuilder.error(securityGroupIdsMustBePresent());
        } else if (isSecurityGroupIdDefined(securityAccessDto)) {
            if (!Strings.isNullOrEmpty(securityAccessDto.getDefaultSecurityGroupId())) {
                validateSecurityGroup(environmentDto, resultBuilder, securityAccessDto.getDefaultSecurityGroupId());
            }
            if (!Strings.isNullOrEmpty(securityAccessDto.getSecurityGroupIdForKnox())) {
                validateSecurityGroup(environmentDto, resultBuilder, securityAccessDto.getSecurityGroupIdForKnox());
            }
        }
    }
}
Also used : EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) SecurityAccessDto(com.sequenceiq.environment.environment.dto.SecurityAccessDto)

Example 17 with SecurityAccessDto

use of com.sequenceiq.environment.environment.dto.SecurityAccessDto in project cloudbreak by hortonworks.

the class EnvironmentNetworkProviderValidator method validateSecurityGroup.

private void validateSecurityGroup(EnvironmentValidationDto environmentValidationDto, String cloudPlatform, ValidationResultBuilder resultBuilder) {
    EnvironmentDto environmentDto = environmentValidationDto.getEnvironmentDto();
    SecurityAccessDto securityAccess = environmentDto.getSecurityAccess();
    NetworkDto networkDto = environmentDto.getNetwork();
    if (securityAccess != null && networkDto != null) {
        EnvironmentSecurityGroupValidator environmentSecurityGroupValidator = environmentSecurityGroupValidatorsByCloudPlatform.get(valueOf(cloudPlatform));
        if (environmentSecurityGroupValidator != null) {
            environmentSecurityGroupValidator.validate(environmentValidationDto, resultBuilder);
        } else if (!MOCK.equalsIgnoreCase(cloudPlatform) && !YARN.equalsIgnoreCase(cloudPlatform) && !GCP.equalsIgnoreCase(cloudPlatform)) {
            resultBuilder.error(String.format("Environment specific security group is not supported for cloud platform: '%s'!", cloudPlatform));
        }
    }
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) EnvironmentSecurityGroupValidator(com.sequenceiq.environment.environment.validation.securitygroup.EnvironmentSecurityGroupValidator) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) SecurityAccessDto(com.sequenceiq.environment.environment.dto.SecurityAccessDto)

Aggregations

SecurityAccessDto (com.sequenceiq.environment.environment.dto.SecurityAccessDto)17 Environment (com.sequenceiq.environment.environment.domain.Environment)11 Test (org.junit.jupiter.api.Test)11 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)9 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)8 EnvironmentEditDto (com.sequenceiq.environment.environment.dto.EnvironmentEditDto)5 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)4 NetworkDto (com.sequenceiq.environment.network.dto.NetworkDto)4 BadRequestException (javax.ws.rs.BadRequestException)3 Network (com.sequenceiq.cloudbreak.cloud.model.Network)2 NetworkCidr (com.sequenceiq.cloudbreak.cloud.network.NetworkCidr)2 CloudPlatform (com.sequenceiq.cloudbreak.common.mappable.CloudPlatform)2 Credential (com.sequenceiq.environment.credential.domain.Credential)2 AuthenticationDto (com.sequenceiq.environment.environment.dto.AuthenticationDto)2 EnvironmentBackup (com.sequenceiq.environment.environment.dto.EnvironmentBackup)2 EnvironmentTelemetry (com.sequenceiq.environment.environment.dto.telemetry.EnvironmentTelemetry)2 AwsNetwork (com.sequenceiq.environment.network.dao.domain.AwsNetwork)2 BaseNetwork (com.sequenceiq.environment.network.dao.domain.BaseNetwork)2 GcpNetwork (com.sequenceiq.environment.network.dao.domain.GcpNetwork)2 EnvironmentNetworkConverter (com.sequenceiq.environment.network.v1.converter.EnvironmentNetworkConverter)2