/** * Sign the given HTTP method object using the AWS credentials provided * by {@link #getAWSCredentials()}. * * @param httpMethod the request object * @param context * @param ignoredForceRequestSignatureVersion * ignored parameter relevant only for AWS4-HMAC-SHA256 request signing. * @throws ServiceException */ public void authorizeHttpRequest(HttpUriRequest httpMethod, HttpContext context, String ignoredForceRequestSignatureVersion) throws ServiceException { String date = ServiceUtils.formatRfc822Date(getCurrentTimeWithOffset()); // Set/update the date timestamp to the current time // Note that this will be over-ridden if an "x-amz-date" header is present. httpMethod.setHeader("Date", date); // Sign the date to authenticate the request. // Sign the canonical string. String signature = ServiceUtils.signWithHmacSha1( getAWSCredentials().getSecretKey(), date); // Add encoded authorization to connection as HTTP Authorization header. String authorizationString = "AWS " + getAWSCredentials().getAccessKey() + ":" + signature; httpMethod.setHeader("Authorization", authorizationString); }
/** * Sign the given HTTP method object using the AWS credentials provided * by {@link #getAWSCredentials()}. * * @param httpMethod the request object * @param context * @param ignoredForceRequestSignatureVersion * ignored parameter relevant only for AWS4-HMAC-SHA256 request signing. * @throws ServiceException */ public void authorizeHttpRequest(HttpUriRequest httpMethod, HttpContext context, String ignoredForceRequestSignatureVersion) throws ServiceException { String date = ServiceUtils.formatRfc822Date(getCurrentTimeWithOffset()); // Set/update the date timestamp to the current time // Note that this will be over-ridden if an "x-amz-date" header is present. httpMethod.setHeader("Date", date); // Sign the date to authenticate the request. // Sign the canonical string. String signature = ServiceUtils.signWithHmacSha1( getAWSCredentials().getSecretKey(), date); // Add encoded authorization to connection as HTTP Authorization header. String authorizationString = "AWS " + getAWSCredentials().getAccessKey() + ":" + signature; httpMethod.setHeader("Authorization", authorizationString); }