Class MaskIPV4Address

java.lang.Object
com.github.eventmanager.processors.MaskIPV4Address
All Implemented Interfaces:
Processor

public class MaskIPV4Address extends Object implements Processor
The MaskIPV4Address class implements the Processor interface and provides methods to mask IPv4 addresses in different event formats (KV, JSON, XML). The class also provides methods to check if an IP address is in a CIDR range and to convert an IP address to a long value. The class uses a list of CIDR ranges to mask the IP addresses.
  • Constructor Details

    • MaskIPV4Address

      public MaskIPV4Address(List<String> ipAddressRanges)
  • Method Details

    • processKV

      public String processKV(String event)
      Processes a key-value formatted event and masks any IPv4 addresses that match the CIDR ranges.
      Specified by:
      processKV in interface Processor
      Parameters:
      event - the key-value formatted event string.
      Returns:
      the event string with masked IPv4 addresses.
    • processJSON

      public String processJSON(String event)
      Processes a JSON formatted event and masks any IPv4 addresses that match the CIDR ranges.
      Specified by:
      processJSON in interface Processor
      Parameters:
      event - the JSON formatted event string.
      Returns:
      the event string with masked IPv4 addresses.
    • processXML

      public String processXML(String event)
      Processes an XML formatted event and masks any IPv4 addresses that match the CIDR ranges.
      Specified by:
      processXML in interface Processor
      Parameters:
      event - the XML formatted event string.
      Returns:
      the event string with masked IPv4 addresses.
    • isIpInCidr

      public static boolean isIpInCidr(String ip, String cidr)
      Checks if the given IP address is in the specified CIDR range.
      Parameters:
      ip - the IP address to check.
      cidr - the CIDR range to check against.
      Returns:
      true if the IP address is in the CIDR range, false otherwise.