Class OAuthHelper

java.lang.Object
org.apache.camel.support.OAuthHelper

public final class OAuthHelper extends Object
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 Type
    Method
    Description
    static String
    resolveOAuthToken(org.apache.camel.CamelContext context, String profileName)
    Resolves an OAuth bearer token using a named profile.
    static org.apache.camel.spi.OAuthTokenValidationFactory
    resolveOAuthTokenValidationFactory(org.apache.camel.CamelContext context)
    Resolves the OAuth token validation factory.
    static org.apache.camel.spi.OAuthTokenValidationFactory
    resolveOAuthTokenValidationFactory(org.apache.camel.CamelContext context, String profileName)
    Resolves the OAuth token validation factory for the given profile.
    static org.apache.camel.spi.OAuthTokenValidationResult
    validateOAuthToken(org.apache.camel.CamelContext context, String token)
    Validates an incoming bearer token using the default (unnamed) profile.
    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.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 from camel.oauth.<profileName>.*.

      Parameters:
      context - the CamelContext
      profileName - 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 with camel.oauth.validation-factory. If configured, the referenced bean must exist and implement OAuthTokenValidationFactory.

      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-specific camel.oauth.<profileName>.validation-factory property can reference a registry bean by name. If configured, the referenced bean must exist and implement OAuthTokenValidationFactory.

      Parameters:
      context - the CamelContext
      profileName - 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 from camel.oauth.<profileName>.*.

      Parameters:
      context - the CamelContext
      profileName - the OAuth profile name
      token - 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 from camel.oauth.*.

      Parameters:
      context - the CamelContext
      token - the bearer token string to validate
      Returns:
      the validation result (never null)
      Since:
      4.21