|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.lenya.ac.impl.AbstractItem
org.apache.lenya.ac.impl.AbstractGroupable
org.apache.lenya.ac.impl.AbstractIPRange
public abstract class AbstractIPRange
A range of IP addresses, expressed by a network address and a subnet mask.
Note: this class does not enforce that the network address and the subnet mask have the same size
(i.e. either both IPv4 or both IPv6 addresses). If the the network address and subnet mask have
different sizes, the range does not contain any hosts, that is contains(Machine)
will
always return false
.
Constructor Summary | |
---|---|
AbstractIPRange()
Initializes the the IP range with the local host (127.0.0.1/24 for IPv4, ::1/128 for IPv6). |
|
AbstractIPRange(java.lang.String id)
Ctor. |
Method Summary | |
---|---|
boolean |
contains(Machine machine)
Checks if this IP range contains a certain machine. |
void |
delete()
Delete an IP range |
java.io.File |
getConfigurationDirectory()
Returns the configuration directory. |
java.net.InetAddress |
getNetworkAddress()
Returns the network address. |
java.net.InetAddress |
getSubnetMask()
Returns the subnet mask. |
static boolean |
isValidSubnet(java.net.InetAddress networkAddress,
java.net.InetAddress subnetMask)
Deprecated. This method is currently not implemented, probably not necessary.and could be removed in the future. Therefore it should not be used. |
abstract void |
save()
Save the IP range |
void |
setConfigurationDirectory(java.io.File configurationDirectory)
Sets the configuration directory of this item. |
void |
setNetworkAddress(byte[] address)
Sets the network address. |
void |
setNetworkAddress(java.lang.String address)
Sets the network address. |
void |
setSubnetMask(byte[] mask)
Sets the subnet mask. |
void |
setSubnetMask(java.lang.String mask)
Sets the subnet mask. |
Methods inherited from class org.apache.lenya.ac.impl.AbstractGroupable |
---|
addedToGroup, getAccreditables, getGroups, removedFromGroup, removeFromAllGroups |
Methods inherited from class org.apache.lenya.ac.impl.AbstractItem |
---|
equals, getDescription, getId, getName, hashCode, isValidId, setDescription, setId, setName, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.apache.lenya.ac.Accreditable |
---|
getAccreditables |
Methods inherited from interface org.apache.lenya.ac.Item |
---|
configure, getDescription, getId, getName, setDescription, setName |
Methods inherited from interface org.apache.lenya.ac.Groupable |
---|
addedToGroup, getGroups, removedFromGroup, removeFromAllGroups |
Constructor Detail |
---|
public AbstractIPRange()
public AbstractIPRange(java.lang.String id)
id
- The IP range ID.Method Detail |
---|
public java.io.File getConfigurationDirectory()
public void setConfigurationDirectory(java.io.File configurationDirectory)
Item
setConfigurationDirectory
in interface Item
configurationDirectory
- The configuration directory.Item.setConfigurationDirectory(java.io.File)
public abstract void save() throws AccessControlException
AccessControlException
- if the save failedpublic void delete() throws AccessControlException
AccessControlException
- if the delete failedpublic void setNetworkAddress(java.lang.String address) throws AccessControlException
"129.168.0.32"
, numeric IPv6 addresses like
"1080::8:800:200C:417A"
as well as hostnames (if DNS resolution is available)
like "localhost"
or "www.apache.com"
.
setNetworkAddress
in interface IPRange
address
- a String
like "192.168.0.32"
,
"::1"
, ...
AccessControlException
- when the conversion of the String
to an
InetAddress
failedsetNetworkAddress(byte[])
public void setNetworkAddress(byte[] address) throws AccessControlException
setNetworkAddress
in interface IPRange
address
- a byte array of the length 4 or 16
AccessControlException
- when the conversion of the byte array to an InetAddress
failed.setNetworkAddress(String)
public java.net.InetAddress getNetworkAddress()
getNetworkAddress
in interface IPRange
InetAddress
representing the network addresspublic void setSubnetMask(java.lang.String mask) throws AccessControlException
setNetworkAddress(String)
for the allowed formats of the
mask
string. (However, the hostname format will usually not be of much use for
setting the mask.)
Only valid subnet masks are accepted, for which the binary representation is a sequence of
1-bits followed by a sequence of 0-bits. For example "255.128.0.0"
is valid
while "255.128.0.1"
is not.
setSubnetMask
in interface IPRange
mask
- a String
like "255.255.255.0"
AccessControlException
- when the conversion of the String to an
InetAddress
failed.setSubnetMask(byte[])
public void setSubnetMask(byte[] mask) throws AccessControlException
Only valid subnet masks are accepted, for which the binary representation is a sequence of
1-bits followed by a sequence of 0-bits. For example { 255, 128, 0, 0 }
is
valid while { 255, 128, 0, 1 }
is not.
setSubnetMask
in interface IPRange
mask
- A byte array of the length 4.
AccessControlException
- when the conversion of the byte array to an InetAddress
failed.setSubnetMask(String)
public java.net.InetAddress getSubnetMask()
getSubnetMask
in interface IPRange
public static boolean isValidSubnet(java.net.InetAddress networkAddress, java.net.InetAddress subnetMask)
networkAddress
- The network address.subnetMask
- The subnet mask.
public boolean contains(Machine machine)
Note: if the network address and the subnet mask of this IP range have different sizes (i.e.
one is IPv4 and one is IPv6), this method will always return false
, no matter
what machine has been specified!
Further, if the machine address and the IP range (i.e. network address and subnet mask) have
different sizes, the method will return false
. (In other words: an IPv4 range
never contains an IPv6 address and the other way round.)
Note that the above can lead to confusion. For example the local subnet in IPv4 (
127.0.0.0/8
) will not contain the localhost in IPv6 (
::1
), and the localhost in IPv4 (127.0.0.1
) will not
be contained in the local subnet in IPv6 (::1/128
).
contains
in interface IPRange
machine
- the machine to check for
InetAddressUtil.contains(java.net.InetAddress, java.net.InetAddress, java.net.InetAddress)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |