regulaforensics / DocumentReader-web-java-client

Regula Document Reader web API java client compatible with jvm and android
https://regulaforensics.com
5 stars 6 forks source link

how do you set the proxy ? #28

Closed mohammadchehab closed 3 years ago

mohammadchehab commented 3 years ago

how can you set the HTTP proxy? need a username password and a server + port

hleb-albau commented 3 years ago

hello,

working on your question

hleb-albau commented 3 years ago

Assuming you have HTTP proxy, could, you, please, try this

        var proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxy_host", 8083));
        var proxyAuthenticator = new Authenticator() {
            @Override
            public Request authenticate(@Nullable Route route, Response response) throws IOException {
                String credential = Credentials.basic(username, password);
                return response.request().newBuilder()
                        .header("Proxy-Authorization", credential)
                        .build();
            }
        };

         var http_client = new OkHttpClient.Builder()
                .proxy(proxy)
                .proxyAuthenticator(proxyAuthenticator)
                .build();

        var api_client = new ApiClient(http_client);
        api_client.setBasePath("https://some_url_where_document_reader_started:8080/");
        var api = new DocumentReaderApi(api_client);

In general, we use okhttp3 as HTTP client. You can find more options available in OkHttpClient.Builder() in okhttp3 docs.

Waiting your feedback :)

mohammadchehab commented 3 years ago

I suppose this wont work with java 8 without adding the okhttp3 to my pom file, do you have any specific version.

hleb-albau commented 3 years ago

our lib bundled with com.squareup.okhttp3:okhttp:3.14.7 dependency in maven metadata. Thus, if you install our lib, maven/gradle should implicitly include okhttp3.

btw, here you can find actual versions of dependencies we use

hleb-albau commented 3 years ago

hello @chehabz,

Did you succeed with proxy integration?

mohammadchehab commented 3 years ago

Unfortunately no as we’re planning to host the soln on azure on our environment.

On Tue, 20 Apr 2021 at 10:52 AM Hleb Albau @.***> wrote:

hello @chehabz https://github.com/chehabz,

Did you succeed with proxy integration?

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/regulaforensics/DocumentReader-web-java-client/issues/28#issuecomment-823022119, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIC3AYA3MW7DDNJEW5LI2DTJUQCRANCNFSM42Y6RUPQ .

hleb-albau commented 3 years ago

close as stale