public static String generateS3HostnameForBucket(String bucketName, boolean isDnsBucketNamingDisabled, String s3Endpoint) { if (isBucketNameValidDNSName(bucketName) && !isDnsBucketNamingDisabled) { return bucketName + "." + s3Endpoint; } else { return s3Endpoint; } }
public static String generateS3HostnameForBucket(String bucketName, boolean isDnsBucketNamingDisabled, String s3Endpoint) { if (isBucketNameValidDNSName(bucketName) && !isDnsBucketNamingDisabled) { return bucketName + "." + s3Endpoint; } else { return s3Endpoint; } }
@Override public boolean isSupported(final Path workdir, final String name) { if(workdir.isRoot()) { if(StringUtils.isNotBlank(name)) { return ServiceUtils.isBucketNameValidDNSName(name); } } return true; }
private void checkBucketName(Document doc) { String bucketName = ""; try { bucketName = doc.getText(0, doc.getLength()); } catch (BadLocationException e) { } if (ServiceUtils.isBucketNameValidDNSName(bucketName)) { bucketNameIsValidDNSResultLabel.setText("Yes"); okButton.setEnabled(true); } else { bucketNameIsValidDNSResultLabel.setText("No"); // OK button should not be enabled for non-US locations okButton.setEnabled(bucketLocationComboBox.getSelectedIndex() == 0); } } });
private void checkBucketName(Document doc) { String bucketName = ""; try { bucketName = doc.getText(0, doc.getLength()); } catch (BadLocationException e) { } if (ServiceUtils.isBucketNameValidDNSName(bucketName)) { bucketNameIsValidDNSResultLabel.setText("Yes"); okButton.setEnabled(true); } else { bucketNameIsValidDNSResultLabel.setText("No"); // OK button should not be enabled for non-US locations okButton.setEnabled(bucketLocationComboBox.getSelectedIndex() == 0); } } });
/** * Distribution methods supported by this S3 provider. * * @return Download and Streaming for AWS. */ @Override public List<Distribution.Method> getMethods(final Path container) { if(!ServiceUtils.isBucketNameValidDNSName(container.getName())) { // Disable website configuration if bucket name is not DNS compatible return super.getMethods(container); } final List<Distribution.Method> methods = new ArrayList<Distribution.Method>(); if(session.getHost().getHostname().endsWith(preferences.getProperty("s3.hostname.default"))) { methods.addAll(super.getMethods(container)); methods.addAll(Arrays.asList(Distribution.WEBSITE, Distribution.WEBSITE_CDN)); } else { // Only allow website configuration for non AWS endpoints. methods.add(Distribution.WEBSITE); } return methods; }
userBucketName, disableDnsBuckets, s3Endpoint); if (!ServiceUtils.isBucketNameValidDNSName(userBucketName)) {
userBucketName, disableDnsBuckets, s3Endpoint); if (!ServiceUtils.isBucketNameValidDNSName(userBucketName)) {
/** * Generates a URL string that will return a Torrent file for an object in S3, * which file can be downloaded and run in a BitTorrent client. * * @param bucket the name of the bucket containing the object. * @param key the name of the object. * @return a URL to a Torrent file representing the object. */ public String create(final String bucket, final String key) { String s3Endpoint = endpoint.getHostname(); String serviceEndpointVirtualPath = ""; String bucketNameInPath = ServiceUtils.isBucketNameValidDNSName(bucket) ? "" : RestUtils.encodeUrlString(bucket) + "/"; String urlPath = RestUtils.encodeUrlPath(serviceEndpointVirtualPath, "/") + "/" + bucketNameInPath + RestUtils.encodeUrlPath(key, "/"); return "http://" + ServiceUtils.generateS3HostnameForBucket( bucket, false, s3Endpoint) + urlPath + "?torrent"; } }
private String getHostnameForContainer(final Path bucket) { if(!ServiceUtils.isBucketNameValidDNSName(containerService.getContainer(bucket).getName())) { return session.getHost().getHostname(); } if(session.getHost().getHostname().equals(session.getHost().getProtocol().getDefaultHostname())) { return String.format("%s.%s", bucket.getName(), session.getHost().getHostname()); } return session.getHost().getHostname(); } }
@Override public void setStatus(final Path file, final boolean enabled) throws BackgroundException { final Path bucket = containerService.getContainer(file); try { if(!ServiceUtils.isBucketNameValidDNSName(bucket.getName())) { throw new InteroperabilityException("The name of the bucket used for Transfer Acceleration must be DNS-compliant and must not contain periods."); } session.getClient().setAccelerateConfig(bucket.getName(), new AccelerateConfig(enabled)); } catch(S3ServiceException failure) { throw new S3ExceptionMappingService().map("Failure to write attributes of {0}", failure, bucket); } }
public void create(final Path bucket, final String location) throws BackgroundException { if(!session.configure().getBoolProperty("s3service.disable-dns-buckets", false)) { if(!ServiceUtils.isBucketNameValidDNSName(bucket.getName())) { throw new InteroperabilityException(LocaleFactory.localizedString("Bucket name is not DNS compatible", "S3")); } } AccessControlList acl; if(PreferencesFactory.get().getProperty("s3.bucket.acl.default").equals("public-read")) { acl = AccessControlList.REST_CANNED_PUBLIC_READ; } else { acl = AccessControlList.REST_CANNED_PRIVATE; } try { final String region; if("us-east-1".equals(location)) { region = "US"; } else { region = location; } // Create bucket session.getClient().createBucket(URIEncoder.encode(containerService.getContainer(bucket).getName()), region, acl); } catch(ServiceException e) { throw new S3ExceptionMappingService().map("Cannot create folder {0}", e, bucket); } } }
public void create(final Path bucket, final String location) throws BackgroundException { // Create bucket if(!ServiceUtils.isBucketNameValidDNSName(bucket.getName())) { throw new InteroperabilityException(LocaleFactory.localizedString("Bucket name is not DNS compatible", "S3")); } AccessControlList acl; if(PreferencesFactory.get().getProperty("s3.bucket.acl.default").equals("public-read")) { acl = GSAccessControlList.REST_CANNED_PUBLIC_READ; } else { acl = GSAccessControlList.REST_CANNED_PRIVATE; } try { session.getClient().createBucket(new S3PathContainerService().getContainer(bucket).getName(), location, acl); } catch(ServiceException e) { throw new S3ExceptionMappingService().map("Cannot create folder {0}", e, bucket); } } }
!disableDnsBuckets && ServiceUtils.isBucketNameValidDNSName(bucketName) ? "" : RestUtils.encodeUrlString(bucketName) + "/";
!disableDnsBuckets && ServiceUtils.isBucketNameValidDNSName(bucketName) ? "" : RestUtils.encodeUrlString(bucketName) + "/";