Search in sources :

Example 1 with RemoteConnectionConfiguration

use of com.netflix.exhibitor.core.RemoteConnectionConfiguration in project exhibitor by soabase.

the class ExhibitorMain method addRemoteAuth.

private void addRemoteAuth(ExhibitorArguments.Builder builder, String remoteAuthSpec) {
    String[] parts = remoteAuthSpec.split(":");
    Preconditions.checkArgument(parts.length == 2, "Badly formed remote client authorization: " + remoteAuthSpec);
    String type = parts[0].trim();
    String userName = parts[1].trim();
    String password = Preconditions.checkNotNull(users.get(userName), "Realm user not found: " + userName);
    ClientFilter filter;
    if (type.equals("basic")) {
        filter = new HTTPBasicAuthFilter(userName, password);
    } else if (type.equals("digest")) {
        filter = new HTTPDigestAuthFilter(userName, password);
    } else {
        throw new IllegalStateException("Unknown remote client authorization type: " + type);
    }
    builder.remoteConnectionConfiguration(new RemoteConnectionConfiguration(Arrays.asList(filter)));
}
Also used : HTTPDigestAuthFilter(com.sun.jersey.api.client.filter.HTTPDigestAuthFilter) ClientFilter(com.sun.jersey.api.client.filter.ClientFilter) RemoteConnectionConfiguration(com.netflix.exhibitor.core.RemoteConnectionConfiguration) HTTPBasicAuthFilter(com.sun.jersey.api.client.filter.HTTPBasicAuthFilter)

Example 2 with RemoteConnectionConfiguration

use of com.netflix.exhibitor.core.RemoteConnectionConfiguration in project exhibitor by soabase.

the class TestRemoteInstanceRequestClient method testConnectionTimeout.

@Test
public void testConnectionTimeout() throws Exception {
    int port = InstanceSpec.getRandomPort();
    RemoteInstanceRequestClientImpl client = null;
    ServerSocket server = new ServerSocket(port, 0);
    try {
        client = new RemoteInstanceRequestClientImpl(new RemoteConnectionConfiguration());
        client.getWebResource(new URI("http://localhost:" + port), MediaType.WILDCARD_TYPE, Object.class);
    } catch (Exception e) {
        Throwable cause = e.getCause();
        Assert.assertTrue(cause instanceof SocketTimeoutException);
    } finally {
        CloseableUtils.closeQuietly(client);
        server.close();
    }
}
Also used : SocketTimeoutException(java.net.SocketTimeoutException) RemoteConnectionConfiguration(com.netflix.exhibitor.core.RemoteConnectionConfiguration) ServerSocket(java.net.ServerSocket) URI(java.net.URI) SocketTimeoutException(java.net.SocketTimeoutException) URISyntaxException(java.net.URISyntaxException) ConnectException(java.net.ConnectException) Test(org.testng.annotations.Test)

Aggregations

RemoteConnectionConfiguration (com.netflix.exhibitor.core.RemoteConnectionConfiguration)2 ClientFilter (com.sun.jersey.api.client.filter.ClientFilter)1 HTTPBasicAuthFilter (com.sun.jersey.api.client.filter.HTTPBasicAuthFilter)1 HTTPDigestAuthFilter (com.sun.jersey.api.client.filter.HTTPDigestAuthFilter)1 ConnectException (java.net.ConnectException)1 ServerSocket (java.net.ServerSocket)1 SocketTimeoutException (java.net.SocketTimeoutException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 Test (org.testng.annotations.Test)1