Class AuthenticationFactory
java.lang.Object
org.apache.pulsar.client.api.v5.auth.AuthenticationFactory
Factory for creating common authentication providers.
-
Method Summary
Modifier and TypeMethodDescriptionstatic AuthenticationCreate an authentication provider by plugin class name and parameter string.static AuthenticationCreate an authentication provider by plugin class name and parameter map.static AuthenticationCreate TLS mutual authentication.static AuthenticationCreate token-based authentication with a static token.static AuthenticationCreate token-based authentication with a dynamic token supplier.
-
Method Details
-
token
Create token-based authentication with a static token.- Parameters:
token- the JWT or other authentication token string- Returns:
- an
Authenticationinstance configured with the given token
-
token
Create token-based authentication with a dynamic token supplier.The supplier is invoked each time the client needs to authenticate, allowing for token refresh without recreating the client.
- Parameters:
tokenSupplier- a supplier that provides the current authentication token- Returns:
- an
Authenticationinstance that retrieves tokens from the supplier
-
tls
Create TLS mutual authentication.- Parameters:
certFilePath- the path to the client certificate file (PEM format)keyFilePath- the path to the client private key file (PEM format)- Returns:
- an
Authenticationinstance configured for TLS mutual authentication
-
create
public static Authentication create(String authPluginClassName, String authParamsString) throws PulsarClientException Create an authentication provider by plugin class name and parameter string.- Parameters:
authPluginClassName- the fully qualified class name of the authentication pluginauthParamsString- the authentication parameters as a serialized string- Returns:
- an
Authenticationinstance created from the specified plugin - Throws:
PulsarClientException- if the plugin class cannot be loaded or instantiated
-
create
public static Authentication create(String authPluginClassName, Map<String, String> authParams) throws PulsarClientExceptionCreate an authentication provider by plugin class name and parameter map.- Parameters:
authPluginClassName- the fully qualified class name of the authentication pluginauthParams- the authentication parameters as key-value pairs- Returns:
- an
Authenticationinstance created from the specified plugin - Throws:
PulsarClientException- if the plugin class cannot be loaded or instantiated
-