Search in sources :

Example 11 with ConfigurationFieldValidator

use of com.synopsys.integration.alert.common.descriptor.validator.ConfigurationFieldValidator in project hub-alert by blackducksoftware.

the class AuthenticationConfigurationFieldModelValidator method validate.

@Override
public Set<AlertFieldStatus> validate(FieldModel fieldModel) {
    ConfigurationFieldValidator configurationFieldValidator = ConfigurationFieldValidator.fromFieldModel(fieldModel);
    boolean ldapEnabled = configurationFieldValidator.getBooleanValue(AuthenticationDescriptor.KEY_LDAP_ENABLED).orElse(false);
    boolean samlEnabled = configurationFieldValidator.getBooleanValue(AuthenticationDescriptor.KEY_SAML_ENABLED).orElse(false);
    if (ldapEnabled && samlEnabled) {
        configurationFieldValidator.addValidationResults(AlertFieldStatus.error(AuthenticationDescriptor.KEY_LDAP_ENABLED, SAML_LDAP_ENABLED_ERROR));
        configurationFieldValidator.addValidationResults(AlertFieldStatus.error(AuthenticationDescriptor.KEY_SAML_ENABLED, SAML_LDAP_ENABLED_ERROR));
    }
    if (ldapEnabled) {
        configurationFieldValidator.validateRequiredFieldsAreNotBlank(List.of(AuthenticationDescriptor.KEY_LDAP_SERVER, AuthenticationDescriptor.KEY_LDAP_MANAGER_DN, AuthenticationDescriptor.KEY_LDAP_MANAGER_PWD));
    }
    if (samlEnabled) {
        configurationFieldValidator.validateRequiredFieldsAreNotBlank(List.of(AuthenticationDescriptor.KEY_SAML_ENTITY_ID, AuthenticationDescriptor.KEY_SAML_ENTITY_BASE_URL));
        if (configurationFieldValidator.fieldHasNoReadableValue(AuthenticationDescriptor.KEY_SAML_METADATA_URL) && !filePersistenceUtil.uploadFileExists(AuthenticationDescriptor.SAML_METADATA_FILE)) {
            configurationFieldValidator.addValidationResults(AlertFieldStatus.error(AuthenticationDescriptor.KEY_SAML_METADATA_FILE, AuthenticationDescriptor.FIELD_ERROR_SAML_METADATA_FILE_MISSING));
        }
        validateMetaData(configurationFieldValidator, AuthenticationDescriptor.KEY_SAML_METADATA_URL, AuthenticationDescriptor.FIELD_ERROR_SAML_METADATA_URL_MISSING);
        validateMetaData(configurationFieldValidator, AuthenticationDescriptor.KEY_SAML_ENTITY_BASE_URL, AuthenticationDescriptor.FIELD_ERROR_SAML_METADATA_URL_MISSING);
    }
    return configurationFieldValidator.getValidationResults();
}
Also used : ConfigurationFieldValidator(com.synopsys.integration.alert.common.descriptor.validator.ConfigurationFieldValidator)

Example 12 with ConfigurationFieldValidator

use of com.synopsys.integration.alert.common.descriptor.validator.ConfigurationFieldValidator in project hub-alert by blackducksoftware.

the class SlackDistributionConfigurationValidator method validate.

@Override
public Set<AlertFieldStatus> validate(JobFieldModel jobFieldModel) {
    ConfigurationFieldValidator configurationFieldValidator = ConfigurationFieldValidator.fromJobFieldModel(jobFieldModel);
    commonChannelDistributionValidator.validate(configurationFieldValidator);
    configurationFieldValidator.validateRequiredFieldsAreNotBlank(List.of(SlackDescriptor.KEY_WEBHOOK, SlackDescriptor.KEY_CHANNEL_NAME));
    configurationFieldValidator.validateIsAURL(SlackDescriptor.KEY_WEBHOOK);
    return configurationFieldValidator.getValidationResults();
}
Also used : ConfigurationFieldValidator(com.synopsys.integration.alert.common.descriptor.validator.ConfigurationFieldValidator)

Example 13 with ConfigurationFieldValidator

use of com.synopsys.integration.alert.common.descriptor.validator.ConfigurationFieldValidator in project hub-alert by blackducksoftware.

the class MsTeamsDistributionConfigurationValidator method validate.

@Override
public Set<AlertFieldStatus> validate(JobFieldModel jobFieldModel) {
    ConfigurationFieldValidator configurationFieldValidator = ConfigurationFieldValidator.fromJobFieldModel(jobFieldModel);
    commonChannelDistributionValidator.validate(configurationFieldValidator);
    configurationFieldValidator.validateRequiredFieldIsNotBlank(MsTeamsDescriptor.KEY_WEBHOOK);
    configurationFieldValidator.validateIsAURL(MsTeamsDescriptor.KEY_WEBHOOK);
    return configurationFieldValidator.getValidationResults();
}
Also used : ConfigurationFieldValidator(com.synopsys.integration.alert.common.descriptor.validator.ConfigurationFieldValidator)

Example 14 with ConfigurationFieldValidator

use of com.synopsys.integration.alert.common.descriptor.validator.ConfigurationFieldValidator in project hub-alert by blackducksoftware.

the class SchedulingConfigurationFieldModelValidator method validate.

@Override
public Set<AlertFieldStatus> validate(FieldModel fieldModel) {
    ConfigurationFieldValidator configurationFieldValidator = ConfigurationFieldValidator.fromFieldModel(fieldModel);
    configurationFieldValidator.validateRequiredFieldsAreNotBlank(List.of(SchedulingDescriptor.KEY_DAILY_PROCESSOR_HOUR_OF_DAY, SchedulingDescriptor.KEY_PURGE_DATA_FREQUENCY_DAYS));
    configurationFieldValidator.validateIsAValidOption(SchedulingDescriptor.KEY_DAILY_PROCESSOR_HOUR_OF_DAY, getDigestHours());
    configurationFieldValidator.validateIsAValidOption(SchedulingDescriptor.KEY_PURGE_DATA_FREQUENCY_DAYS, getPurgeFrequency());
    return configurationFieldValidator.getValidationResults();
}
Also used : ConfigurationFieldValidator(com.synopsys.integration.alert.common.descriptor.validator.ConfigurationFieldValidator)

Example 15 with ConfigurationFieldValidator

use of com.synopsys.integration.alert.common.descriptor.validator.ConfigurationFieldValidator in project hub-alert by blackducksoftware.

the class SettingsGlobalConfigurationFieldModelValidator method validate.

@Override
public Set<AlertFieldStatus> validate(FieldModel fieldModel) {
    ConfigurationFieldValidator configurationFieldValidator = ConfigurationFieldValidator.fromFieldModel(fieldModel);
    configurationFieldValidator.validateRequiredFieldsAreNotBlank(List.of(SettingsDescriptor.KEY_ENCRYPTION_PWD, SettingsDescriptor.KEY_ENCRYPTION_GLOBAL_SALT));
    minimumEncryptionFieldLength(configurationFieldValidator, SettingsDescriptor.KEY_ENCRYPTION_PWD);
    minimumEncryptionFieldLength(configurationFieldValidator, SettingsDescriptor.KEY_ENCRYPTION_GLOBAL_SALT);
    validateProxySettings(configurationFieldValidator);
    return configurationFieldValidator.getValidationResults();
}
Also used : ConfigurationFieldValidator(com.synopsys.integration.alert.common.descriptor.validator.ConfigurationFieldValidator)

Aggregations

ConfigurationFieldValidator (com.synopsys.integration.alert.common.descriptor.validator.ConfigurationFieldValidator)15 CommonChannelDistributionValidator (com.synopsys.integration.alert.api.channel.CommonChannelDistributionValidator)2 JiraFieldMappingValidator (com.synopsys.integration.alert.api.channel.jira.validation.JiraFieldMappingValidator)2 AlertFieldStatus (com.synopsys.integration.alert.common.descriptor.config.field.errors.AlertFieldStatus)2 DistributionConfigurationValidator (com.synopsys.integration.alert.common.descriptor.validator.DistributionConfigurationValidator)2 JobFieldModel (com.synopsys.integration.alert.common.rest.model.JobFieldModel)2 HashSet (java.util.HashSet)2 Set (java.util.Set)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 Component (org.springframework.stereotype.Component)2 JiraCloudDescriptor (com.synopsys.integration.alert.channel.jira.cloud.descriptor.JiraCloudDescriptor)1 JiraServerDescriptor (com.synopsys.integration.alert.channel.jira.server.descriptor.JiraServerDescriptor)1 FieldValueModel (com.synopsys.integration.alert.common.rest.model.FieldValueModel)1 JiraCloudChannelKey (com.synopsys.integration.alert.descriptor.api.JiraCloudChannelKey)1 JiraServerChannelKey (com.synopsys.integration.alert.descriptor.api.JiraServerChannelKey)1