Class IdPPropertiesApplicationContextInitializer

    • Field Detail

      • IDP_AUTOSEARCH_PROPERTY

        @Nonnull
        @NotEmpty
        public static final String IDP_AUTOSEARCH_PROPERTY
        Property that controls auto-search for property sources.
        See Also:
        Constant Field Values
      • IDP_PROPERTIES

        @Nonnull
        public static final String IDP_PROPERTIES
        Target resource to be searched for.
        See Also:
        Constant Field Values
      • FAILFAST_PROPERTY

        @Nonnull
        public static final String FAILFAST_PROPERTY
        Property controlling whether to fail fast.
        See Also:
        Constant Field Values
      • LOG

        @Nonnull
        private static final org.slf4j.Logger LOG
        Class logger.
    • Constructor Detail

      • IdPPropertiesApplicationContextInitializer

        public IdPPropertiesApplicationContextInitializer()
    • Method Detail

      • getSearchTarget

        @Nonnull
        public String getSearchTarget()
        Get the target resource to be searched for. Defaults to IDP_PROPERTIES.
        Returns:
        the target resource to be searched for
      • getSearchLocation

        @Nonnull
        public String getSearchLocation()
        Get the well known search location. Defaults to SEARCH_LOCATION.
        Returns:
        the well known search locations
      • loadProperties

        @Nullable
        public Properties loadProperties​(@Nullable
                                         Properties sink,
                                         @Nonnull
                                         Resource resource)
        Load properties from the resource.
        Parameters:
        sink - if non-null use this instance as the target
        resource - the resource
        Returns:
        properties loaded from the resource or null if loading failed
      • getAdditionalSources

        public static Collection<String> getAdditionalSources​(@Nonnull
                                                              String searchLocation,
                                                              @Nonnull
                                                              Properties properties)
        Find out all the additional property files we need to load.
        Parameters:
        searchLocation - Where to search from
        properties - the content of idp.properties so far
        Returns:
        a collection of paths
      • loadAdditionalPropertySources

        public void loadAdditionalPropertySources​(@Nonnull
                                                  ConfigurableApplicationContext applicationContext,
                                                  @Nonnull
                                                  String searchLocation,
                                                  @Nonnull
                                                  Properties properties)
        Load additional property sources. File names of additional property sources are defined by IDP_ADDITIONAL_PROPERTY, and are resolved relative to the given search location.
        Parameters:
        applicationContext - the application context
        searchLocation - the location from which additional property sources are resolved
        properties - the properties to be filled with additional property sources
        Throws:
        ConstraintViolationException - if an error occurs loading the additional property sources and isFailFast(ConfigurableApplicationContext) is true
      • logProperties

        public void logProperties​(@Nonnull
                                  Properties properties)
        Log property names and values at debug level, suppressing properties whose name matches 'password', 'credential', 'secret', or 'salt'.
        Parameters:
        properties - the properties to log
      • appendPropertySource

        public void appendPropertySource​(@Nonnull
                                         ConfigurableApplicationContext applicationContext,
                                         @Nonnull
                                         String name,
                                         @Nonnull
                                         Properties properties)
        Add property source to the application context environment with lowest precedence.
        Parameters:
        applicationContext - the application context
        name - the name of the property source to be added to the application context
        properties - the properties added to the application context
      • setIdPHomeProperty

        public void setIdPHomeProperty​(@Nonnull
                                       String path,
                                       @Nonnull
                                       Properties properties)
        Set the IDP_HOME_PROPERTY property to the given path if not already set.
        Parameters:
        path - the property value
        properties - the properties
      • isFailFast

        public boolean isFailFast​(@Nonnull
                                  ConfigurableApplicationContext applicationContext)
        Whether we fail immediately if the config is bogus. Defaults to true. Controlled by the value of the FAILFAST_PROPERTY. This functionality is reserved for use in tests where is is usually used to allow tests to be run in the presence of partial configuration.
        Parameters:
        applicationContext - the application context
        Returns:
        whether we fail immediately if the config is faulty or incomplete.