List of usage examples for com.amazonaws.services.cloudfront CloudFrontUrlSigner getSignedURLWithCannedPolicy
public static String getSignedURLWithCannedPolicy(String resourceUrlOrPath, String keyPairId, PrivateKey privateKey, Date dateLessThan)
From source file:org.nuxeo.ecm.core.storage.sql.CloudFrontBinaryManager.java
License:Apache License
@Override protected URI getRemoteUri(String digest, ManagedBlob blob, HttpServletRequest servletRequest) throws IOException { try {//from w ww.ja v a2 s. c o m URIBuilder uriBuilder = new URIBuilder(buildResourcePath(bucketNamePrefix + digest)); if (blob != null) { uriBuilder.addParameter("response-content-type", getContentTypeHeader(blob)); uriBuilder.addParameter("response-content-disposition", getContentDispositionHeader(blob, servletRequest)); } if (isBooleanPropertyTrue(ENABLE_CF_ENCODING_FIX)) { String trimmedChars = " "; uriBuilder.getQueryParams().stream().filter(s -> s.getValue().contains(trimmedChars)) .forEach(s -> uriBuilder.setParameter(s.getName(), s.getValue().replace(trimmedChars, ""))); } URI uri = uriBuilder.build(); if (privKey == null) { return uri; } Date expiration = new Date(); expiration.setTime(expiration.getTime() + directDownloadExpire * 1000); String signedURL = CloudFrontUrlSigner.getSignedURLWithCannedPolicy(uri.toString(), privKeyId, privKey, expiration); return new URI(signedURL); } catch (URISyntaxException e) { throw new IOException(e); } }