Search in sources :

Example 11 with Authentication

use of com.yahoo.pulsar.client.api.Authentication in project pulsar by yahoo.

the class AuthenticationFactory method create.

/**
     * Create an instance of the Authentication-Plugin
     *
     * @param authPluginClassName
     *            name of the Authentication-Plugin you want to use
     * @param authParams
     *            map which represents parameters for the Authentication-Plugin
     * @return instance of the Authentication-Plugin
     * @throws UnsupportedAuthenticationException
     */
public static final Authentication create(String authPluginClassName, Map<String, String> authParams) throws UnsupportedAuthenticationException {
    try {
        if (isNotBlank(authPluginClassName)) {
            Class<?> authClass = Class.forName(authPluginClassName);
            Authentication auth = (Authentication) authClass.newInstance();
            auth.configure(authParams);
            return auth;
        } else {
            return new AuthenticationDisabled();
        }
    } catch (Throwable t) {
        throw new UnsupportedAuthenticationException(t);
    }
}
Also used : Authentication(com.yahoo.pulsar.client.api.Authentication) AuthenticationDisabled(com.yahoo.pulsar.client.impl.auth.AuthenticationDisabled) UnsupportedAuthenticationException(com.yahoo.pulsar.client.api.PulsarClientException.UnsupportedAuthenticationException)

Aggregations

Authentication (com.yahoo.pulsar.client.api.Authentication)11 PulsarAdmin (com.yahoo.pulsar.client.admin.PulsarAdmin)7 URL (java.net.URL)7 ServiceConfiguration (com.yahoo.pulsar.broker.ServiceConfiguration)6 PulsarService (com.yahoo.pulsar.broker.PulsarService)5 LocalBookkeeperEnsemble (com.yahoo.pulsar.zookeeper.LocalBookkeeperEnsemble)5 ClientConfiguration (com.yahoo.pulsar.client.api.ClientConfiguration)4 AuthenticationTls (com.yahoo.pulsar.client.impl.auth.AuthenticationTls)4 ClusterData (com.yahoo.pulsar.common.policies.data.ClusterData)4 IOException (java.io.IOException)4 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 BeforeMethod (org.testng.annotations.BeforeMethod)4 Consumer (com.yahoo.pulsar.client.api.Consumer)3 ConsumerConfiguration (com.yahoo.pulsar.client.api.ConsumerConfiguration)3 PulsarClient (com.yahoo.pulsar.client.api.PulsarClient)3 PropertyAdmin (com.yahoo.pulsar.common.policies.data.PropertyAdmin)3 Test (org.testng.annotations.Test)3 ConflictException (com.yahoo.pulsar.client.admin.PulsarAdminException.ConflictException)1 UnsupportedAuthenticationException (com.yahoo.pulsar.client.api.PulsarClientException.UnsupportedAuthenticationException)1