Class OAuthClientMetadataPolicy.Builder
java.lang.Object
com.revetsec.oauth.server.OAuthClientMetadataPolicy.Builder
- Enclosing class:
OAuthClientMetadataPolicy
@NotThreadSafe
@CheckReturnValue
public static final class OAuthClientMetadataPolicy.Builder
extends Object
Builds an enabled policy; null property values reset defaults, except resolver and cache null
clear required properties. There is no implicit storage backend.
- Since:
- 1.0.0
- Author:
- Mark Allen
-
Method Summary
Modifier and TypeMethodDescriptionSets the trusted resolver; null clears it and makes build fail.allowedOrigins(@Nullable Set<@NonNull URI> value) Sets a complete exact origin restriction snapshot.build()Builds a complete immutable enabled configuration without invoking the resolver.Selects application storage.Sets maximumConcurrentFetches, bounded from1through64, inclusive.maximumDocumentBytes(@Nullable Integer value) Sets maximumDocumentBytes, bounded from1024through5120, inclusive.maximumFreshness(@Nullable Duration value) Sets maximumFreshness, bounded fromDuration.ZEROthroughDuration.ofHours(1), inclusive.Sets maximumResolvedAddresses, bounded from1through64, inclusive.
-
Method Details
-
addressResolver
@CheckReturnValue public @NonNull OAuthClientMetadataPolicy.Builder addressResolver(@Nullable OAuthClientMetadataAddressResolver value) Sets the trusted resolver; null clears it and makes build fail.- Parameters:
value- the resolver, or null to clear- Returns:
- this builder
- Since:
- 1.0.0
-
cache
@CheckReturnValue public @NonNull OAuthClientMetadataPolicy.Builder cache(@Nullable OAuthClientMetadataCache value) Selects application storage. Null clears this required dependency and makes build fail; build invokes no provider method. Select an in-memory backend explicitly throughInMemoryOAuthClientMetadataCache.fromMaximumEntries(Integer)when local storage is intended. Shared providers must honor atomic comparison, namespaces, record bounds and remaining budgets.- Parameters:
value- the selected storage, or null to clear- Returns:
- this builder
- Since:
- 1.0.0
-
allowedOrigins
@CheckReturnValue public @NonNull OAuthClientMetadataPolicy.Builder allowedOrigins(@Nullable Set<@NonNull URI> value) Sets a complete exact origin restriction snapshot. Null resets all eligible public HTTPS origins; an empty set denies every origin. Origins have HTTPS scheme, host and optional port only, without path, query, fragment or userinfo. At most 4096 origins and 128 KiB aggregate text are accepted.- Parameters:
value- the restriction, or null to reset- Returns:
- this builder
- Throws:
IllegalArgumentException- if a supplied origin or aggregate is invalidNullPointerException- if a set element is null- Since:
- 1.0.0
-
maximumDocumentBytes
@CheckReturnValue public @NonNull OAuthClientMetadataPolicy.Builder maximumDocumentBytes(@Nullable Integer value) Sets maximumDocumentBytes, bounded from1024through5120, inclusive.- Parameters:
value- the limit, or null to reset to5120- Returns:
- this builder
- Throws:
IllegalArgumentException- if outside the allowed interval- Since:
- 1.0.0
-
maximumFreshness
@CheckReturnValue public @NonNull OAuthClientMetadataPolicy.Builder maximumFreshness(@Nullable Duration value) Sets maximumFreshness, bounded fromDuration.ZEROthroughDuration.ofHours(1), inclusive.- Parameters:
value- the limit, or null to reset toDuration.ofSeconds(300)- Returns:
- this builder
- Throws:
IllegalArgumentException- if outside the allowed interval- Since:
- 1.0.0
-
maximumConcurrentFetches
@CheckReturnValue public @NonNull OAuthClientMetadataPolicy.Builder maximumConcurrentFetches(@Nullable Integer value) Sets maximumConcurrentFetches, bounded from1through64, inclusive. The limit bounds active fetches; waiting uses the original operation deadline without creating workers. At least two slots are needed to reserve one from authorization requests for credential transitions.- Parameters:
value- the limit, or null to reset to8- Returns:
- this builder
- Throws:
IllegalArgumentException- if outside the allowed interval- Since:
- 1.0.0
-
maximumResolvedAddresses
@CheckReturnValue public @NonNull OAuthClientMetadataPolicy.Builder maximumResolvedAddresses(@Nullable Integer value) Sets maximumResolvedAddresses, bounded from1through64, inclusive.- Parameters:
value- the limit, or null to reset to16- Returns:
- this builder
- Throws:
IllegalArgumentException- if outside the allowed interval- Since:
- 1.0.0
-
build
Builds a complete immutable enabled configuration without invoking the resolver.- Returns:
- the configured policy
- Throws:
IllegalStateException- if the required resolver or cache is missing- Since:
- 1.0.0
-