Package com.jsgalactic.axiom.security
Record Class ClientOrigin
java.lang.Object
java.lang.Record
com.jsgalactic.axiom.security.ClientOrigin
- Record Components:
address- the client address: the transport peer, or the forwarded address when the peer is a trusted proxyscheme-httporhttpsforwarded- true when the values come from headers set by trusted proxies rather than from the connection itselfhost- the host the client addressed, as validated byTrustedProxies: a DNS name in lower case, an IPv4 literal, or an IPv6 literal in brackets; empty when no trusted proxy reported a usable oneport- the port the client addressed, 1 to 65535; empty when no trusted proxy reported a usable one (no default is inferred from the scheme)
public record ClientOrigin(InetAddress address, String scheme, boolean forwarded, Optional<String> host, OptionalInt port)
extends Record
Where a request came from, as decided by
TrustedProxies: the client's IP address, the
scheme it used and, when a trusted proxy reported them, the host and port it addressed.
Immutable.-
Constructor Summary
ConstructorsConstructorDescriptionClientOrigin(InetAddress address, String scheme, boolean forwarded) Creates an origin without a reported host or port.ClientOrigin(InetAddress address, String scheme, boolean forwarded, Optional<String> host, OptionalInt port) Validates the origin. -
Method Summary
Modifier and TypeMethodDescriptionaddress()Returns the value of theaddressrecord component.final booleanIndicates whether some other object is "equal to" this one.booleanReturns the value of theforwardedrecord component.final inthashCode()Returns a hash code value for this object.host()Returns the value of thehostrecord component.port()Returns the value of theportrecord component.scheme()Returns the value of theschemerecord component.booleansecure()Reports whether the client used HTTPS.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
ClientOrigin
public ClientOrigin(InetAddress address, String scheme, boolean forwarded, Optional<String> host, OptionalInt port) Validates the origin.- Parameters:
address- client addressscheme-httporhttpsforwarded- whether proxy headers supplied the valueshost- reported host, if anyport- reported port, if any- Throws:
IllegalArgumentException- for another scheme
-
ClientOrigin
Creates an origin without a reported host or port.- Parameters:
address- client addressscheme-httporhttpsforwarded- whether proxy headers supplied the values- Throws:
IllegalArgumentException- for another scheme
-
-
Method Details
-
secure
public boolean secure()Reports whether the client used HTTPS.- Returns:
- true for
https
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
address
Returns the value of theaddressrecord component.- Returns:
- the value of the
addressrecord component
-
scheme
Returns the value of theschemerecord component.- Returns:
- the value of the
schemerecord component
-
forwarded
public boolean forwarded()Returns the value of theforwardedrecord component.- Returns:
- the value of the
forwardedrecord component
-
host
Returns the value of thehostrecord component.- Returns:
- the value of the
hostrecord component
-
port
Returns the value of theportrecord component.- Returns:
- the value of the
portrecord component
-