Package org.apache.pulsar.client.api.v5.auth
Authentication carries only lifecycle
(configure / initializeAsync / capability / close); the credential work
lives on opt-in capability interfaces the framework discovers only through
Authentication.capability(Class) — never
instanceof. The capabilities are segregated on two axes (transport × style):
| Pulsar binary protocol | HTTP | |
|---|---|---|
| Single-pass | BinaryAuthDataProvider |
HttpAuthHeadersProvider |
| Multi-round challenge/response | BinaryAuthChallengeHandler |
HttpAuthChallengeHandler |
The convenience composite SinglePassAuthentication
bundles the common single-pass-over-both-transports combination. All capability methods are
asynchronous, so credential acquisition never blocks the Netty event loop.
Two configuration paths.
- Programmatic — build and configure an instance yourself, then pass it to the builder's
authentication(Authentication).Authentication.configure(Map)is NOT called (the instance is presumed already configured). The convenience factories inAuthenticationFactoryreturn such instances. - Reflective by class name —
authentication(authPluginClassName, authParams): the framework loads the class, constructs it no-arg, and callsAuthentication.configure(Map)with the parsed params. A class implementing only this v5 SPI works over this path exactly like a built-in.
Binary routing rules (normative). For every plugin, ClientCnx routes as:
- Initial connect →
BinaryAuthDataProvider; this capability is required for the binary transport — a plugin that does not expose it fails at client build with anUnsupportedAuthenticationException. - The refresh sentinel (
AuthData.REFRESH_AUTH_DATA_BYTES) → the current credential is re-produced throughBinaryAuthDataProvideron a fresh exchange; the sentinel is filtered out and never reaches the challenge handler. - Any other challenge →
BinaryAuthChallengeHandler; a plugin that receives a challenge without exposing the handler fails the connection with anAuthenticationException.
The package also provides end-to-end encryption support via
PublicKeyProvider (producer side) and
PrivateKeyProvider (consumer side); for local
PEM-file-backed setups use PemFileKeyProvider.
-
ClassDescriptionA binary-protocol
CommandAuthChallengepayload handed to aBinaryAuthChallengeHandler(PIP-478).Pluggable authentication provider for the Pulsar v5 client (PIP-478).The per-call context for binary-protocol authentication (PIP-478).Factory for creating common authentication providers.Runtime services handed toAuthentication.initializeAsync(AuthenticationInitContext)once when the client is built (PIP-478).Capability: multi-round challenge/response (SASL-style and custom protocols) for the Pulsar binary protocol (PIP-478).The binary-protocol credential: theauth_databytes forCommandConnect(PIP-478).Capability: single-pass credential exchange for the Pulsar binary protocol (PIP-478).The reply fromBinaryAuthChallengeHandler.respondToChallengeAsync(AuthenticationCallContext, AuthChallenge)— the bytes for the nextCommandAuthResponse(PIP-478).Action a consumer takes when message decryption fails (e.g.Convenience interface for implementations that serve both public keys (for producer-side encryption) and private keys (for consumer-side decryption) — for example, a single PEM-file-backed key store used by both sides of an in-process round trip.A single encryption / decryption key returned by aPublicKeyProviderorPrivateKeyProvider.The per-call context for HTTP authentication (PIP-478).Capability: SASL-style multi-round challenge/response over HTTP (PIP-478).HTTP authentication headers an implementation produces for an outgoing request (and, for challenge/response, the headers carrying a server's challenge) (PIP-478).Capability: single-pass credential exchange for the Pulsar HTTP transport (PIP-478).Batteries-included key provider that loads PEM-encoded keys from local files.Builder forPemFileKeyProvider.Consumer-side SPI: load a private key by name for end-to-end message decryption.Action a producer takes when message encryption fails (e.g.Producer-side SPI: load a public key by name for end-to-end message encryption.Convenience composite: a single-pass credential served over both transports (PIP-478).