Class InMemoryPendingAuthorizationStore
java.lang.Object
com.revetsec.oauth.InMemoryPendingAuthorizationStore
- All Implemented Interfaces:
PendingAuthorizationStore
@ThreadSafe
public final class InMemoryPendingAuthorizationStore
extends Object
implements PendingAuthorizationStore
A bounded, single-process pending-authorization store. It starts no worker thread; expiry is removed lazily on
saves and consumes. An observed backward clock step cannot revive a record past an earlier observed expiry.
A full store refuses a new login without evicting another live login. Use a durable shared
PendingAuthorizationStore when callbacks may land on other nodes or after a restart.- Since:
- 1.0.0
- Author:
- Mark Allen
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classConfigures the store. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Starts a builder with bounded defaults.Atomically removes the matching record, including an expired one.Constructs a store with the default limits and UTC system clock.save(@NonNull String browserBinding, @NonNull String state, @NonNull String opaqueRecord, @NonNull Instant expiresAt, @NonNull Duration remaining) Saves a record whose expiry is after now and no more than 60 minutes away.Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface PendingAuthorizationStore
consume, save
-
Method Details
-
builder
Starts a builder with bounded defaults.- Returns:
- the builder
- Since:
- 1.0.0
-
fromDefaults
Constructs a store with the default limits and UTC system clock.- Returns:
- the store
- Since:
- 1.0.0
-
save
@CheckReturnValue public @NonNull PendingAuthorizationSaveResult save(@NonNull String browserBinding, @NonNull String state, @NonNull String opaqueRecord, @NonNull Instant expiresAt, @NonNull Duration remaining) Saves a record whose expiry is after now and no more than 60 minutes away. No live record is evicted.- Specified by:
savein interfacePendingAuthorizationStore- Parameters:
browserBinding- the browser-specific bindingstate- the authorization stateopaqueRecord- the opaque recordexpiresAt- its exact expiryremaining- positive time left for this operation- Returns:
- the fixed storage outcome
- Since:
- 1.0.0
-
consume
public @NonNull Optional<@NonNull String> consume(@NonNull String browserBinding, @NonNull String state, @NonNull Duration remaining) Atomically removes the matching record, including an expired one.- Specified by:
consumein interfacePendingAuthorizationStore- Parameters:
browserBinding- the browser-specific bindingstate- the authorization stateremaining- positive time left for this operation- Returns:
- the record when it was still live
- Since:
- 1.0.0
-