Class OAuthHelper
java.lang.Object
org.apache.camel.support.OAuthHelper
Helper for resolving and validating OAuth tokens via the
OAuthClientAuthenticationFactory and
OAuthTokenValidationFactory SPIs.
Token acquisition requires camel-oauth on the classpath. Token validation requires an
OAuthTokenValidationFactory; camel-oauth provides the default implementation, and runtimes can provide their
own implementation backed by their native security stack.-
Method Summary
Modifier and TypeMethodDescriptionstatic StringresolveOAuthToken(org.apache.camel.CamelContext context, String profileName) Resolves an OAuth bearer token using a named profile.static org.apache.camel.spi.OAuthTokenValidationFactoryresolveOAuthTokenValidationFactory(org.apache.camel.CamelContext context) Resolves the OAuth token validation factory.static org.apache.camel.spi.OAuthTokenValidationFactoryresolveOAuthTokenValidationFactory(org.apache.camel.CamelContext context, String profileName) Resolves the OAuth token validation factory for the given profile.static org.apache.camel.spi.OAuthTokenValidationResultvalidateOAuthToken(org.apache.camel.CamelContext context, String token) Validates an incoming bearer token using the default (unnamed) profile.static org.apache.camel.spi.OAuthTokenValidationResultvalidateOAuthToken(org.apache.camel.CamelContext context, String profileName, String token) Validates an incoming bearer token using a named profile.
-
Method Details
-
resolveOAuthToken
public static String resolveOAuthToken(org.apache.camel.CamelContext context, String profileName) throws Exception Resolves an OAuth bearer token using a named profile. The profile properties are resolved fromcamel.oauth.<profileName>.*.- Parameters:
context- the CamelContextprofileName- the OAuth profile name- Returns:
- the bearer token string
- Throws:
Exception- if the factory is not found or token acquisition fails
-
resolveOAuthTokenValidationFactory
public static org.apache.camel.spi.OAuthTokenValidationFactory resolveOAuthTokenValidationFactory(org.apache.camel.CamelContext context) Resolves the OAuth token validation factory. The default profile can reference a registry bean withcamel.oauth.validation-factory. If configured, the referenced bean must exist and implementOAuthTokenValidationFactory.- Parameters:
context- the CamelContext- Returns:
- the token validation factory
- Since:
- 4.21
-
resolveOAuthTokenValidationFactory
public static org.apache.camel.spi.OAuthTokenValidationFactory resolveOAuthTokenValidationFactory(org.apache.camel.CamelContext context, String profileName) Resolves the OAuth token validation factory for the given profile. The profile-specificcamel.oauth.<profileName>.validation-factoryproperty can reference a registry bean by name. If configured, the referenced bean must exist and implementOAuthTokenValidationFactory.- Parameters:
context- the CamelContextprofileName- the OAuth profile name- Returns:
- the token validation factory
- Since:
- 4.21
-
validateOAuthToken
public static org.apache.camel.spi.OAuthTokenValidationResult validateOAuthToken(org.apache.camel.CamelContext context, String profileName, String token) Validates an incoming bearer token using a named profile. JWT tokens are validated locally via JWKS (signature, expiry, audience, issuer). Opaque tokens are validated via RFC 7662 introspection. The profile properties are resolved fromcamel.oauth.<profileName>.*.- Parameters:
context- the CamelContextprofileName- the OAuth profile nametoken- the bearer token string to validate- Returns:
- the validation result (never null)
- Since:
- 4.21
-
validateOAuthToken
public static org.apache.camel.spi.OAuthTokenValidationResult validateOAuthToken(org.apache.camel.CamelContext context, String token) Validates an incoming bearer token using the default (unnamed) profile. JWT tokens are validated locally via JWKS (signature, expiry, audience, issuer). Opaque tokens are validated via RFC 7662 introspection. The profile properties are resolved fromcamel.oauth.*.- Parameters:
context- the CamelContexttoken- the bearer token string to validate- Returns:
- the validation result (never null)
- Since:
- 4.21
-