Example usage for org.springframework.http HttpRequest getURI

List of usage examples for org.springframework.http HttpRequest getURI

Introduction

In this page you can find the example usage for org.springframework.http HttpRequest getURI.

Prototype

URI getURI();

Source Link

Document

Return the URI of the request (including a query string if any, but only if it is well-formed for a URI representation).

Usage

From source file:org.springframework.ide.eclipse.boot.wizard.github.auth.BasicAuthCredentials.java

@Override
public RestTemplate apply(RestTemplate rest) {
    List<ClientHttpRequestInterceptor> interceptors = rest.getInterceptors();
    interceptors.add(new ClientHttpRequestInterceptor() {
        public ClientHttpResponse intercept(HttpRequest request, byte[] body,
                ClientHttpRequestExecution execution) throws IOException {
            if (matchHost(request.getURI().getHost())) {
                HttpHeaders headers = request.getHeaders();
                if (!headers.containsKey("Authorization")) {
                    String authString = computeAuthString();
                    headers.add("Authorization", authString);
                }/* w ww . ja  v a 2  s. c o  m*/
            }
            return execution.execute(request, body);
        }

    });
    return rest;
}

From source file:org.springframework.social.oauth1.SigningSupport.java

/**
 * Builds an authorization header from a request.
 * Expects that the request's query parameters are form-encoded.
 */// w  w  w  .j  av  a2 s.c o  m
public String buildAuthorizationHeaderValue(HttpRequest request, byte[] body, String consumerKey,
        String consumerSecret, String accessToken, String accessTokenSecret) {
    Map<String, String> oauthParameters = commonOAuthParameters(consumerKey);
    oauthParameters.put("oauth_token", accessToken);
    MultiValueMap<String, String> additionalParameters = union(
            readFormParameters(request.getHeaders().getContentType(), body),
            parseFormParameters(request.getURI().getRawQuery()));
    return buildAuthorizationHeaderValue(request.getMethod(), request.getURI(), oauthParameters,
            additionalParameters, consumerSecret, accessTokenSecret);
}

From source file:org.springframework.social.oauth1.SigningUtils.java

public static String buildAuthorizationHeaderValue(HttpRequest request, byte[] body, String consumerKey,
        String consumerSecret, String accessToken, String accessTokenSecret) {
    Map<String, String> oauthParameters = commonOAuthParameters(consumerKey);
    oauthParameters.put("oauth_token", accessToken);
    Map<String, String> aditionalParameters = extractBodyParameters(request.getHeaders().getContentType(),
            body);/*from   www  .  ja v  a  2 s .  c  om*/
    Map<String, String> queryParameters = extractParameters(request.getURI().getQuery());
    aditionalParameters.putAll(queryParameters);
    String baseRequestUrl = getBaseUrlWithoutPortOrQueryString(request.getURI());
    return SigningUtils.buildAuthorizationHeaderValue(baseRequestUrl, oauthParameters, aditionalParameters,
            request.getMethod(), consumerSecret, accessTokenSecret);
}