@Override
  public void process(final HttpRequest request, final HttpContext context)
      throws HttpException, IOException {
    URIBuilder uriBuilder;
    try {
      uriBuilder = new URIBuilder(request.getRequestLine().getUri());
    } catch (URISyntaxException e) {
      throw new IOException("Invalid URI" , e);
    }

    // Copy Apache HttpRequest to AWS DefaultRequest
    DefaultRequest<?> signableRequest = new DefaultRequest<>(service);

    HttpHost host = (HttpHost) context.getAttribute(HttpCoreContext.HTTP_TARGET_HOST);
    if (host != null) {
      signableRequest.setEndpoint(URI.create(host.toURI()));
    }
    final HttpMethodName httpMethod =
        HttpMethodName.fromValue(request.getRequestLine().getMethod());
    signableRequest.setHttpMethod(httpMethod);
    try {
      signableRequest.setResourcePath(uriBuilder.build().getRawPath());
    } catch (URISyntaxException e) {
      throw new IOException("Invalid URI" , e);
    }

    if (request instanceof HttpEntityEnclosingRequest) {
      HttpEntityEnclosingRequest httpEntityEnclosingRequest =
          (HttpEntityEnclosingRequest) request;
      if (httpEntityEnclosingRequest.getEntity() != null) {
        signableRequest.setContent(httpEntityEnclosingRequest.getEntity().getContent());
      }
    }
    signableRequest.setParameters(nvpToMapParams(uriBuilder.getQueryParams()));
    signableRequest.setHeaders(headerArrayToMap(request.getAllHeaders()));

    // Sign it
    signer.sign(signableRequest, awsCredentialsProvider.getCredentials());

    // Now copy everything back
    request.setHeaders(mapToHeaderArray(signableRequest.getHeaders()));
    if (request instanceof HttpEntityEnclosingRequest) {
      HttpEntityEnclosingRequest httpEntityEnclosingRequest =
          (HttpEntityEnclosingRequest) request;
      if (httpEntityEnclosingRequest.getEntity() != null) {
        BasicHttpEntity basicHttpEntity = new BasicHttpEntity();
        basicHttpEntity.setContent(signableRequest.getContent());
        httpEntityEnclosingRequest.setEntity(basicHttpEntity);
      }
    }
  }
@Override
  public void process(final HttpRequest request, final HttpContext context)
      throws HttpException, IOException {
    URIBuilder uriBuilder;
    try {
      uriBuilder = new URIBuilder(request.getRequestLine().getUri());
    } catch (URISyntaxException e) {
      throw new IOException("Invalid URI" , e);
    }

    
    DefaultRequest<?> signableRequest = new DefaultRequest<>(service);

    HttpHost host = (HttpHost) context.getAttribute(HttpCoreContext.HTTP_TARGET_HOST);
    if (host != null) {
      signableRequest.setEndpoint(URI.create(host.toURI()));
    }
    final HttpMethodName httpMethod =
        HttpMethodName.fromValue(request.getRequestLine().getMethod());
    signableRequest.setHttpMethod(httpMethod);
    try {
      signableRequest.setResourcePath(uriBuilder.build().getRawPath());
    } catch (URISyntaxException e) {
      throw new IOException("Invalid URI" , e);
    }

    if (request instanceof HttpEntityEnclosingRequest) {
      HttpEntityEnclosingRequest httpEntityEnclosingRequest =
          (HttpEntityEnclosingRequest) request;
      if (httpEntityEnclosingRequest.getEntity() != null) {
        signableRequest.setContent(httpEntityEnclosingRequest.getEntity().getContent());
      }
    }
    signableRequest.setParameters(nvpToMapParams(uriBuilder.getQueryParams()));
    signableRequest.setHeaders(headerArrayToMap(request.getAllHeaders()));

    
    signer.sign(signableRequest, awsCredentialsProvider.getCredentials());

    
    request.setHeaders(mapToHeaderArray(signableRequest.getHeaders()));
    if (request instanceof HttpEntityEnclosingRequest) {
      HttpEntityEnclosingRequest httpEntityEnclosingRequest =
          (HttpEntityEnclosingRequest) request;
      if (httpEntityEnclosingRequest.getEntity() != null) {
        BasicHttpEntity basicHttpEntity = new BasicHttpEntity();
        basicHttpEntity.setContent(signableRequest.getContent());
        httpEntityEnclosingRequest.setEntity(basicHttpEntity);
      }
    }
  }
@ Override public void process ( final HttpRequest request , final HttpContext context ) throws HttpException , IOException { URIBuilder uriBuilder ; try { uriBuilder = new URIBuilder ( request . getRequestLine ( ) . getUri ( ) ) ; } catch ( URISyntaxException e ) { throw new IOException ( "Invalid URI" , e ) ; } // Copy Apache HttpRequest to AWS DefaultRequest DefaultRequest < ? > signableRequest = new DefaultRequest <> ( service ) ; HttpHost host = ( HttpHost ) context . getAttribute ( HttpCoreContext . HTTP_TARGET_HOST ) ; if ( host != null ) { signableRequest . setEndpoint ( URI . create ( host . toURI ( ) ) ) ; } final HttpMethodName httpMethod = HttpMethodName . fromValue ( request . getRequestLine ( ) . getMethod ( ) ) ; signableRequest . setHttpMethod ( httpMethod ) ; try { signableRequest . setResourcePath ( uriBuilder . build ( ) . getRawPath ( ) ) ; } catch ( URISyntaxException e ) { throw new IOException ( "Invalid URI" , e ) ; } if ( request instanceof HttpEntityEnclosingRequest ) { HttpEntityEnclosingRequest httpEntityEnclosingRequest = ( HttpEntityEnclosingRequest ) request ; if ( httpEntityEnclosingRequest . getEntity ( ) != null ) { signableRequest . setContent ( httpEntityEnclosingRequest . getEntity ( ) . getContent ( ) ) ; } } signableRequest . setParameters ( nvpToMapParams ( uriBuilder . getQueryParams ( ) ) ) ; signableRequest . setHeaders ( headerArrayToMap ( request . getAllHeaders ( ) ) ) ; // Sign it signer . sign ( signableRequest , awsCredentialsProvider . getCredentials ( ) ) ; // Now copy everything back request . setHeaders ( mapToHeaderArray ( signableRequest . getHeaders ( ) ) ) ; if ( request instanceof HttpEntityEnclosingRequest ) { HttpEntityEnclosingRequest httpEntityEnclosingRequest = ( HttpEntityEnclosingRequest ) request ; if ( httpEntityEnclosingRequest . getEntity ( ) != null ) { BasicHttpEntity basicHttpEntity = new BasicHttpEntity ( ) ; basicHttpEntity . setContent ( signableRequest . getContent ( ) ) ; httpEntityEnclosingRequest . setEntity ( basicHttpEntity ) ; } } }
{@inheritDoc}
{