Search in sources :

Example 1 with BasicAuthenticator

use of org.jolokia.client.BasicAuthenticator in project camel by apache.

the class JolokiaClientFactory method createJolokiaClient.

public static J4pClient createJolokiaClient(String jolokiaUrl, String username, String password) {
    J4pClientBuilder builder = J4pClientBuilderFactory.url(jolokiaUrl);
    boolean auth = false;
    if (isNotEmpty(username)) {
        builder = builder.user(username);
        auth = true;
    }
    if (isNotEmpty(password)) {
        builder = builder.password(password);
        auth = true;
    }
    if (auth) {
        builder = builder.authenticator(new BasicAuthenticator(true));
    }
    return builder.build();
}
Also used : BasicAuthenticator(org.jolokia.client.BasicAuthenticator) J4pClientBuilder(org.jolokia.client.J4pClientBuilder)

Aggregations

BasicAuthenticator (org.jolokia.client.BasicAuthenticator)1 J4pClientBuilder (org.jolokia.client.J4pClientBuilder)1