/** * Convience method that allows the DNS rules to be altered for different SDKs. */ public static boolean isDNSBucketName(String bucketName) { return isValidV2BucketName( bucketName ); }
/** * Returns true if the specified bucket name can be addressed using V2, * virtual host style, addressing. Otherwise, returns false indicating that * the bucket must be addressed using V1, path style, addressing. * * @param bucketName * The name of the bucket to check. * * @return True if the specified bucket name can be addressed in V2, virtual * host style, addressing otherwise false if V1, path style, * addressing is required. */ public static boolean isValidV2BucketName(String bucketName) { return isValidV2BucketName(bucketName, false); }
/** * Validates that the specified bucket name is valid for Amazon S3 V2 naming * (i.e. DNS addressable in virtual host style). Throws an * IllegalArgumentException if the bucket name is not valid. * <p> * S3 bucket naming guidelines are specified in <a href="http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html?BucketRestrictions.html" * > http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html? * BucketRestrictions.html</a> * * @param bucketName * The bucket name to validate. * * @throws IllegalArgumentException * If the specified bucket name doesn't follow Amazon S3's * guidelines. */ public static void validateBucketName(final String bucketName) { isValidV2BucketName(bucketName, true); }
/** * Convience method that allows the DNS rules to be altered for different * SDKs. * * @param bucketName the name of the bucket. * @return true if the name is valid, false if not. */ public static boolean isDNSBucketName(String bucketName) { return isValidV2BucketName(bucketName); }
/** * Returns true if the specified bucket name can be addressed using V2, * virtual host style, addressing. Otherwise, returns false indicating that * the bucket must be addressed using V1, path style, addressing. * * @param bucketName The name of the bucket to check. * @return True if the specified bucket name can be addressed in V2, virtual * host style, addressing otherwise false if V1, path style, * addressing is required. */ public static boolean isValidV2BucketName(String bucketName) { return isValidV2BucketName(bucketName, false); }
/** * Validates that the specified bucket name is valid for Amazon S3 V2 naming * (i.e. DNS addressable in virtual host style). Throws an * IllegalArgumentException if the bucket name is not valid. * <p> * S3 bucket naming guidelines are specified in <a href= * "http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html?BucketRestrictions.html" * > http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html? * BucketRestrictions.html</a> * * @param bucketName The bucket name to validate. * @throws IllegalArgumentException If the specified bucket name doesn't * follow Amazon S3's guidelines. */ public static void validateBucketName(final String bucketName) { isValidV2BucketName(bucketName, true); }
@Test(expected = IllegalArgumentException.class) public void testInvalidV2BucketNames() { assertFalse(BucketNameUtils.isValidV2BucketName(null)); assertFalse(BucketNameUtils.isValidV2BucketName("sm")); assertFalse(BucketNameUtils.isValidV2BucketName("UPPERCASE")); assertFalse(BucketNameUtils.isValidV2BucketName("contains.dot")); assertFalse(BucketNameUtils.isValidV2BucketName("white space")); assertFalse(BucketNameUtils.isValidV2BucketName("adjacent..periods")); assertFalse(BucketNameUtils.isValidV2BucketName("dash.-nexttoperiod")); char invalid[] = { '9' }; invalid[0]++; assertFalse(BucketNameUtils.isValidV2BucketName( String.valueOf(invalid))); assertFalse(BucketNameUtils.isValidV2BucketName("endingperiod.")); BucketNameUtils.validateBucketName("endingdash-"); } }
/** * Convience method that allows the DNS rules to be altered for different SDKs. */ public static boolean isDNSBucketName(String bucketName) { return isValidV2BucketName( bucketName ); }
/** * Convience method that allows the DNS rules to be altered for different * SDKs. * * @param bucketName the name of the bucket. * @return true if the name is valid, false if not. */ public static boolean isDNSBucketName(String bucketName) { return isValidV2BucketName(bucketName); }
/** * Returns true if the specified bucket name can be addressed using V2, * virtual host style, addressing. Otherwise, returns false indicating that * the bucket must be addressed using V1, path style, addressing. * * @param bucketName The name of the bucket to check. * @return True if the specified bucket name can be addressed in V2, virtual * host style, addressing otherwise false if V1, path style, * addressing is required. */ public static boolean isValidV2BucketName(String bucketName) { return isValidV2BucketName(bucketName, false); }
/** * Validates that the specified bucket name is valid for Amazon S3 V2 naming * (i.e. DNS addressable in virtual host style). Throws an * IllegalArgumentException if the bucket name is not valid. * <p> * S3 bucket naming guidelines are specified in <a href= * "http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html?BucketRestrictions.html" * > http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html? * BucketRestrictions.html</a> * * @param bucketName The bucket name to validate. * @throws IllegalArgumentException If the specified bucket name doesn't * follow Amazon S3's guidelines. */ public static void validateBucketName(final String bucketName) { isValidV2BucketName(bucketName, true); }
/** * Returns true if the specified bucket name can be addressed using V2, * virtual host style, addressing. Otherwise, returns false indicating that * the bucket must be addressed using V1, path style, addressing. * * @param bucketName * The name of the bucket to check. * * @return True if the specified bucket name can be addressed in V2, virtual * host style, addressing otherwise false if V1, path style, * addressing is required. */ public static boolean isValidV2BucketName(String bucketName) { return isValidV2BucketName(bucketName, false); }
/** * Validates that the specified bucket name is valid for Amazon S3 V2 naming * (i.e. DNS addressable in virtual host style). Throws an * IllegalArgumentException if the bucket name is not valid. * <p> * S3 bucket naming guidelines are specified in <a href="http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html?BucketRestrictions.html" * > http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html? * BucketRestrictions.html</a> * * @param bucketName * The bucket name to validate. * * @throws IllegalArgumentException * If the specified bucket name doesn't follow Amazon S3's * guidelines. */ public static void validateBucketName(final String bucketName) { isValidV2BucketName(bucketName, true); }