Package com.install4j.api.windows
Class WinFirewall.Rule
java.lang.Object
com.install4j.api.windows.WinFirewall.Rule
- Enclosing class:
WinFirewall
A Windows firewall rule.
-
Constructor Summary
ConstructorDescriptionRule
(String executablePath, String ruleName, WinFirewall.RuleDirection ruleDirection, WinFirewall.NetworkProtocol networkProtocol) Create a rule with the minimally required parameters. -
Method Summary
Modifier and TypeMethodDescriptionsetAvoidPublicProfile
(boolean avoidPublicProfile) Only add for public profile if public profile is the only currently active profile.setDescription
(String description) An optional description for this rule.setEnabled
(boolean enabled) If this rule should be enabled when created.setGroupName
(String groupName) An optional group name for this rule.setLocalAddresses
(String localAddresses) One or more comma-delimited tokens specifying the local addresses from which the application can listen for traffic.setLocalPorts
(String localPorts) A list of local port numbers or port ranges separated by commas.setOnlyActiveProfiles
(boolean onlyActiveProfiles) Only add for profiles that are currently active.setProfileTypes
(Collection<WinFirewall.ProfileType> profileTypes) The profiles this rule should be added for.setRemoteAddresses
(String remoteAddresses) One or more comma-delimited tokens specifying the remote addresses from which the application can listen for traffic.setRemotePorts
(String remotePorts) A list of remote port numbers or port ranges separated by commas.
-
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
An optional group name for this rule.- Parameters:
groupName
- the group name- Returns:
- this rule
-
setDescription
An optional description for this rule.- Parameters:
description
- the description- Returns:
- this rule
-
setLocalPorts
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
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 not 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
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
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 not 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
The profiles this rule should be added for.The default value is
ProfileType.DOMAIN
andProfileType.PRIVATE
- Parameters:
profileTypes
- a collection of profile types- Returns:
- this rule
-
setOnlyActiveProfiles
Only add for profiles that are currently active.The default value is
false
.- Parameters:
onlyActiveProfiles
- the value- Returns:
- this object
-
setAvoidPublicProfile
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
If this rule should be enabled when created.The default value is
true
.- Parameters:
enabled
- the value- Returns:
- this object
-