public static ValidationToken fromHttpRequest(
        String accountSid,
        String credentialSid,
        String signingKeySid,
        PrivateKey privateKey,
        HttpRequest request,
        List<String> signedHeaders
    ) throws IOException {
        Builder builder = new Builder(accountSid, credentialSid, signingKeySid, privateKey);

        String method = request.getRequestLine().getMethod();
        builder.method(method);

        String uri = request.getRequestLine().getUri();
        if (uri.contains("?")) {
            String[] uriParts = uri.split("\\?");
            builder.uri(uriParts[0]);
            builder.queryString(uriParts[1]);
        } else {
            builder.uri(uri);
        }

        builder.headers(request.getAllHeaders());
        builder.signedHeaders(signedHeaders);

        /**
         * If the request encloses an "entity", use it for the body. Note that this is dependent on several factors
         * during request building and is not solely based on the specified method.
         *
         * @see org.apache.http.client.methods.RequestBuilder#build
         */
        if (request instanceof HttpEntityEnclosingRequest) {
            HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
            builder.requestBody(CharStreams.toString(new InputStreamReader(entity.getContent(), Charsets.UTF_8)));
        }

        return builder.build();
    }
public static ValidationToken fromHttpRequest ( String accountSid , String credentialSid , String signingKeySid , PrivateKey privateKey , HttpRequest request , List < String > signedHeaders ) throws IOException { Builder builder = new Builder ( accountSid , credentialSid , signingKeySid , privateKey ) ; String method = request . getRequestLine ( ) . getMethod ( ) ; builder . method ( method ) ; String uri = request . getRequestLine ( ) . getUri ( ) ; if ( uri . contains ( "?" ) ) { String [ ] uriParts = uri . split ( "\\?" ) ; builder . uri ( uriParts [ 0 ] ) ; builder . queryString ( uriParts [ 1 ] ) ; } else { builder . uri ( uri ) ; } builder . headers ( request . getAllHeaders ( ) ) ; builder . signedHeaders ( signedHeaders ) ; if ( request instanceof HttpEntityEnclosingRequest ) { HttpEntity entity = ( ( HttpEntityEnclosingRequest ) request ) . getEntity ( ) ; builder . requestBody ( CharStreams . toString ( new InputStreamReader ( entity . getContent ( ) , Charsets . UTF_8 ) ) ) ; } return builder . build ( ) ; }
Create a ValidationToken from an HTTP Request.

@param  accountSid Twilio Account SID
@param  credentialSid Twilio Credential SID
@param  signingKeySid Twilio Signing Key SID
@param  privateKey Private Key
@param  request HTTP Request
@param  signedHeaders Headers to sign

@throws IOException when unable to generate
@return The ValidationToken generated from the HttpRequest