WinFirewall.Rule (install4j API)
Description: declaration: package: com.install4j.api.windows, class: WinFirewall, class: Rule

Package com.install4j.api.windows

# Class WinFirewall.Rule

java.lang.Object
com.install4j.api.windows.WinFirewall.Rule

Enclosing class:
  `WinFirewall`

public static class WinFirewall.Rule extends Object
A Windows firewall rule.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Rule(String executablePath, String ruleName, WinFirewall.RuleDirection ruleDirection, WinFirewall.NetworkProtocol networkProtocol)`
  Create a rule with the minimally required parameters.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `WinFirewall.Rule`
  `setAvoidPublicProfile(boolean avoidPublicProfile)`
  Only add for public profile if public profile is the only currently active profile.
  `WinFirewall.Rule`
  `setDescription(String description)`
  An optional description for this rule.
  `WinFirewall.Rule`
  `setEnabled(boolean enabled)`
  If this rule should be enabled when created.
  `WinFirewall.Rule`
  `setGroupName(String groupName)`
  An optional group name for this rule.
  `WinFirewall.Rule`
  `setLocalAddresses(String localAddresses)`
  One or more comma-delimited tokens specifying the local addresses from which the application can listen for traffic.
  `WinFirewall.Rule`
  `setLocalPorts(String localPorts)`
  A list of local port numbers or port ranges separated by commas.
  `WinFirewall.Rule`
  `setOnlyActiveProfiles(boolean onlyActiveProfiles)`
  Only add for profiles that are currently active.
  `WinFirewall.Rule`
  `setProfileTypes(Collection<WinFirewall.ProfileType> profileTypes)`
  The profiles this rule should be added for.
  `WinFirewall.Rule`
  `setRemoteAddresses(String remoteAddresses)`
  One or more comma-delimited tokens specifying the remote addresses from which the application can listen for traffic.
  `WinFirewall.Rule`
  `setRemotePorts(String remotePorts)`
  A list of remote port numbers or port ranges separated by commas.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### Rule

    public Rule(@NotNull String executablePath, @NotNull String ruleName, @NotNull WinFirewall.RuleDirection ruleDirection, @NotNull WinFirewall.NetworkProtocol networkProtocol)
    Create a rule with the minimally required parameters.
    Parameters:
      `executablePath` - The path to the executable this rule is created for.
      `ruleName` - The name of the firewall rule.
      `ruleDirection` - If the rule is an incoming or outgoing rule.
      `networkProtocol` - If this is a rule for TCP or UDP.

- ## Method Details

  - ### setGroupName

    public WinFirewall.Rule setGroupName(String groupName)
    An optional group name for this rule.
    Parameters:
      `groupName` - the group name
    Returns:
      this rule

  - ### setDescription

    public WinFirewall.Rule setDescription(String description)
    An optional description for this rule.
    Parameters:
      `description` - the description
    Returns:
      this rule

  - ### setLocalPorts

    public WinFirewall.Rule setLocalPorts(String localPorts)
    A list of local port numbers or port ranges separated by commas.

    Example: 80, 8080, 5000-5100

    The default is any ports.

    Parameters:
      `localPorts` - the port list
    Returns:
      this rule

  - ### setLocalAddresses

    public WinFirewall.Rule setLocalAddresses(String localAddresses)
    One or more comma-delimited tokens specifying the local addresses from which the application can listen for traffic. Valid tokens include:
    - "*" or an empty value indicates any local address. If present, this must be the only token included.
    - A valid IPv4 or IPv6 address.
    - A subnet can be specified using either the subnet mask or network prefix notation. If neither a subnet mask nor a network prefix is specified, the subnet mask defaults to 255.255.255.255.
    - An IPv4 or IPv6 address range in the format of "start address - end address" with no spaces included.

    The default value is "*".

    Parameters:
      `localAddresses` - the address string
    Returns:
      this rule

  - ### setRemotePorts

    public WinFirewall.Rule setRemotePorts(String remotePorts)
    A list of remote port numbers or port ranges separated by commas.

    Example: 80, 8080, 5000-5100

    The default is any ports.

    Parameters:
      `remotePorts` - the port list
    Returns:
      this rule

  - ### setRemoteAddresses

    public WinFirewall.Rule setRemoteAddresses(String remoteAddresses)
    One or more comma-delimited tokens specifying the remote addresses from which the application can listen for traffic. Valid tokens include:
    - "*" or an empty value indicates any remote address. If present, this must be the only token included.
    - A valid IPv4 or IPv6 address.
    - A subnet can be specified using either the subnet mask or network prefix notation. If neither a subnet mask nor a network prefix is specified, the subnet mask defaults to 255.255.255.255.
    - An IPv4 or IPv6 address range in the format of "start address - end address" with no spaces included.
    - "Defaultgateway"
    - "DHCP"
    - "DNS"
    - "WINS"
    - "LocalSubnet" indicates any local address on the local subnet. This token is not case-sensitive.

    The default value is "*".

    Parameters:
      `remoteAddresses` - the address string
    Returns:
      this rule

  - ### setProfileTypes

    public WinFirewall.Rule setProfileTypes(Collection<WinFirewall.ProfileType> profileTypes)
    The profiles this rule should be added for.

    The default value is `ProfileType.DOMAIN` and `ProfileType.PRIVATE`

    Parameters:
      `profileTypes` - a collection of profile types
    Returns:
      this rule

  - ### setOnlyActiveProfiles

    public WinFirewall.Rule setOnlyActiveProfiles(boolean onlyActiveProfiles)
    Only add for profiles that are currently active.

    The default value is `false`.

    Parameters:
      `onlyActiveProfiles` - the value
    Returns:
      this object

  - ### setAvoidPublicProfile

    public WinFirewall.Rule setAvoidPublicProfile(boolean avoidPublicProfile)
    Only add for public profile if public profile is the only currently active profile.

    The default value is `false`.

    Parameters:
      `avoidPublicProfile` - the value
    Returns:
      this object

  - ### setEnabled

    public WinFirewall.Rule setEnabled(boolean enabled)
    If this rule should be enabled when created.

    The default value is `true`.

    Parameters:
      `enabled` - the value
    Returns:
      this object