java.lang.Object
com.aoindustries.firewalld.Service
Represents on specific service as configured in either
/usr/lib/firewalld/services/service.xml
or
/etc/firewalld/services/service.xml
.
See man 5 firewalld.service
for details.
- Author:
- AO Industries, Inc.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionService
(String name, String version, String shortName, String description, Collection<? extends IPortRange> ports, Collection<Protocol> protocols, Collection<? extends IPortRange> sourcePorts, Set<String> modules, InetAddressPrefix destinationIpv4, InetAddressPrefix destinationIpv6) Creates a new service. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Compares two services for equality.The optional longer description.getDestination
(AddressFamily addressFamily) Deprecated.getDestination
(ProtocolFamily family) Gets the destination for the givenProtocolFamily
.The optional IPv4 destination network.final InetAddressPrefix
Deprecated.Please usegetDestinationIpv4()
instead.The optional IPv6 destination network.final InetAddressPrefix
Deprecated.Please usegetDestinationIpv6()
instead.static File
getLocalServiceFile
(String name) Gets the file to use for local service.The optional set of modules.getName()
The name as used by firewalld commands and XML filenames.getPorts()
The optional set of ports.The optional set of protocols.The optional more readable short name.The optional set of source ports.static File
getSystemServiceFile
(String name) Gets the file to use for system service.Gets the set of all targets represented by this service.The optional version.int
hashCode()
static Service
loadLocalService
(String name) Loads a local service fromLOCAL_SERVICES_DIRECTORY
.static Service
loadService
(String name, File file) Loads a service from the givenFile
.static Service
loadService
(String name, InputStream in) Loads a service from anInputStream
.static Service
loadSystemService
(String name) Loads a system service fromSYSTEM_SERVICES_DIRECTORY
.void
Write this service to its local service file.toString()
-
Field Details
-
LOCAL_SERVICES_DIRECTORY
The directory containing local service files.- See Also:
-
SYSTEM_SERVICES_DIRECTORY
The directory containing system service files.- See Also:
-
EXTENSION
File extension used on service XML files.- See Also:
-
-
Constructor Details
-
Service
public Service(String name, String version, String shortName, String description, Collection<? extends IPortRange> ports, Collection<Protocol> protocols, Collection<? extends IPortRange> sourcePorts, Set<String> modules, InetAddressPrefix destinationIpv4, InetAddressPrefix destinationIpv6) Creates a new service.
-
-
Method Details
-
loadService
Loads a service from anInputStream
.- Throws:
IOException
- when cannot read or parse the service file
-
loadService
Loads a service from the givenFile
.- Returns:
- The
Service
ornull
if the service file does not exist. - Throws:
IOException
- when cannot read or parse the service file
-
getLocalServiceFile
Gets the file to use for local service. -
loadLocalService
Loads a local service fromLOCAL_SERVICES_DIRECTORY
.- Returns:
- The
Service
ornull
if the service file does not exist. - Throws:
IOException
- when cannot read or parse the service file
-
getSystemServiceFile
Gets the file to use for system service. -
loadSystemService
Loads a system service fromSYSTEM_SERVICES_DIRECTORY
.- Returns:
- The
Service
ornull
if the service file does not exist. - Throws:
IOException
- when cannot read or parse the service file
-
toString
-
equals
Compares two services for equality. All fields must be equal, with ordering not mattering for sets. -
hashCode
public int hashCode() -
getName
The name as used by firewalld commands and XML filenames. -
getVersion
The optional version. -
getShortName
The optional more readable short name. -
getDescription
The optional longer description. -
getPorts
The optional set of ports. When no ports will be an empty set.- Returns:
- an unmodifiable set of ports
-
getProtocols
The optional set of protocols. When no protocols will be an empty set.- Returns:
- an unmodifiable set of protocols
-
getSourcePorts
The optional set of source ports. When no source ports will be an empty set.- Returns:
- an unmodifiable set of source ports
-
getModules
The optional set of modules. When no modules will be an empty set.- Returns:
- an unmodifiable set of modules
-
getDestinationIpv4
The optional IPv4 destination network.- Returns:
- the IPv4 address and prefix or
null
for no IPv4 destination. - See Also:
-
getDestinationIPv4
Deprecated.Please usegetDestinationIpv4()
instead.The optional IPv4 destination network.- Returns:
- the IPv4 address and prefix or
null
for no IPv4 destination. - See Also:
-
getDestinationIpv6
The optional IPv6 destination network.- Returns:
- the IPv6 address and prefix or
null
for no IPv6 destination. - See Also:
-
getDestinationIPv6
Deprecated.Please usegetDestinationIpv6()
instead.The optional IPv6 destination network.- Returns:
- the IPv6 address and prefix or
null
for no IPv6 destination. - See Also:
-
getDestination
Deprecated.Please usegetDestination(java.net.ProtocolFamily)
as of Java 1.7.Gets the destination for the givenAddressFamily
. -
getDestination
Gets the destination for the givenProtocolFamily
. -
getTargets
Gets the set of all targets represented by this service. This may be an empty set when a service is modules-only (like tftp-client).This may have overlapping targets if the service was not previously
optimized
.- See Also:
-
saveLocalService
Write this service to its local service file.- Throws:
IOException
-
getDestination(java.net.ProtocolFamily)
as of Java 1.7.