org.apache.oltu.oauth2.client.response.OAuthClientResponseFactory Java Examples

The following examples show how to use org.apache.oltu.oauth2.client.response.OAuthClientResponseFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OAuthOkHttpClient.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
public <T extends OAuthClientResponse> T execute(OAuthClientRequest request, Map<String, String> headers,
        String requestMethod, Class<T> responseClass)
                throws OAuthSystemException, OAuthProblemException {

    MediaType mediaType = MediaType.parse("application/json");
    Request.Builder requestBuilder = new Request.Builder().url(request.getLocationUri());

    if(headers != null) {
        for (Entry<String, String> entry : headers.entrySet()) {
            if (entry.getKey().equalsIgnoreCase("Content-Type")) {
                mediaType = MediaType.parse(entry.getValue());
            } else {
                requestBuilder.addHeader(entry.getKey(), entry.getValue());
            }
        }
    }

    RequestBody body = request.getBody() != null ? RequestBody.create(mediaType, request.getBody()) : null;
    requestBuilder.method(requestMethod, body);

    try {
        Response response = client.newCall(requestBuilder.build()).execute();
        return OAuthClientResponseFactory.createCustomResponse(
                response.body().string(), 
                response.body().contentType().toString(),
                response.code(),
                responseClass);
    } catch (IOException e) {
        throw new OAuthSystemException(e);
    }
}
 
Example #2
Source File: OAuthOkHttpClient.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
@Override
public <T extends OAuthClientResponse> T execute(OAuthClientRequest request, Map<String, String> headers,
                                                 String requestMethod, Class<T> responseClass)
        throws OAuthSystemException, OAuthProblemException {

    MediaType mediaType = MediaType.parse("application/json");
    Request.Builder requestBuilder = new Request.Builder().url(request.getLocationUri());

    if(headers != null) {
        for (Entry<String, String> entry : headers.entrySet()) {
            if (entry.getKey().equalsIgnoreCase("Content-Type")) {
                mediaType = MediaType.parse(entry.getValue());
            } else {
                requestBuilder.addHeader(entry.getKey(), entry.getValue());
            }
        }
    }

    RequestBody body = request.getBody() != null ? RequestBody.create(mediaType, request.getBody()) : null;
    requestBuilder.method(requestMethod, body);

    try {
        Response response = client.newCall(requestBuilder.build()).execute();
        return OAuthClientResponseFactory.createCustomResponse(
                response.body().string(),
                response.body().contentType().toString(),
                response.code(),
                responseClass);
    } catch (IOException e) {
        throw new OAuthSystemException(e);
    }
}
 
Example #3
Source File: OAuthOkHttpClient.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
public <T extends OAuthClientResponse> T execute(OAuthClientRequest request, Map<String, String> headers,
        String requestMethod, Class<T> responseClass)
                throws OAuthSystemException, OAuthProblemException {

    MediaType mediaType = MediaType.parse("application/json");
    Request.Builder requestBuilder = new Request.Builder().url(request.getLocationUri());

    if(headers != null) {
        for (Entry<String, String> entry : headers.entrySet()) {
            if (entry.getKey().equalsIgnoreCase("Content-Type")) {
                mediaType = MediaType.parse(entry.getValue());
            } else {
                requestBuilder.addHeader(entry.getKey(), entry.getValue());
            }
        }
    }

    RequestBody body = request.getBody() != null ? RequestBody.create(mediaType, request.getBody()) : null;
    requestBuilder.method(requestMethod, body);

    try {
        Response response = client.newCall(requestBuilder.build()).execute();
        return OAuthClientResponseFactory.createCustomResponse(
                response.body().string(), 
                response.body().contentType().toString(),
                response.code(),
                responseClass);
    } catch (IOException e) {
        throw new OAuthSystemException(e);
    }
}
 
Example #4
Source File: OAuthOkHttpClient.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
@Override
public <T extends OAuthClientResponse> T execute(OAuthClientRequest request, Map<String, String> headers,
                                                 String requestMethod, Class<T> responseClass)
        throws OAuthSystemException, OAuthProblemException {

    MediaType mediaType = MediaType.parse("application/json");
    Request.Builder requestBuilder = new Request.Builder().url(request.getLocationUri());

    if(headers != null) {
        for (Entry<String, String> entry : headers.entrySet()) {
            if (entry.getKey().equalsIgnoreCase("Content-Type")) {
                mediaType = MediaType.parse(entry.getValue());
            } else {
                requestBuilder.addHeader(entry.getKey(), entry.getValue());
            }
        }
    }

    RequestBody body = request.getBody() != null ? RequestBody.create(mediaType, request.getBody()) : null;
    requestBuilder.method(requestMethod, body);

    try {
        Response response = client.newCall(requestBuilder.build()).execute();
        return OAuthClientResponseFactory.createCustomResponse(
                response.body().string(),
                response.body().contentType().toString(),
                response.code(),
                responseClass);
    } catch (IOException e) {
        throw new OAuthSystemException(e);
    }
}
 
Example #5
Source File: OAuthOkHttpClient.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
public <T extends OAuthClientResponse> T execute(OAuthClientRequest request, Map<String, String> headers,
        String requestMethod, Class<T> responseClass)
                throws OAuthSystemException, OAuthProblemException {

    MediaType mediaType = MediaType.parse("application/json");
    Request.Builder requestBuilder = new Request.Builder().url(request.getLocationUri());

    if(headers != null) {
        for (Entry<String, String> entry : headers.entrySet()) {
            if (entry.getKey().equalsIgnoreCase("Content-Type")) {
                mediaType = MediaType.parse(entry.getValue());
            } else {
                requestBuilder.addHeader(entry.getKey(), entry.getValue());
            }
        }
    }

    RequestBody body = request.getBody() != null ? RequestBody.create(mediaType, request.getBody()) : null;
    requestBuilder.method(requestMethod, body);

    try {
        Response response = client.newCall(requestBuilder.build()).execute();
        return OAuthClientResponseFactory.createCustomResponse(
                response.body().string(), 
                response.body().contentType().toString(),
                response.code(),
                responseClass);
    } catch (IOException e) {
        throw new OAuthSystemException(e);
    }
}
 
Example #6
Source File: OAuthOkHttpClient.java    From android with MIT License 5 votes vote down vote up
public <T extends OAuthClientResponse> T execute(OAuthClientRequest request, Map<String, String> headers,
        String requestMethod, Class<T> responseClass)
                throws OAuthSystemException, OAuthProblemException {

    MediaType mediaType = MediaType.parse("application/json");
    Request.Builder requestBuilder = new Request.Builder().url(request.getLocationUri());

    if(headers != null) {
        for (Entry<String, String> entry : headers.entrySet()) {
            if (entry.getKey().equalsIgnoreCase("Content-Type")) {
                mediaType = MediaType.parse(entry.getValue());
            } else {
                requestBuilder.addHeader(entry.getKey(), entry.getValue());
            }
        }
    }

    RequestBody body = request.getBody() != null ? RequestBody.create(mediaType, request.getBody()) : null;
    requestBuilder.method(requestMethod, body);

    try {
        Response response = client.newCall(requestBuilder.build()).execute();
        return OAuthClientResponseFactory.createCustomResponse(
                response.body().string(), 
                response.body().contentType().toString(),
                response.code(),
                response.headers().toMultimap(),
                responseClass);
    } catch (IOException e) {
        throw new OAuthSystemException(e);
    }
}
 
Example #7
Source File: OAuthOkHttpClient.java    From eve-esi with Apache License 2.0 5 votes vote down vote up
@Override
public <T extends OAuthClientResponse> T execute(OAuthClientRequest request, Map<String, String> headers,
        String requestMethod, Class<T> responseClass) throws OAuthSystemException, OAuthProblemException {

    MediaType mediaType = MediaType.parse("application/json");
    Request.Builder requestBuilder = new Request.Builder().url(request.getLocationUri());

    if (headers != null) {
        for (Entry<String, String> entry : headers.entrySet()) {
            if (entry.getKey().equalsIgnoreCase("Content-Type")) {
                mediaType = MediaType.parse(entry.getValue());
            } else {
                requestBuilder.addHeader(entry.getKey(), entry.getValue());
            }
        }
    }

    RequestBody body = request.getBody() != null ? RequestBody.create(mediaType, request.getBody()) : null;
    requestBuilder.method(requestMethod, body);

    try {
        Response response = client.newCall(requestBuilder.build()).execute();
        return OAuthClientResponseFactory.createCustomResponse(response.body().string(), response.body()
                .contentType().toString(), response.code(), responseClass);
    } catch (IOException e) {
        throw new OAuthSystemException(e);
    }
}