use of com.bluenimble.platform.http.HttpParameter in project serverless by bluenimble.
the class AccessSecretKeysBasedHttpRequestSigner method sign.
@Override
public void sign(HttpRequest request) throws HttpRequestSignerException {
List<HttpParameter> params = request.getParameters();
String signature = null;
try {
URI uri = request.getURI();
signature = generate(params, uri.getScheme() + "://" + uri.getHost(), uri.getPort(), uri.getPath(), request.getName());
} catch (Throwable th) {
throw new HttpRequestSignerException(th);
}
if (SignaturePlaceHolder.Headers.equals(signatureParameterPlace)) {
List<HttpHeader> headers = request.getHeaders();
if (headers == null) {
headers = new ArrayList<HttpHeader>();
request.setHeaders(headers);
}
headers.add(new HttpHeaderImpl(HttpHeaders.AUTHORIZATION, scheme + " " + accessKey + ":" + signature));
} else {
if (signatureParameterName == null) {
signatureParameterName = "signature";
}
params.add(new HttpParameterImpl(signatureParameterName, encode(signature)));
}
}
use of com.bluenimble.platform.http.HttpParameter in project serverless by bluenimble.
the class AbstractHttpRequest method dumpParameters.
protected String dumpParameters() throws UnsupportedEncodingException {
if (parameters == null || parameters.isEmpty()) {
return null;
}
StringBuilder sb = new StringBuilder();
for (HttpParameter p : parameters) {
p.dump(sb, charset);
if (parameters.indexOf(p) < (parameters.size() - 1)) {
sb.append("&");
}
}
String s = sb.toString();
sb.setLength(0);
sb = null;
return s;
}
Aggregations