Example usage for com.amazonaws SignableRequest SignableRequest

List of usage examples for com.amazonaws SignableRequest SignableRequest

Introduction

In this page you can find the example usage for com.amazonaws SignableRequest SignableRequest.

Prototype

SignableRequest

Source Link

Usage

From source file:com.eucalyptus.ws.handlers.IoInternalHmacHandler.java

License:Open Source License

private SignableRequest<?> wrapRequest(final FullHttpRequest request) {
    return new SignableRequest() {
        @Override//  ww  w .  j  a va2s. c  om
        public Map<String, String> getHeaders() {
            return request.headers().entries().stream()
                    .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
        }

        @Override
        public String getResourcePath() {
            return request.getUri();
        }

        @Override
        public Map<String, List<String>> getParameters() {
            return Collections.emptyMap();
        }

        @Override
        public URI getEndpoint() {
            return URI.create("http://" + request.headers().get(HttpHeaders.Names.HOST));
        }

        @Override
        public HttpMethodName getHttpMethod() {
            return HttpMethodName.fromValue(request.getMethod().name());
        }

        @Override
        public int getTimeOffset() {
            return 0;
        }

        @Override
        public InputStream getContent() {
            return new ByteBufInputStream(request.content().slice());
        }

        @Override
        public InputStream getContentUnwrapped() {
            return getContent();
        }

        @Override
        public ReadLimitInfo getReadLimitInfo() {
            return () -> request.content().readableBytes();
        }

        @Override
        public Object getOriginalRequestObject() {
            throw new RuntimeException("Not supported");
        }

        @Override
        public void addHeader(final String s, final String s1) {
            request.headers().set(s, s1);
        }

        @Override
        public void addParameter(final String s, final String s1) {
            throw new RuntimeException("Not supported");
        }

        @Override
        public void setContent(final InputStream inputStream) {
            throw new RuntimeException("Not supported");
        }
    };
}