use of com.sequenceiq.cloudbreak.common.mappable.CloudPlatform.GCP in project cloudbreak by hortonworks.
the class EnvironmentValidatorService method validateEncryptionKey.
public ValidationResult validateEncryptionKey(EnvironmentCreationDto creationDto) {
ValidationResultBuilder resultBuilder = ValidationResult.builder();
if (GCP.name().equalsIgnoreCase(creationDto.getCloudPlatform())) {
String encryptionKey = Optional.ofNullable(creationDto.getParameters()).map(parametersDto -> parametersDto.getGcpParametersDto()).map(gcpParametersDto -> gcpParametersDto.getGcpResourceEncryptionParametersDto()).map(gcpREParamsDto -> gcpREParamsDto.getEncryptionKey()).orElse(null);
if (StringUtils.isNotEmpty(encryptionKey)) {
if (!entitlementService.isGcpDiskEncryptionWithCMEKEnabled(creationDto.getAccountId())) {
resultBuilder.error(String.format("You have specified encryption-key to enable encryption for GCP resources with CMEK " + "but that feature is currently not enabled for this account." + " Please get 'CDP_CB_GCP_DISK_ENCRYPTION_WITH_CMEK' enabled for this account."));
} else {
ValidationResult validationResult = encryptionKeyValidator.validateEncryptionKey(encryptionKey);
resultBuilder.merge(validationResult);
}
}
}
return resultBuilder.build();
}
use of com.sequenceiq.cloudbreak.common.mappable.CloudPlatform.GCP in project cloudbreak by hortonworks.
the class EnvironmentCreationService method validateEncryptionKey.
private ValidationResult validateEncryptionKey(EnvironmentCreationDto creationDto) {
ValidationResultBuilder resultBuilder = ValidationResult.builder();
String cloudPlatform = creationDto.getCloudPlatform().toLowerCase(Locale.ROOT);
switch(cloudPlatform) {
case "azure":
String encryptionKeyUrl = Optional.ofNullable(creationDto.getParameters()).map(paramsDto -> paramsDto.getAzureParametersDto()).map(azureParamsDto -> azureParamsDto.getAzureResourceEncryptionParametersDto()).map(azureREParamsDto -> azureREParamsDto.getEncryptionKeyUrl()).orElse(null);
if (encryptionKeyUrl != null) {
resultBuilder.merge(validatorService.validateEncryptionKeyUrl(encryptionKeyUrl, creationDto.getAccountId()));
}
break;
case "gcp":
String encryptionKey = Optional.ofNullable(creationDto.getParameters()).map(parametersDto -> parametersDto.getGcpParametersDto()).map(gcpParametersDto -> gcpParametersDto.getGcpResourceEncryptionParametersDto()).map(gcpREParamsDto -> gcpREParamsDto.getEncryptionKey()).orElse(null);
if (encryptionKey != null) {
resultBuilder.merge(validatorService.validateEncryptionKey(encryptionKey, creationDto.getAccountId()));
}
break;
case "aws":
String encryptionKeyArn = Optional.ofNullable(creationDto.getParameters()).map(paramsDto -> paramsDto.getAwsParametersDto()).map(awsParamsDto -> awsParamsDto.getAwsDiskEncryptionParametersDto()).map(awsREparamsDto -> awsREparamsDto.getEncryptionKeyArn()).orElse(null);
if (encryptionKeyArn != null) {
resultBuilder.merge(validatorService.validateEncryptionKeyArn(encryptionKeyArn, creationDto.getAccountId()));
}
break;
default:
break;
}
return resultBuilder.build();
}
Aggregations