HttpMethodName httpMethod = HttpMethodName.valueOf(req.getMethod().toString());
private S3Signer createSigV2Signer(final Request<?> request, final String bucketName, final String key) { String resourcePath = "/" + ((bucketName != null) ? bucketName + "/" : "") + ((key != null) ? key : ""); return new S3Signer(request.getHttpMethod().toString(), resourcePath); }
public static boolean usePayloadForQueryParameters(SignableRequest<?> request) { boolean requestIsPOST = HttpMethodName.POST.equals(request.getHttpMethod()); boolean requestHasNoPayload = (request.getContent() == null); return requestIsPOST && requestHasNoPayload; }
/** * @param value Raw string representing value of enum * @return HttpMethodName enum or null if value is not present. * @throws IllegalArgumentException If value does not represent a known enum value. */ public static HttpMethodName fromValue(String value) { if (StringUtils.isNullOrEmpty(value)) { return null; } final String upperCaseValue = StringUtils.upperCase(value); for (HttpMethodName httpMethodName : values()) { if (httpMethodName.name().equals(upperCaseValue)) { return httpMethodName; } } throw new IllegalArgumentException("Unsupported HTTP method name " + value); }
protected GenericApiGatewayRequest configureRequest(final ProcessContext context, final ProcessSession session, final String resourcePath, final FlowFile requestFlowFile) { String method = trimToEmpty( context.getProperty(PROP_METHOD).evaluateAttributeExpressions(requestFlowFile) .getValue()).toUpperCase(); HttpMethodName methodName = HttpMethodName.fromValue(method); return configureRequest(context, session, resourcePath,requestFlowFile, methodName); }
private static HttpMethod toNettyHttpMethod(HttpMethodName method) { return HttpMethod.valueOf(method.name()); } }
&& validationContext.isExpressionLanguagePresent(method))) { try { HttpMethodName methodName = HttpMethodName.fromValue(method); } catch (IllegalArgumentException e) { results.add(new ValidationResult.Builder().subject(PROP_METHOD.getName()).input(method)
/** * @param value Raw string representing value of enum * @return HttpMethodName enum or null if value is not present. * @throws IllegalArgumentException If value does not represent a known enum value. */ public static HttpMethodName fromValue(String value) { if (StringUtils.isNullOrEmpty(value)) { return null; } final String upperCaseValue = StringUtils.upperCase(value); for (HttpMethodName httpMethodName : values()) { if (httpMethodName.name().equals(upperCaseValue)) { return httpMethodName; } } throw new IllegalArgumentException("Unsupported HTTP method name " + value); }
protected boolean shouldAddContentUnsignedPayloadInHeader(final String httpMethodName) { return HttpMethodName.POST.name().equals(httpMethodName); } }
/** * Step 1 of the AWS Signature version 4 calculation. Refer to * http://docs.aws * .amazon.com/general/latest/gr/sigv4-create-canonical-request.html to * generate the canonical request. */ protected String createCanonicalRequest(SignableRequest<?> request, String contentSha256) { /* This would url-encode the resource path for the first time. */ final String path = SdkHttpUtils.appendUri( request.getEndpoint().getPath(), request.getResourcePath()); final StringBuilder canonicalRequestBuilder = new StringBuilder(request .getHttpMethod().toString()); canonicalRequestBuilder.append(LINE_SEPARATOR) // This would optionally double url-encode the resource path .append(getCanonicalizedResourcePath(path, doubleUrlEncode)) .append(LINE_SEPARATOR) .append(getCanonicalizedQueryString(request)) .append(LINE_SEPARATOR) .append(getCanonicalizedHeaderString(request)) .append(LINE_SEPARATOR) .append(getSignedHeadersString(request)).append(LINE_SEPARATOR) .append(contentSha256); final String canonicalRequest = canonicalRequestBuilder.toString(); if (log.isDebugEnabled()) log.debug("AWS4 Canonical Request: '\"" + canonicalRequest + "\""); return canonicalRequest; }
/** * Sets HTTP method to the {@link Request} object. If the given method is * none of GET, POST, PUT, DELETE, and HEAD, then it will be tunneled via * X-HTTP-Method-Override. Note that not all servers support this header. * * @param request request to be set * @param httpMethod given http method * @param hasContent indicate whether the request has content body */ void setHttpMethod(Request<?> request, String httpMethod, boolean hasContent) { try { request.setHttpMethod(HttpMethodName.valueOf(httpMethod)); } catch (final IllegalArgumentException iae) { // if an HTTP method is unsupported, then 'tunnel' it through // another method by setting the intended method in the // X-HTTP-Method-Override header. request.addHeader("X-HTTP-Method-Override", httpMethod); // depending on whether the request has content or not, choose an // appropriate method. request.setHttpMethod(hasContent ? HttpMethodName.POST : HttpMethodName.GET); } }
/** * @param request the request. * @return true if request is post and request has no payload. */ public static boolean usePayloadForQueryParameters(Request<?> request) { final boolean requestIsPOST = HttpMethodName.POST.equals(request.getHttpMethod()); final boolean requestHasNoPayload = (request.getContent() == null); return requestIsPOST && requestHasNoPayload; }
@Override public HttpMethodName getHttpMethod() { return HttpMethodName.fromValue(urlConnection.getRequestMethod()); }
/** * @param value Raw string representing value of enum * @return HttpMethodName enum or null if value is not present. * @throws IllegalArgumentException If value does not represent a known enum value. */ public static HttpMethodName fromValue(String value) { if (StringUtils.isNullOrEmpty(value)) { return null; } final String upperCaseValue = StringUtils.upperCase(value); for (HttpMethodName httpMethodName : values()) { if (httpMethodName.name().equals(upperCaseValue)) { return httpMethodName; } } throw new IllegalArgumentException("Unsupported HTTP method name " + value); }
private static HttpMethod toNettyHttpMethod(HttpMethodName method) { return HttpMethod.valueOf(method.name()); } }
stringToSign = request.getHttpMethod().toString() + "\n" + getCanonicalizedResourcePath(path) + "\n" + getCanonicalizedQueryString(request.getParameters()) + "\n"
final HttpMethodName httpMethod = HttpMethodName.valueOf(generatePresignedUrlRequest.getMethod() .toString());
public static boolean usePayloadForQueryParameters(SignableRequest<?> request) { boolean requestIsPOST = HttpMethodName.POST.equals(request.getHttpMethod()); boolean requestHasNoPayload = (request.getContent() == null); return requestIsPOST && requestHasNoPayload; }
protected GenericApiGatewayRequest configureRequest(final ProcessContext context, final ProcessSession session, final String resourcePath, final FlowFile requestFlowFile) { String method = trimToEmpty( context.getProperty(PROP_METHOD).evaluateAttributeExpressions(requestFlowFile) .getValue()).toUpperCase(); HttpMethodName methodName = HttpMethodName.fromValue(method); return configureRequest(context, session, resourcePath,requestFlowFile, methodName); }
@Override protected String calculateContentHash(final SignableRequest<?> request) { if (shouldAddContentUnsignedPayloadInHeader(request.getHttpMethod().name())) { return CONTENT_UNSIGNED_PAYLOAD; } return super.calculateContentHash(request); }