|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.avalon.framework.logger.AbstractLogEnabled org.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(org.apache.lenya.ac.ItemManager itemManager,
org.apache.avalon.framework.logger.Logger logger)
Ctor. |
|
AbstractIPRange(org.apache.lenya.ac.ItemManager itemManager,
org.apache.avalon.framework.logger.Logger logger,
java.lang.String id)
Ctor. |
Method Summary | |
---|---|
boolean |
contains(org.apache.lenya.ac.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 |
protected void |
setConfigurationDirectory(java.io.File _configurationDirectory)
|
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 |
---|
compareTo, equals, getAccreditableManager, getDescription, getId, getItemManager, getName, hashCode, setDescription, setId, setName, toString |
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled |
---|
enableLogging, getLogger, setupLogger, setupLogger, setupLogger |
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, getItemManager, getName, setDescription, setName |
Methods inherited from interface org.apache.avalon.framework.logger.LogEnabled |
---|
enableLogging |
Methods inherited from interface org.apache.lenya.ac.Groupable |
---|
addedToGroup, getGroups, removedFromGroup, removeFromAllGroups |
Constructor Detail |
---|
public AbstractIPRange(org.apache.lenya.ac.ItemManager itemManager, org.apache.avalon.framework.logger.Logger logger)
itemManager
- The item manager.logger
- The logger.public AbstractIPRange(org.apache.lenya.ac.ItemManager itemManager, org.apache.avalon.framework.logger.Logger logger, java.lang.String id)
itemManager
- The item manager.logger
- The logger.id
- The IP range ID.Method Detail |
---|
public java.io.File getConfigurationDirectory()
protected void setConfigurationDirectory(java.io.File _configurationDirectory)
public abstract void save() throws org.apache.lenya.ac.AccessControlException
save
in interface org.apache.lenya.ac.IPRange
org.apache.lenya.ac.AccessControlException
- if the save failedpublic void delete() throws org.apache.lenya.ac.AccessControlException
delete
in interface org.apache.lenya.ac.IPRange
org.apache.lenya.ac.AccessControlException
- if the delete failedpublic void setNetworkAddress(java.lang.String address) throws org.apache.lenya.ac.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 org.apache.lenya.ac.IPRange
address
- a String
like "192.168.0.32"
,
"::1"
, ...
org.apache.lenya.ac.AccessControlException
- when the conversion of the String
to an
InetAddress
failedsetNetworkAddress(byte[])
public void setNetworkAddress(byte[] address) throws org.apache.lenya.ac.AccessControlException
setNetworkAddress
in interface org.apache.lenya.ac.IPRange
address
- a byte array of the length 4 or 16
org.apache.lenya.ac.AccessControlException
- when the conversion of the byte array to an InetAddress
failed.setNetworkAddress(String)
public java.net.InetAddress getNetworkAddress()
getNetworkAddress
in interface org.apache.lenya.ac.IPRange
InetAddress
representing the network addresspublic void setSubnetMask(java.lang.String mask) throws org.apache.lenya.ac.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 org.apache.lenya.ac.IPRange
mask
- a String
like "255.255.255.0"
org.apache.lenya.ac.AccessControlException
- when the conversion of the String to an
InetAddress
failed.setSubnetMask(byte[])
public void setSubnetMask(byte[] mask) throws org.apache.lenya.ac.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 org.apache.lenya.ac.IPRange
mask
- A byte array of the length 4.
org.apache.lenya.ac.AccessControlException
- when the conversion of the byte array to an InetAddress
failed.setSubnetMask(String)
public java.net.InetAddress getSubnetMask()
getSubnetMask
in interface org.apache.lenya.ac.IPRange
public static boolean isValidSubnet(java.net.InetAddress networkAddress, java.net.InetAddress subnetMask)
networkAddress
- The network address.subnetMask
- The subnet mask.
public boolean contains(org.apache.lenya.ac.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 org.apache.lenya.ac.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 |