Top Description Inners Fields Constructors Methods
org.hsqldb.server

public final Class ServerAcl

extends Object
Class Inheritance
Imports
java.io.BufferedReader, .File, .FileReader, .IOException, .InputStreamReader, .PrintWriter, java.net.InetAddress, .UnknownHostException, java.util.ArrayList, .List, .StringTokenizer, org.hsqldb.map.BitMap

A list of ACL permit and deny entries with a permitAccess method which tells whether candidate addresses are permitted or denied by this ACL list.

The ACL file is reloaded whenever a modification to it is detected. If you copy in a file with an older file date, you will need to touch it.

The public runtime method is permitAccess(). The public setup method is the constructor.

Each non-comment line in the ACL file must be a rule of the format:

{allow|deny} <ip_address>[/significant-bits]
For example
allow ahostname
    deny ahost.domain.com
    allow 127.0.0.1
    allow 2001:db8::/32

In order to detect bit specification mistakes, we require that non-significant bits be zero in the values. An undesirable consequence of this is, you can't use a specification like the following to mean "all of the hosts on the same network as x.admc.com":

allow x.admc.com/24
Author
Blaine Simpson (blaine dot simpson at admc dot com)
Since
2.0.0
Version
2.3.0
See Also
ServerAcl(File), permitAccess

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
public static class
private static class

Field Summary

Modifier and TypeField and Description
private List<ServerAcl.AclEntry>
private File
pack-priv static final byte[]
pack-priv static final byte[]
private long
private static ServerAcl.AclEntry
private static ServerAcl.AclEntry
private PrintWriter

Constructor Summary

AccessConstructor and Description
public
ServerAcl(File aclFile)

Method Summary

Modifier and TypeMethod and Description
public static String
colonNotation(byte[]
Unsigned byte array
uba
)

Returns: String

public static String
dottedNotation(byte[]
Unsigned byte array
uba
)

Returns: String

pack-priv synchronized void
pack-priv List<ServerAcl.AclEntry>
load()

public static void
main(String[]
String[]
sa
)

Utility method that allows interactive testing of individual ACL records, as well as the net effect of the ACL record list.

public boolean

Returns:

boolean
permitAccess
(String
String
s
)

Uses system network libraries to resolve the given String to an IP addr, then determine whether this address is permitted or denied.

public boolean
permitAccess(byte[]
byte[]
addr
)

Returns: true if access for the candidate address should be permitted, false if access should be denied.

private void
public void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

aclEntriesback to summary
private List<ServerAcl.AclEntry> aclEntries
aclFileback to summary
private File aclFile
ALL_SET_16BYTESback to summary
pack-priv static final byte[] ALL_SET_16BYTES
ALL_SET_4BYTESback to summary
pack-priv static final byte[] ALL_SET_4BYTES
lastLoadTimeback to summary
private long lastLoadTime
PROHIBIT_ALL_IPV4back to summary
private static ServerAcl.AclEntry PROHIBIT_ALL_IPV4
PROHIBIT_ALL_IPV6back to summary
private static ServerAcl.AclEntry PROHIBIT_ALL_IPV6
pwback to summary
private PrintWriter pw

Constructor Detail

ServerAclback to summary
public ServerAcl(File aclFile) throws IOException, AclFormatException

Method Detail

colonNotationback to summary
public static String colonNotation(byte[] uba)
Parameters
uba:byte[]

Unsigned byte array

Returns:String

String

dottedNotationback to summary
public static String dottedNotation(byte[] uba)
Parameters
uba:byte[]

Unsigned byte array

Returns:String

String

ensureAclsUptodateback to summary
pack-priv synchronized void ensureAclsUptodate()
loadback to summary
pack-priv List<ServerAcl.AclEntry> load() throws IOException, AclFormatException
mainback to summary
public static void main(String[] sa) throws AclFormatException, IOException

Utility method that allows interactive testing of individual ACL records, as well as the net effect of the ACL record list. Run "java -cp path/to/hsqldb.jar org.hsqldb.server.ServerAcl --help" for Syntax help.

Parameters
sa:String[]

String[]

Exceptions
AclFormatException:
when badly formatted
IOException:
when io error
permitAccessback to summary
public boolean permitAccess(String s)

Uses system network libraries to resolve the given String to an IP addr, then determine whether this address is permitted or denied. Specified name may be a numerical-based String like "1.2.3.4", a constant known to the networking libraries, or a host name to be resolved by the systems name resolution system. If the given String can't be resolved to an IP addr, false is returned.

Parameters
s:String

String

Returns:boolean

boolean

See Also
permitAccess(byte[])
permitAccessback to summary
public boolean permitAccess(byte[] addr)
Parameters
addr:byte[]

byte[]

Returns:boolean

true if access for the candidate address should be permitted, false if access should be denied.

printlnback to summary
private void println(String s)
setPrintWriterback to summary
public void setPrintWriter(PrintWriter pw)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

org.hsqldb.server back to summary

private final Class ServerAcl.AclEntry

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
public boolean
private int
private byte[]
private byte[]

Constructor Summary

AccessConstructor and Description
public
AclEntry(byte[] value, int bitBlockSize, boolean allow)

Method Summary

Modifier and TypeMethod and Description
public boolean
matches(byte[] candidate)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

allowback to summary
public boolean allow
bitBlockSizeback to summary
private int bitBlockSize
maskback to summary
private byte[] mask
valueback to summary
private byte[] value

Constructor Detail

AclEntryback to summary
public AclEntry(byte[] value, int bitBlockSize, boolean allow) throws AclFormatException

Method Detail

matchesback to summary
public boolean matches(byte[] candidate)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

validateMaskback to summary
public void validateMask() throws AclFormatException
org.hsqldb.server back to summary

public final Class ServerAcl.AclFormatException

extends Exception
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Constructor Detail

AclFormatExceptionback to summary
public AclFormatException(String s)
org.hsqldb.server back to summary

private final Class ServerAcl.InternalException

extends Exception
Class Inheritance

Constructor Summary

AccessConstructor and Description
private

Constructor Detail

InternalExceptionback to summary
private InternalException()