Class AuthenticationResult

java.lang.Object
org.mockserver.authentication.AuthenticationResult

public class AuthenticationResult extends Object
Immutable outcome of authenticating a control-plane request, carrying not just the boolean decision but the VERIFIED principal, the source of that verification, and a redaction-safe subset of token claims and scopes.

This is the richer return type for AuthenticationHandler.authenticate(org.mockserver.model.HttpRequest). The legacy boolean SPI (AuthenticationHandler.controlPlaneRequestAuthenticated(org.mockserver.model.HttpRequest)) is preserved and adapted via a default method, so existing (and third-party) handlers keep working unchanged and the control plane behaves byte-for-byte identically when no enriched handler is configured.

Construct only via the authenticated / unauthenticated() factories; all collections are wrapped unmodifiable and never null.

  • Method Details

    • authenticated

      public static AuthenticationResult authenticated(String principal, String principalSource, Map<String,Object> claims, Set<String> scopes)
      An authenticated result.
      Parameters:
      principal - the verified principal (e.g. the sub claim), or null for an authenticated-but-anonymous handler (e.g. mTLS-only)
      principalSource - how the principal was verified: "verified-oidc" / "verified-mtls" / "verified-jwt" / "none"
      claims - a redaction-safe subset of token claims (NEVER the raw token); may be empty, never null
      scopes - normalised granted scopes; may be empty, never null
    • unauthenticated

      public static AuthenticationResult unauthenticated()
    • isAuthenticated

      public boolean isAuthenticated()
    • getPrincipal

      public String getPrincipal()
    • getPrincipalSource

      public String getPrincipalSource()
    • getClaims

      public Map<String,Object> getClaims()
    • getScopes

      public Set<String> getScopes()