io.dropwizard.configuration.ConfigurationException Java Examples

The following examples show how to use io.dropwizard.configuration.ConfigurationException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VerifyServiceProviderConfigurationTest.java    From verify-service-provider with MIT License 5 votes vote down vote up
@Test
public void shouldNotAllowMsaAndEidasConfigTogether() throws Exception {
    Map<String, String> map = ImmutableMap.<String,String>builder()
        .put("PORT", "50555")
        .put("LOG_LEVEL", "ERROR")
        .put("VERIFY_ENVIRONMENT", "COMPLIANCE_TOOL")
        .put("MSA_METADATA_URL", "some-msa-metadata-url")
        .put("MSA_ENTITY_ID", "some-msa-entity-id")
        .put("SERVICE_ENTITY_IDS", "[\"http://some-service-entity-id\"]")
        .put("SAML_SIGNING_KEY", TEST_RP_PRIVATE_SIGNING_KEY)
        .put("SAML_PRIMARY_ENCRYPTION_KEY", TEST_RP_PRIVATE_ENCRYPTION_KEY)
        .put("SAML_SECONDARY_ENCRYPTION_KEY", TEST_RP_PRIVATE_ENCRYPTION_KEY)
        .put("CLOCK_SKEW", "PT30s")
        .put("EUROPEAN_IDENTITY_ENABLED", "false")
        .put("HUB_CONNECTOR_ENTITY_ID", "etc")
        .put("TRUST_ANCHOR_URI", "etc")
        .put("METADATA_SOURCE_URI", "etc")
        .put("TRUSTSTORE_PATH", "etc")
        .put("TRUSTSTORE_PASSWORD", "etc")
        .build();

    String newErrorMessage = "eIDAS and MSA support cannot be set together." +
        " The VSP's eIDAS support is only available when it operates without the MSA";
    assertThatThrownBy(() -> {
            factory.build(
                new SubstitutingSourceProvider(
                    new FileConfigurationSourceProvider(),
                    new StrSubstitutor(map)
                ),
                ResourceHelpers.resourceFilePath("verify-service-provider-with-msa-and-eidas.yml")
            );
        }).isInstanceOf(ConfigurationException.class).hasMessageContaining(newErrorMessage);
}
 
Example #2
Source File: EmoService.java    From emodb with Apache License 2.0 5 votes vote down vote up
private EmoConfiguration loadConfigFile(File configFile)
        throws IOException, ConfigurationException {
    Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
    ObjectMapper mapper = EmoServiceObjectMapperFactory.build(new YAMLFactory());
    ConfigurationFactory<EmoConfiguration> configurationFactory = new ConfigurationFactory(EmoConfiguration.class, validator, mapper, "dw");
    return configurationFactory.build(configFile);
}
 
Example #3
Source File: CreateKeyspacesCommand.java    From emodb with Apache License 2.0 5 votes vote down vote up
public static DdlConfiguration parseDdlConfiguration(File file) throws IOException, ConfigurationException {
    // Similar to Dropwizard's ConfigurationFactory but ignores System property overrides.
    ObjectMapper mapper = EmoServiceObjectMapperFactory.build(new YAMLFactory());
    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true);
    DdlConfiguration ddlConfiguration = mapper.readValue(file, DdlConfiguration.class);

    Set<ConstraintViolation<DdlConfiguration>> errors = _validator.validate(ddlConfiguration);
    if (!errors.isEmpty()) {
        throw new ConfigurationValidationException(file.toString(), errors);
    }

    return ddlConfiguration;
}
 
Example #4
Source File: SdkConfigTest.java    From emodb with Apache License 2.0 5 votes vote down vote up
@Test
public void ensureSdkDefaultConfigDeserialization()
        throws IOException, URISyntaxException, ConfigurationException {
    // This test makes sure that we haven't forgotten to update the emodb sdk default config file when we add/remove properties
    Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
    ObjectMapper mapper = EmoServiceObjectMapperFactory.build(new YAMLFactory());
    ConfigurationFactory configurationFactory = new ConfigurationFactory(EmoConfiguration.class, validator, mapper, "dw");
    // Make sure that our config files are up to date
    configurationFactory.build(
    new File(EmoStartMojo.class.getResource("/emodb-default-config.yaml").toURI()));
}
 
Example #5
Source File: MegabusConfigTest.java    From emodb with Apache License 2.0 5 votes vote down vote up
@Test
public void ensureMegabusDefaultConfigDeserialization()
    throws IOException, URISyntaxException, ConfigurationException {
    Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
    ObjectMapper mapper = CustomJsonObjectMapperFactory.build(new YAMLFactory());
    ConfigurationFactory configurationFactory = new ConfigurationFactory(MegabusConfiguration.class, validator, mapper, "dw");
    // Make sure that our config files are up to date
    configurationFactory.build(
        new File(MegabusConfiguration.class.getResource("/emodb-megabus-config.yaml").toURI()));
}
 
Example #6
Source File: KafkaConfigTest.java    From emodb with Apache License 2.0 5 votes vote down vote up
@Test
public void ensureKafkaDefaultConfigDeserialization()
    throws IOException, URISyntaxException, ConfigurationException {
    Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
    ObjectMapper mapper = CustomJsonObjectMapperFactory.build(new YAMLFactory());
    ConfigurationFactory configurationFactory = new ConfigurationFactory(KafkaConfiguration.class, validator, mapper, "dw");
    // Make sure that our config files are up to date
    configurationFactory.build(
        new File(KafkaConfiguration.class.getResource("/emodb-kafka-config.yaml").toURI()));
}
 
Example #7
Source File: UpgradeCommand.java    From irontest with Apache License 2.0 5 votes vote down vote up
private IronTestConfiguration getIronTestConfiguration(String ironTestHome) throws IOException, ConfigurationException {
    Path configYmlFilePath = Paths.get(ironTestHome, "config.yml");
    ObjectMapper objectMapper = Jackson.newObjectMapper();
    Validator validator = Validators.newValidator();
    YamlConfigurationFactory<IronTestConfiguration> factory =
            new YamlConfigurationFactory<>(IronTestConfiguration.class, validator, objectMapper, "dw");
    IronTestConfiguration configuration = factory.build(configYmlFilePath.toFile());
    return configuration;
}
 
Example #8
Source File: KeywhizTestRunner.java    From keywhiz with Apache License 2.0 5 votes vote down vote up
static Injector createInjector() {
  KeywhizService service = new KeywhizService();
  Bootstrap<KeywhizConfig> bootstrap = new Bootstrap<>(service);
  service.initialize(bootstrap);

  File yamlFile = new File(Resources.getResource("keywhiz-test.yaml").getFile());
  Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
  ObjectMapper objectMapper = bootstrap.getObjectMapper().copy();
  KeywhizConfig config;
  try {
    config = new YamlConfigurationFactory<>(KeywhizConfig.class, validator, objectMapper, "dw")
        .build(yamlFile);
  } catch (IOException | ConfigurationException e) {
    throw Throwables.propagate(e);
  }

  Environment environment = new Environment(service.getName(),
      objectMapper,
      validator,
      bootstrap.getMetricRegistry(),
      bootstrap.getClassLoader());

  Injector injector = Guice.createInjector(new ServiceModule(config, environment));

  service.setInjector(injector);
  return injector;
}
 
Example #9
Source File: Cli.java    From oxd with Apache License 2.0 5 votes vote down vote up
private static OxdServerConfiguration parseConfiguration(String pathToYaml) throws IOException, ConfigurationException {
    if (StringUtils.isBlank(pathToYaml)) {
        System.out.println("Path to yml configuration file is not specified. Exit!");
        System.exit(1);
    }
    File file = new File(pathToYaml);
    if (!file.exists()) {
        System.out.println("Failed to find yml configuration file. Please check " + pathToYaml);
        System.exit(1);
    }

    DefaultConfigurationFactoryFactory<OxdServerConfiguration> configurationFactoryFactory = new DefaultConfigurationFactoryFactory<>();
    ConfigurationFactory<OxdServerConfiguration> configurationFactory = configurationFactoryFactory.create(OxdServerConfiguration.class, Validators.newValidatorFactory().getValidator(), Jackson.newObjectMapper(), "dw");
    return configurationFactory.build(file);
}
 
Example #10
Source File: TestUtils.java    From oxd with Apache License 2.0 5 votes vote down vote up
public static OxdServerConfiguration parseConfiguration(String pathToYaml) throws IOException, ConfigurationException {

        File file = new File(pathToYaml);
        if (!file.exists()) {
            System.out.println("Failed to find yml configuration file. Please check " + pathToYaml);
            System.exit(1);
        }

        DefaultConfigurationFactoryFactory<OxdServerConfiguration> configurationFactoryFactory = new DefaultConfigurationFactoryFactory<>();
        ConfigurationFactory<OxdServerConfiguration> configurationFactory = configurationFactoryFactory.create(OxdServerConfiguration.class, Validators.newValidatorFactory().getValidator(), Jackson.newObjectMapper(), "dw");
        return configurationFactory.build(file);
    }
 
Example #11
Source File: RpSyncServiceTest.java    From oxd with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public void setUp() throws IOException, ConfigurationException {
    configurationService.setConfiguration(TestUtils.parseConfiguration(ResourceHelpers.resourceFilePath("oxd-server-jenkins.yml")));
    persistenceService.create();
    rpService.removeAllRps();
    rpService.load();
}
 
Example #12
Source File: RpServiceTest.java    From oxd with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public void setUp() throws IOException, ConfigurationException {
    configurationService.setConfiguration(TestUtils.parseConfiguration(ResourceHelpers.resourceFilePath("oxd-server-jenkins.yml")));
    persistenceService.create();
    service.removeAllRps();
    service.load();
}
 
Example #13
Source File: RsProtectTest.java    From oxd with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public void setUp() throws IOException, ConfigurationException {
    configurationService.setConfiguration(TestUtils.parseConfiguration(ResourceHelpers.resourceFilePath("oxd-server-jenkins.yml")));
    persistenceService.create();
}