Search in sources :

Example 1 with NoSSLv3SocketFactory

use of io.jawg.osmcontributor.flickr.oauth.NoSSLv3SocketFactory in project osm-contributor by jawg.

the class FlickrPhotoUtils method getAdapter.

public static Retrofit getAdapter() {
    if (adapter == null) {
        try {
            SSLSocketFactory noSSLv3Factory = new NoSSLv3SocketFactory(new URL(FLICKR_API_URL));
            OkHttpClient okHttpClient = new OkHttpClient().newBuilder().sslSocketFactory(noSSLv3Factory).build();
            adapter = new Retrofit.Builder().addConverterFactory(ScalarsConverterFactory.create()).baseUrl(FLICKR_API_URL).client(okHttpClient).build();
        } catch (MalformedURLException e) {
        } catch (IOException e) {
        }
    }
    return adapter;
}
Also used : Retrofit(retrofit2.Retrofit) MalformedURLException(java.net.MalformedURLException) OkHttpClient(okhttp3.OkHttpClient) IOException(java.io.IOException) SSLSocketFactory(javax.net.ssl.SSLSocketFactory) URL(java.net.URL) NoSSLv3SocketFactory(io.jawg.osmcontributor.flickr.oauth.NoSSLv3SocketFactory)

Example 2 with NoSSLv3SocketFactory

use of io.jawg.osmcontributor.flickr.oauth.NoSSLv3SocketFactory in project osm-contributor by jawg.

the class FlickrPhotoUtils method getAdapter.

public static Retrofit getAdapter(final Map<String, String> oAuthParams) {
    Retrofit adapterOauth = null;
    try {
        SSLSocketFactory NoSSLv3Factory = new NoSSLv3SocketFactory(new URL(FLICKR_API_URL));
        adapterOauth = new Retrofit.Builder().addConverterFactory(ScalarsConverterFactory.create()).baseUrl(FLICKR_API_URL).client(new OkHttpClient().newBuilder().sslSocketFactory(NoSSLv3Factory).addInterceptor(new Interceptor() {

            @Override
            public Response intercept(Chain chain) throws IOException {
                Request request = chain.request();
                Request newRequest = request.newBuilder().addHeader("Authorization", FlickrSecurityUtils.getAuthorizationHeader(oAuthParams)).build();
                return chain.proceed(newRequest);
            }
        }).build()).build();
    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return adapterOauth;
}
Also used : MalformedURLException(java.net.MalformedURLException) OkHttpClient(okhttp3.OkHttpClient) Request(okhttp3.Request) IOException(java.io.IOException) URL(java.net.URL) NoSSLv3SocketFactory(io.jawg.osmcontributor.flickr.oauth.NoSSLv3SocketFactory) Response(okhttp3.Response) Retrofit(retrofit2.Retrofit) SSLSocketFactory(javax.net.ssl.SSLSocketFactory) Interceptor(okhttp3.Interceptor)

Example 3 with NoSSLv3SocketFactory

use of io.jawg.osmcontributor.flickr.oauth.NoSSLv3SocketFactory in project osm-contributor by jawg.

the class FlickrUploadUtils method getRestAdapter.

public static Retrofit getRestAdapter(final Map<String, String> oAuthParams) {
    if (adapter == null) {
        try {
            SSLSocketFactory NoSSLv3Factory = new NoSSLv3SocketFactory(new URL("https://up.flickr.com/services"));
            adapter = new Retrofit.Builder().addConverterFactory(ScalarsConverterFactory.create()).baseUrl("https://up.flickr.com/services/").client(new okhttp3.OkHttpClient().newBuilder().sslSocketFactory(NoSSLv3Factory).addInterceptor(new Interceptor() {

                @Override
                public Response intercept(Chain chain) throws IOException {
                    Request request = chain.request();
                    Request newRequest = request.newBuilder().addHeader("Authorization", FlickrSecurityUtils.getAuthorizationHeader(oAuthParams)).build();
                    return chain.proceed(newRequest);
                }
            }).build()).build();
        } catch (MalformedURLException e) {
        } catch (IOException e) {
        }
    }
    return adapter;
}
Also used : MalformedURLException(java.net.MalformedURLException) Request(okhttp3.Request) IOException(java.io.IOException) URL(java.net.URL) NoSSLv3SocketFactory(io.jawg.osmcontributor.flickr.oauth.NoSSLv3SocketFactory) Response(okhttp3.Response) Retrofit(retrofit2.Retrofit) SSLSocketFactory(javax.net.ssl.SSLSocketFactory) Interceptor(okhttp3.Interceptor)

Aggregations

NoSSLv3SocketFactory (io.jawg.osmcontributor.flickr.oauth.NoSSLv3SocketFactory)3 IOException (java.io.IOException)3 MalformedURLException (java.net.MalformedURLException)3 URL (java.net.URL)3 SSLSocketFactory (javax.net.ssl.SSLSocketFactory)3 Retrofit (retrofit2.Retrofit)3 Interceptor (okhttp3.Interceptor)2 OkHttpClient (okhttp3.OkHttpClient)2 Request (okhttp3.Request)2 Response (okhttp3.Response)2