Class RemoteAddressValidator
java.lang.Object
org.apache.activemq.util.RemoteAddressValidator
Validates a socket's remote IP address against configurable allow and deny
lists expressed in CIDR notation (e.g. "192.168.1.0/24", "10.0.0.0/8").
Evaluation order:
- If the address matches any deny entry → DENIED.
- If the allow list is non-empty and the address matches any allow entry → ALLOWED.
- If the allow list is empty (no restrictions) → ALLOWED.
- Otherwise → DENIED (not in allow list).
Both IPv4 and IPv6 addresses are supported. IPv4-mapped IPv6 addresses
(e.g. ::ffff:192.168.1.1) are automatically normalized to their
IPv4 equivalent before matching, so a single IPv4 CIDR rule covers both
plain IPv4 connections and dual-stack sockets that represent the same peer.
Build the lists with CidrListLoader, which accepts a comma separated
string or a file: URI and reports entries it had to skip.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanRuns a single IP address or a whole CIDR block through the allow/deny decision.booleanisAllowed(InetAddress address) Returnstrueif the givenInetAddresspasses the allow/deny policy.booleanReturnstrueif the remote address of the given socket is allowed.
-
Constructor Details
-
RemoteAddressValidator
-
-
Method Details
-
isAllowed
Returnstrueif the remote address of the given socket is allowed.- Throws:
IllegalArgumentException- if the socket is not connected or has no remote address.
-
isAllowed
Returnstrueif the givenInetAddresspasses the allow/deny policy. -
isAllowed
Runs a single IP address or a whole CIDR block through the allow/deny decision. A single address gets exactly the decision an accepted socket would: deny entries first, then the allow list, an empty allow list permitting, an IPv4-mapped IPv6 address normalised first. A block is judged as a whole: it is allowed when an allow entry covers it (or the allow list is empty) and no deny entry covers the entire block, so a few denied hosts carved out of an allowed network do not change its answer. Host names are rejected, never resolved.- Throws:
IllegalArgumentException- if the value is neither an IP literal nor a CIDR block
-