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)));
}
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();
}
}
Aggregations