Class ControlPlaneAuthenticationHandlerFactory
AuthenticationHandler chain from a Configuration.
This exists so the handler chain has exactly ONE construction site that is a pure function of the
live configuration. Previously the chain was built once during server bootstrap and pushed into
HttpState; enabling control-plane authentication afterwards (via a system
property, a Configuration mutation, or PUT /mockserver/configuration) returned success
but left the handler null, and a null handler means "authenticated" — so the control
plane reported itself locked while remaining fully open. Deriving the handler from the configuration on
demand, keyed by signature(Configuration), makes every configuration route take effect.
Fail closed. build(org.mockserver.configuration.Configuration, org.mockserver.logging.MockServerLogger) returns null only when no control-plane
authentication is required. If authentication IS required but the handler cannot be constructed (bad
JWKS source, unreadable CA chain, ...) it returns a handler that rejects every request rather than
null, so a misconfiguration can never degrade into an open control plane.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRejects every control-plane request. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanauthenticationRequired(Configuration configuration) static AuthenticationHandlerbuild(Configuration configuration, MockServerLogger mockServerLogger) Build the control-plane authentication handler for the supplied configuration.static Stringsignature(Configuration configuration) A stable string capturing every configuration value that feeds handler construction.
-
Method Details
-
authenticationRequired
- Returns:
trueif any control-plane authentication mechanism is enabled
-
signature
A stable string capturing every configuration value that feeds handler construction. When this changes the cached handler must be discarded and rebuilt, which is how a runtime reconfiguration (system property,Configurationsetter, DTO, orPUT /mockserver/configuration) reaches the enforcement point. Sorted collections keep the value order-independent so a semantically identical configuration does not force a pointless rebuild. -
build
public static AuthenticationHandler build(Configuration configuration, MockServerLogger mockServerLogger) Build the control-plane authentication handler for the supplied configuration.- Returns:
nullwhen no control-plane authentication is required; otherwise a handler that enforces every enabled mechanism (chained when more than one is enabled), or a deny-all handler if construction failed
-