Interface OAuthTokenValidationFactory
public interface OAuthTokenValidationFactory
Factory for validating incoming OAuth 2.0 bearer tokens (JWT and opaque).
JWT tokens are validated locally via JWKS (signature, expiry, audience, issuer). Opaque tokens are validated via RFC
7662 introspection.
The camel-oauth component provides the default implementation. Runtime-specific integrations can provide their own
implementation backed by their native security stack.
Implementations that call identity-provider infrastructure, such as OIDC discovery, JWKS endpoints, or RFC 7662
introspection endpoints, should apply bounded connect/read timeouts and avoid unbounded blocking in
request-processing paths.
- Since:
- 4.21
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault voidvalidateConfiguration(CamelContext context) Validates the default token validation profile without validating a token.default voidvalidateConfiguration(CamelContext context, String profileName) Validates a named token validation profile without validating a token.voidValidates explicit token validation configuration without validating a token.default OAuthTokenValidationResultvalidateToken(CamelContext context, String token) Validates a bearer token using the default (unnamed) profile.default OAuthTokenValidationResultvalidateToken(CamelContext context, String profileName, String token) Validates a bearer token using a named profile from Camel properties.validateToken(OAuthTokenValidationConfig config, String token) Validates a bearer token using explicit configuration.
-
Field Details
-
FACTORY
-
-
Method Details
-
validateToken
Validates a bearer token using explicit configuration. The error contract distinguishes three failure modes:- Configuration errors (missing JWKS endpoint, missing client credentials) throw
IllegalArgumentException. These indicate a setup problem that the operator must fix. - Validation failures (expired token, invalid signature, wrong issuer) return
OAuthTokenValidationResult.invalid(OAuthTokenValidationResult.ErrorCode, String). These indicate a rejected bearer token. - Infrastructure failures (network timeout, JWKS fetch failure) throw runtime exceptions. These indicate a transient or infrastructure problem.
- Parameters:
config- the token validation configurationtoken- the bearer token string to validate- Returns:
- the validation result (never null)
- Throws:
IllegalArgumentException- if required configuration is missing- Since:
- 4.21
- Configuration errors (missing JWKS endpoint, missing client credentials) throw
-
validateToken
default OAuthTokenValidationResult validateToken(CamelContext context, String profileName, String token) Validates a bearer token using a named profile from Camel properties. Properties are resolved fromcamel.oauth.<profileName>.*:camel.oauth.<profileName>.base-uri— base URL for OIDC auto-discovery from/.well-known/openid-configurationcamel.oauth.<profileName>.jwks-endpoint— JWKS URL for JWT validationcamel.oauth.<profileName>.introspection-endpoint— RFC 7662 introspection URL for opaque tokenscamel.oauth.<profileName>.introspection-client-id— client ID for introspection; falls back toclient-idcamel.oauth.<profileName>.introspection-client-secret— client secret for introspection; falls back toclient-secretcamel.oauth.<profileName>.expected-issuer— expected issuer claimcamel.oauth.<profileName>.expected-audience— comma-separated accepted audience claim valuescamel.oauth.<profileName>.expected-token-type— expected JWTtypheader, for exampleat+jwtcamel.oauth.<profileName>.clock-skew-seconds— clock skew leeway in seconds (default: 0)camel.oauth.<profileName>.jwks-cache-ttl-seconds— JWKS cache TTL in seconds (default: 600)camel.oauth.<profileName>.oidc-discovery-cache-ttl-seconds— OIDC discovery cache TTL in seconds (default: 600)camel.oauth.<profileName>.connect-timeout-seconds— outbound HTTP connect timeout in seconds (default: 5)camel.oauth.<profileName>.read-timeout-seconds— outbound HTTP read timeout in seconds (default: 10)camel.oauth.<profileName>.require-expiration— whether JWTs must containexp(default: true)camel.oauth.<profileName>.allowed-jws-algorithms— comma-separated JWS algorithm allowlistcamel.oauth.<profileName>.allow-missing-audience— opt out of requiring an expected audience (default: false)camel.oauth.<profileName>.allow-missing-issuer— opt out of requiring an expected issuer (default: false)camel.oauth.<profileName>.allow-insecure-http— allow plain HTTP IdP endpoints for local development (default: false)
introspection-client-id/introspection-client-secretor theclient-id/client-secretfallback properties.- Parameters:
context- the CamelContext to resolve properties fromprofileName- the named profile (e.g., "keycloak", "azure")token- the bearer token string to validate- Returns:
- the validation result (never null)
- Throws:
RuntimeException- if required properties are missing or an infrastructure error occurs- Since:
- 4.21
-
validateToken
Validates a bearer token using the default (unnamed) profile. Properties are resolved fromcamel.oauth.*directly (backward compatible with existing single-IdP configuration).- Parameters:
context- the CamelContext to resolve properties fromtoken- the bearer token string to validate- Returns:
- the validation result (never null)
- Throws:
RuntimeException- if required properties are missing or an infrastructure error occurs- Since:
- 4.21
-
validateConfiguration
Validates explicit token validation configuration without validating a token. Implementations should fail fast for static configuration errors such as missing endpoints, missing client credentials, insecure endpoint URLs, or missing expected issuer/audience policy.- Parameters:
config- the token validation configuration- Throws:
IllegalArgumentException- if required configuration is missing or invalid- Since:
- 4.21
-
validateConfiguration
Validates a named token validation profile without validating a token.- Parameters:
context- the CamelContext to resolve properties fromprofileName- the named profile- Throws:
IllegalArgumentException- if required profile configuration is missing or invalid- Since:
- 4.21
-
validateConfiguration
Validates the default token validation profile without validating a token.- Parameters:
context- the CamelContext to resolve properties from- Throws:
IllegalArgumentException- if required profile configuration is missing or invalid- Since:
- 4.21
-