/** * Based on the given {@link GetObjectRequest}, returns whether the specified request should * skip MD5 check on the requested object content. Specifically, MD5 check should be skipped if * one of the following conditions are true: * <ol> * <li>The system property {@value #DISABLE_GET_OBJECT_MD5_VALIDATION_PROPERTY} is set.</li> * <li>The request is a range-get operation</li> * <li>The request is a GET object operation that involves SSE-C</li> * </ol> * Otherwise, MD5 check should not be skipped. */ public boolean skipClientSideValidationPerRequest(GetObjectRequest request) { if (isGetObjectMd5ValidationDisabledByProperty()) { return true; } // Skip MD5 check for range get if (request.getRange() != null) { return true; } if (request.getSSECustomerKey() != null) { return true; } return false; }
long[] range = req.getRange(); long lastByte = range[1]; long totalBytesToDownload = lastByte - this.origStartingByte + 1;
/** * Returns true if the specified download request can use parallel part * downloads for increased performance. * * @param getObjectRequest * The request to check. * * @param s3 * The Amazon s3 client. * * @return True if this request can use parallel part downloads. */ public static boolean isDownloadParallelizable(final AmazonS3 s3, final GetObjectRequest getObjectRequest, Integer partCount) { ValidationUtils.assertNotNull(s3, "S3 client"); ValidationUtils.assertNotNull(getObjectRequest, "GetObjectRequest"); if (s3 instanceof AmazonS3Encryption || getObjectRequest.getRange() != null || getObjectRequest.getPartNumber() != null || partCount == null) { return false; } return true; } }
/** * Returns the captured state of the download; or null if it should not be * captured (for security reason). */ private PersistableDownload captureDownloadState( final GetObjectRequest getObjectRequest, final File file) { if (getObjectRequest.getSSECustomerKey() == null) { return new PersistableDownload( getObjectRequest.getBucketName(), getObjectRequest.getKey(), getObjectRequest.getVersionId(), getObjectRequest.getRange(), getObjectRequest.getResponseHeaders(), getObjectRequest.isRequesterPays(), file.getAbsolutePath(), getLastFullyDownloadedPartNumber(), getObjectMetadata().getLastModified().getTime(), getLastFullyDownloadedFilePosition()); } return null; }
long[] desiredRange = req.getRange(); if (isStrict() && (desiredRange != null || req.getPartNumber() != null)) throw new SecurityException("Range get and getting a part are not allowed in strict crypto mode");
long lastByte; long[] range = getObjectRequest.getRange(); if (range != null && range.length == 2) { startingByte = range[0];
long[] range = getObjectRequest.getRange(); if (range != null) { request.addHeader(Headers.RANGE, "bytes=" + Long.toString(range[0]) + "-" + Long.toString(range[1]));
@Override public ObjectMetadata getObject(final GetObjectRequest getObjectRequest, File destinationFile) throws AmazonClientException, AmazonServiceException { assertParameterNotNull(destinationFile, "The destination file parameter must be specified when downloading an object directly to a file"); boolean mode = ServiceUtils.OVERWRITE_MODE; if (getObjectRequest.getRange() != null && getObjectRequest.getRange()[0] > 0) { mode = ServiceUtils.APPEND_MODE; } final S3Object s3Object = ServiceUtils.retryableDownloadS3ObjectToFile(destinationFile, new ServiceUtils.RetryableS3DownloadTask() { @Override public S3Object getS3ObjectStream() { return getObject(getObjectRequest); } @Override public boolean needIntegrityCheck() { return !ServiceUtils.skipMd5CheckPerRequest(getObjectRequest); } }, mode); // getObject can return null if constraints were specified but not met if (s3Object == null) { return null; } return s3Object.getObjectMetadata(); }
final GetObjectRequest getObjectRequest = (GetObjectRequest) request; if (getObjectRequest.getRange() != null) { return true;
/** * Returns the captured state of the download; or null if it should not be * captured (for security reason). */ private PersistableDownload captureDownloadState( final GetObjectRequest getObjectRequest, final File file) { if (getObjectRequest.getSSECustomerKey() == null) { return new PersistableDownload( getObjectRequest.getBucketName(), getObjectRequest.getKey(), getObjectRequest.getVersionId(), getObjectRequest.getRange(), getObjectRequest.getResponseHeaders(), getObjectRequest.isRequesterPays(), file.getAbsolutePath()); } return null; }
final long[] desiredRange = req.getRange(); if (isStrict() && (desiredRange != null || req.getPartNumber() != null)) { throw new SecurityException("Range get and getting a part are not allowed in strict crypto mode");
@Override public ObjectMetadata getObject(final GetObjectRequest getObjectRequest, File destinationFile) throws AmazonClientException, AmazonServiceException { assertParameterNotNull(destinationFile, "The destination file parameter must be specified when downloading an object directly to a file"); boolean mode = ServiceUtils.OVERWRITE_MODE; if (getObjectRequest.getRange() != null && getObjectRequest.getRange()[0] > 0) { mode = ServiceUtils.APPEND_MODE; } final S3Object s3Object = ServiceUtils.retryableDownloadS3ObjectToFile(destinationFile, new ServiceUtils.RetryableS3DownloadTask() { @Override public S3Object getS3ObjectStream() { return getObject(getObjectRequest); } @Override public boolean needIntegrityCheck() { return !ServiceUtils.skipMd5CheckPerRequest(getObjectRequest); } }, mode); // getObject can return null if constraints were specified but not met if (s3Object == null) { return null; } return s3Object.getObjectMetadata(); }
long[] range = req.getRange(); long lastByte = range[1]; long totalBytesToDownload = lastByte - this.origStartingByte + 1;
/** * Based on the given {@link GetObjectRequest}, returns whether the specified request should * skip MD5 check on the requested object content. Specifically, MD5 check should be skipped if * one of the following conditions are true: * <ol> * <li>The system property {@value #DISABLE_GET_OBJECT_MD5_VALIDATION_PROPERTY} is set.</li> * <li>The request is a range-get operation</li> * <li>The request is a GET object operation that involves SSE-C</li> * </ol> * Otherwise, MD5 check should not be skipped. */ public boolean skipClientSideValidationPerRequest(GetObjectRequest request) { if (isGetObjectMd5ValidationDisabledByProperty()) { return true; } // Skip MD5 check for range get if (request.getRange() != null) { return true; } if (request.getSSECustomerKey() != null) { return true; } return false; }
final long[] range = getObjectRequest.getRange(); if (range != null) { String rangeHeader = "bytes=" + Long.toString(range[0]) + "-";
/** * Returns true if the specified download request can use parallel part * downloads for increased performance. * * @param getObjectRequest * The request to check. * * @param s3 * The Amazon s3 client. * * @return True if this request can use parallel part downloads. */ public static boolean isDownloadParallelizable(final AmazonS3 s3, final GetObjectRequest getObjectRequest, Integer partCount) { ValidationUtils.assertNotNull(s3, "S3 client"); ValidationUtils.assertNotNull(getObjectRequest, "GetObjectRequest"); if (s3 instanceof AmazonS3Encryption || getObjectRequest.getRange() != null || getObjectRequest.getPartNumber() != null || partCount == null) { return false; } return true; } }
/** * Returns the captured state of the download; or null if it should not be * captured (for security reason). */ private PersistableDownload captureDownloadState( final GetObjectRequest getObjectRequest, final File file) { if (getObjectRequest.getSSECustomerKey() == null) { return new PersistableDownload( getObjectRequest.getBucketName(), getObjectRequest.getKey(), getObjectRequest.getVersionId(), getObjectRequest.getRange(), getObjectRequest.getResponseHeaders(), getObjectRequest.isRequesterPays(), file.getAbsolutePath()); } return null; }
final GetObjectRequest getObjectRequest = (GetObjectRequest) request; if (getObjectRequest.getRange() != null) { return true;
/** * Returns the captured state of the download; or null if it should not be * captured (for security reason). */ private PersistableDownload captureDownloadState( final GetObjectRequest getObjectRequest, final File file) { if (getObjectRequest.getSSECustomerKey() == null) { return new PersistableDownload( getObjectRequest.getBucketName(), getObjectRequest.getKey(), getObjectRequest.getVersionId(), getObjectRequest.getRange(), getObjectRequest.getResponseHeaders(), getObjectRequest.isRequesterPays(), file.getAbsolutePath(), getLastFullyDownloadedPartNumber(), getObjectMetadata().getLastModified().getTime()); } return null; }