protected JsonClient(final RemoteService remote) { this.remote = Objects.requireNonNull(remote, "The remote parameter is null"); final ClientConfig clientConfig = new ClientConfig(); clientConfig.register(JacksonJsonProvider.class).register(JacksonSmileProvider.class); if (remote.isCredential()) { final HttpAuthenticationFeature feature = HttpAuthenticationFeature.basicBuilder() .nonPreemptive() .credentials(remote.username, remote.password) .build(); clientConfig.register(feature); } final int timeout = remote.timeout != null ? remote.timeout : DEFAULT_TIMEOUT; client = ClientBuilder.newClient(clientConfig); client.property(ClientProperties.CONNECT_TIMEOUT, timeout); client.property(ClientProperties.READ_TIMEOUT, timeout); }