Interface EarlyDataPolicy
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Replay. 0-RTT data has no protection against replay (RFC 8446 sections 2.3 and 8): an
attacker who captures a client's first flight can send it again, and a server that accepts it
acts on the early data twice. The default, antiReplay(), narrows this as RFC 8446
section 8 describes: it accepts a ticket's early data at most once, and only while the client's
idea of the ticket's age agrees with the server's within a short window, so a first flight
replayed later fails the age check and one replayed sooner hits the single-use record. That
record lives in one process: servers behind one address that share a ticket key but not the
record can each accept a replay once. Even then, early data should only carry requests that are
safe to repeat, which is the application's call; RFC 8470 describes it for HTTP. Compose an
application veto with and(EarlyDataPolicy).
Policies are called on the thread that drives the handshake, so they should be quick and must be thread-safe.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final EarlyDataPolicyAccepts any early data the protocol allows, with no protection against replay.static final EarlyDataPolicyAccepts no early data. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaccept(EarlyDataAttempt attempt) Whether to accept a client's early data.default EarlyDataPolicyand(EarlyDataPolicy other) A policy that accepts only what both this one and another accept.static EarlyDataPolicyThe default anti-replay policy: a ticket age window of 10 seconds and a single-use record of up to 100000 tickets.static EarlyDataPolicyantiReplay(Duration window, int maxEntries) An anti-replay policy.
-
Field Details
-
REJECT
Accepts no early data. -
ACCEPT_ALL
Accepts any early data the protocol allows, with no protection against replay. For tests.
-
-
Method Details
-
accept
Whether to accept a client's early data.- Parameters:
attempt- what the client offers- Returns:
- true to accept it
-
and
A policy that accepts only what both this one and another accept. The other is asked first, and this one only if the other accepts: inantiReplay().and(veto)the anti-replay record notes a ticket only when the application's veto lets it through.- Parameters:
other- the second policy- Returns:
- the combined policy
-
antiReplay
The default anti-replay policy: a ticket age window of 10 seconds and a single-use record of up to 100000 tickets.- Returns:
- a new policy with its own record
-
antiReplay
An anti-replay policy.- Parameters:
window- how far the client's and the server's ticket ages may differ; the single-use record keeps each ticket for twice this longmaxEntries- the most tickets the record holds; when it is full, early data is refused- Returns:
- a new policy with its own record
-