Search in sources :

Example 1 with AuthenticationException

use of org.openkilda.exception.AuthenticationException in project open-kilda by telstra.

the class OAuthService method getHttpResponse.

private HttpResponse getHttpResponse(UrlDto request, AuthConfigDto authDto) {
    try {
        String accessToken = getToken((OauthTwoConfigDto) authDto);
        if (request.getHeader() != null) {
            request.setHeader(request.getHeader() + "\nAuthorization:" + accessToken);
        } else {
            request.setHeader("Authorization:" + accessToken);
        }
        HttpMethod httpMethod = null;
        if (("POST").equalsIgnoreCase(request.getMethodType())) {
            httpMethod = HttpMethod.POST;
        } else if (("PUT").equalsIgnoreCase(request.getMethodType())) {
            httpMethod = HttpMethod.PUT;
        } else if (("DELETE").equalsIgnoreCase(request.getMethodType())) {
            httpMethod = HttpMethod.DELETE;
        } else {
            httpMethod = HttpMethod.GET;
        }
        ApiRequestDto apiRequestDto = new ApiRequestDto(request.getUrl(), httpMethod, request.getHeader(), request.getBody());
        if (request.getParams() != null) {
            prepareRequest.preprocessApiRequest(apiRequestDto, request.getParams());
        }
        return restClientManager.invoke(apiRequestDto);
    } catch (RestCallFailedException | AuthenticationException e) {
        e.printStackTrace();
    }
    return null;
}
Also used : AuthenticationException(org.openkilda.exception.AuthenticationException) RestCallFailedException(org.openkilda.exception.RestCallFailedException) ApiRequestDto(org.openkilda.store.common.model.ApiRequestDto) HttpMethod(org.springframework.http.HttpMethod)

Aggregations

AuthenticationException (org.openkilda.exception.AuthenticationException)1 RestCallFailedException (org.openkilda.exception.RestCallFailedException)1 ApiRequestDto (org.openkilda.store.common.model.ApiRequestDto)1 HttpMethod (org.springframework.http.HttpMethod)1