@Override public void configure(final boolean enable, final Path file) { final Jets3tProperties options = session.getClient().getJetS3tProperties(); if(enable) { // Set accelerated endpoint options.setProperty("s3service.s3-endpoint", hostname); options.setProperty("s3service.disable-dns-buckets", String.valueOf(false)); options.setProperty("s3service.disable-expect-continue", String.valueOf(true)); } else { // Revert default configuration options.loadAndReplaceProperties(session.configure(), this.toString()); } }
@Override public void authorizeHttpRequest(final HttpUriRequest httpMethod, final HttpContext context, final String forceRequestSignatureVersion) throws ServiceException { if(forceRequestSignatureVersion != null) { final S3Protocol.AuthenticationHeaderSignatureVersion authenticationHeaderSignatureVersion = S3Protocol.AuthenticationHeaderSignatureVersion.valueOf(StringUtils.remove(forceRequestSignatureVersion, "-")); log.warn(String.format("Switched authentication signature version to %s", forceRequestSignatureVersion)); session.setSignatureVersion(authenticationHeaderSignatureVersion); } if(session.authorize(httpMethod, this.getProviderCredentials())) { return; } super.authorizeHttpRequest(httpMethod, context, forceRequestSignatureVersion); }
public S3MultipleDeleteFeature(final S3Session session, final S3MultipartService multipartService) { this.session = session; this.multipartService = multipartService; this.versioningService = session.getFeature(Versioning.class); }
private boolean accelerate(final Path file, final ConnectionCallback prompt) throws BackgroundException { switch(session.getSignatureVersion()) { case AWS2: return false; } if(accelerationService.getStatus(file)) { log.info(String.format("S3 transfer acceleration enabled for file %s", file)); return true; } if(preferences.getBoolean("s3.accelerate.prompt")) { if(accelerationService.prompt(session.getHost(), file, prompt)) { log.info(String.format("S3 transfer acceleration enabled for file %s", file)); return true; } } return false; } }
@Override protected Jets3tProperties configure() { final Jets3tProperties configuration = super.configure(); configuration.setProperty("s3service.enable-storage-classes", String.valueOf(false)); configuration.setProperty("s3service.disable-dns-buckets", String.valueOf(true)); return configuration; }
@Override public List<MultipartPart> list(final MultipartUpload multipart) throws BackgroundException { if(log.isInfoEnabled()) { log.info(String.format("List completed parts of %s", multipart.getUploadId())); } // This operation lists the parts that have been uploaded for a specific multipart upload. try { return session.getClient().multipartListParts(multipart); } catch(S3ServiceException e) { throw new S3ExceptionMappingService().map(MessageFormat.format("Upload {0} failed", multipart.getObjectKey()), e); } }
session.getClient().multipartAbortUpload(multipart); versionId.set(new VersionId(new S3TouchFeature(session).touch(file, new TransferStatus()).attributes().getVersionId())); final MultipartCompleted complete = session.getClient().multipartCompleteUpload(multipart, completed); if(log.isDebugEnabled()) { log.debug(String.format("Completed multipart upload for %s with checksum %s", if(session.getHost().getHostname().endsWith(preferences.getProperty("s3.hostname.default"))) { throw new ChecksumException(MessageFormat.format(LocaleFactory.localizedString("Upload {0} failed", "Error"), file.getName()), MessageFormat.format("Mismatch between MD5 hash {0} of uploaded data and ETag {1} returned by the server",
@Override protected Map<Path, Distribution> operate(final PasswordCallback callback, final Path file) throws BackgroundException { final DistributionConfiguration feature = session.getFeature(DistributionConfiguration.class); if(null == feature) { return Collections.emptyMap(); } final AttributedList<Path> containers = new S3BucketListService(session, new S3LocationFeature.S3Region(session.getHost().getRegion())).list(file, new DisabledListProgressListener()); final Map<Path, Distribution> distributions = new ConcurrentHashMap<>(); for(Path container : containers) { for(Distribution.Method method : feature.getMethods(container)) { if(Distribution.WEBSITE.equals(method)) { continue; } if(Distribution.WEBSITE_CDN.equals(method)) { continue; } final Distribution distribution = feature.read(container, method, new DisabledLoginCallback()); if(distribution.isEnabled()) { if(log.isInfoEnabled()) { log.info(String.format("Cache distribution %s", distribution)); } distributions.put(container, distribution); } } } return distributions; } }
public S3TokenExpiredResponseInterceptor(final S3Session session, final LoginCallback prompt) { this.host = session.getHost(); this.prompt = prompt; }
final String secret = store.findLoginPassword(session.getHost()); if(StringUtils.isBlank(secret)) { log.warn("No secret found in keychain required to sign temporary URL"); return DescriptiveUrl.EMPTY; String region = session.getHost().getRegion(); if(session.isConnected()) { if(session.getClient().getRegionEndpointCache().containsRegionForBucketName(containerService.getContainer(file).getName())) { region = session.getClient().getRegionEndpointCache() .getRegionForBucketName(containerService.getContainer(file).getName()); session.getHost(), session.getHost().getCredentials().getUsername(), secret, containerService.getContainer(file).getName(), region, containerService.getKey(file), expiry.getTimeInMillis())), DescriptiveUrl.Type.signed,
if(session.getHost().getCredentials().isAnonymousLogin()) { if(StringUtils.isEmpty(this.getContainer(session.getHost()))) { if(StringUtils.isNotBlank(session.getHost().getDefaultPath())) { if(containerService.isContainer(new Path(PathNormalizer.normalize(session.getHost().getDefaultPath()), EnumSet.of(Path.Type.directory)))) { final Path bucket = containerService.getContainer( new Path(PathNormalizer.normalize(session.getHost().getDefaultPath()), EnumSet.of(Path.Type.directory)) ); log.info(String.format("Using default %s path to determine bucket name %s", session.getHost().getDefaultPath(), bucket)); final AttributedList<Path> buckets = new AttributedList<>(Collections.singletonList(bucket)); listener.chunk(directory, buckets); log.warn(String.format("No bucket name given in hostname %s", session.getHost().getHostname())); final Path bucket = new Path(PathNormalizer.normalize(session.getHost().getHostname()), EnumSet.of(Path.Type.volume, Path.Type.directory)); final AttributedList<Path> buckets = new AttributedList<>(Collections.singletonList(bucket)); listener.chunk(directory, buckets); final Path bucket = new Path(PathNormalizer.normalize(this.getContainer(session.getHost())), EnumSet.of(Path.Type.volume, Path.Type.directory)); final AttributedList<Path> buckets = new AttributedList<>(Collections.singletonList(bucket)); listener.chunk(directory, buckets); final String bucketname = this.getContainer(session.getHost()); if(StringUtils.isNotEmpty(bucketname)) { final Path bucket = new Path(PathNormalizer.normalize(bucketname), EnumSet.of(Path.Type.volume, Path.Type.directory)); for(StorageBucket b : session.getClient().listAllBuckets()) { final Path bucket = new Path(PathNormalizer.normalize(b.getName()), EnumSet.of(Path.Type.volume, Path.Type.directory)); if(b.getOwner() != null) {
parameters.put("partNumber", String.valueOf(++partNumber)); final TransferStatus status = new TransferStatus().withParameters(parameters).length(len); switch(session.getSignatureVersion()) { case AWS4HMACSHA256: status.setChecksum(ChecksumComputeFactory.get(HashAlgorithm.sha256) .getDetails(file, status); try { session.getClient().putObjectWithRequestEntityImpl( containerService.getContainer(file).getName(), part, new ByteArrayEntity(content, off, len), parameters);
final Redundancy storageClassFeature = session.getFeature(Redundancy.class); if(storageClassFeature != null) { target.setStorageClass(storageClassFeature.getClass(file)); final Encryption encryptionFeature = session.getFeature(Encryption.class); if(encryptionFeature != null) { final Encryption.Algorithm encryption = encryptionFeature.getEncryption(file); session.getClient().updateObjectMetadata(containerService.getContainer(file).getName(), target);
return null; return super._getFeature(type);
/** * @return header prefix for Google Storage metadata headers: x-goog-meta-. */ @Override public String getRestMetadataPrefix() { return session.getRestMetadataPrefix(); }
/** * @return header prefix for general Google Storage headers: x-goog-. */ @Override public String getRestHeaderPrefix() { return session.getRestHeaderPrefix(); }
public CustomOriginCloudFrontDistributionConfiguration(final Host origin, final X509TrustManager trust, final X509KeyManager key) { // Configure with the same host as S3 to get the same credentials from the keychain. super(new S3Session(new Host(new S3Protocol(), new S3Protocol().getDefaultHostname(), origin.getCdnCredentials()), trust, key), Collections.emptyMap()); this.origin = origin; }
@Override protected Jets3tProperties configure() { final Jets3tProperties configuration = super.configure(); configuration.setProperty("s3service.enable-storage-classes", String.valueOf(false)); configuration.setProperty("s3service.disable-dns-buckets", String.valueOf(true)); return configuration; }
final MultipartUploadChunk chunk; try { chunk = session.getClient().multipartListUploadsChunked( containerService.getContainer(directory).getName(), containerService.getKey(directory), null, nextKeyMarker, nextUploadIdMarker, null, true);
.getDetails(file, status); multipart = session.getClient().multipartStartUpload(containerService.getContainer(file).getName(), object); if(log.isDebugEnabled()) { log.debug(String.format("Multipart upload started for %s with ID %s", multipart.getObjectKey(), multipart.getUploadId())); final MultipartCompleted complete = session.getClient().multipartCompleteUpload(multipart, completed); if(log.isInfoEnabled()) { log.info(String.format("Completed multipart upload for %s with %d parts and checksum %s", if(session.getHost().getHostname().endsWith(preferences.getProperty("s3.hostname.default"))) { throw new ChecksumException(MessageFormat.format(LocaleFactory.localizedString("Upload {0} failed", "Error"), file.getName()), MessageFormat.format("Mismatch between MD5 hash {0} of uploaded data and ETag {1} returned by the server",