Class InetAddressMatchers.Builder

java.lang.Object
org.springframework.security.web.util.matcher.InetAddressMatchers.Builder
Enclosing class:
InetAddressMatchers

public static final class InetAddressMatchers.Builder extends Object
A builder for constructing InetAddressMatcher instances with various matching rules.
Since:
7.1
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • includeAddresses

      public InetAddressMatchers.Builder includeAddresses(List<String> addresses)
      Adds an include list matcher that permits only the specified addresses.
      Parameters:
      addresses - the list of IP address patterns to include (cannot be null or empty)
      Returns:
      this builder for method chaining
      Throws:
      IllegalArgumentException - if addresses is null or empty
    • excludeAddresses

      public InetAddressMatchers.Builder excludeAddresses(List<String> addresses)
      Adds an exclude list matcher that blocks the specified addresses.
      Parameters:
      addresses - the list of IP address patterns to exclude (cannot be null or empty)
      Returns:
      this builder for method chaining
      Throws:
      IllegalArgumentException - if addresses is null or empty
    • matchAll

      public InetAddressMatchers.Builder matchAll(InetAddressMatcher... matchers)
      Adds custom matchers to the matcher chain. All matchers must match for an address to be permitted.
      Parameters:
      matchers - the custom InetAddressMatcher instances to add (cannot be null or empty)
      Returns:
      this builder for method chaining
      Throws:
      IllegalArgumentException - if matchers is null or empty
    • reportOnly

      public InetAddressMatchers.Builder reportOnly()
      Configures the matcher to operate in report-only mode. In this mode, matching logic is evaluated and logged, but all addresses are allowed regardless of match results.
      Returns:
      this builder for method chaining
    • build

      public InetAddressMatcher build()
      Builds the configured InetAddressMatcher.
      Returns:
      the constructed InetAddressMatcher