Class UrlWhitelistService

java.lang.Object
com.google.common.util.concurrent.AbstractIdleService
org.graylog2.system.urlwhitelist.UrlWhitelistService
All Implemented Interfaces:
com.google.common.util.concurrent.Service

@Singleton public class UrlWhitelistService extends com.google.common.util.concurrent.AbstractIdleService
  • Constructor Details

    • UrlWhitelistService

      @Inject public UrlWhitelistService(com.google.common.eventbus.EventBus eventBus, ClusterConfigService clusterConfigService)
  • Method Details

    • getWhitelist

      public UrlWhitelist getWhitelist()
      Gets the whitelist by reading from the cluster configuration.

      There should always be a whitelist which is created by an initial migration but if there is none, we return a disabled one, which will consider all URLs as whitelisted.

      This is because we can't easily guarantee that migrations are run before other services are started. On a system that didn't have a whitelist before, we have to add the URLs configured e.g. in lookup table data adapters to the whitelist by running a migration. If the services start before the migration has run, the configured URLs have to pass the whitelist though, otherwise the services won't be able to run properly. Once the migration has run, these URLs will have been added to whitelist and we are fine.

    • saveWhitelist

      public void saveWhitelist(UrlWhitelist whitelist)
    • isWhitelisted

      public boolean isWhitelisted(String url)
    • getEntry

      public Optional<WhitelistEntry> getEntry(String id)
    • addEntry

      public void addEntry(WhitelistEntry entry)
    • removeEntry

      public void removeEntry(String id)
    • handleWhitelistUpdated

      public void handleWhitelistUpdated(ClusterConfigChangedEvent event)
    • startUp

      protected void startUp()
      Specified by:
      startUp in class com.google.common.util.concurrent.AbstractIdleService
    • shutDown

      protected void shutDown()
      Specified by:
      shutDown in class com.google.common.util.concurrent.AbstractIdleService