You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by na...@apache.org on 2018/01/11 15:41:04 UTC

[21/50] [abbrv] jclouds git commit: JCLOUDS-1370: Add CannedAccessPolicy constants

JCLOUDS-1370: Add CannedAccessPolicy constants

Also use CaseFormat instead of extra logic.


Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/5ca4827d
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/5ca4827d
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/5ca4827d

Branch: refs/heads/keystonev3
Commit: 5ca4827d1bebd9adb5e03a7e6608e60ed8ac8f5b
Parents: 8cd68a3
Author: Andrew Gaul <ga...@apache.org>
Authored: Fri Jan 5 00:45:24 2018 -0800
Committer: Andrew Gaul <ga...@apache.org>
Committed: Tue Jan 9 13:06:47 2018 -0800

----------------------------------------------------------------------
 .../jclouds/s3/domain/CannedAccessPolicy.java   | 51 +++++++++++---------
 1 file changed, 29 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds/blob/5ca4827d/apis/s3/src/main/java/org/jclouds/s3/domain/CannedAccessPolicy.java
----------------------------------------------------------------------
diff --git a/apis/s3/src/main/java/org/jclouds/s3/domain/CannedAccessPolicy.java b/apis/s3/src/main/java/org/jclouds/s3/domain/CannedAccessPolicy.java
index 46a4caf..96688b4 100644
--- a/apis/s3/src/main/java/org/jclouds/s3/domain/CannedAccessPolicy.java
+++ b/apis/s3/src/main/java/org/jclouds/s3/domain/CannedAccessPolicy.java
@@ -16,6 +16,8 @@
  */
 package org.jclouds.s3.domain;
 
+import com.google.common.base.CaseFormat;
+
 /**
  * Description from Amazon's documentation:
  * 
@@ -36,34 +38,49 @@ public enum CannedAccessPolicy {
     /**
      * Owner gets FULL_CONTROL. No one else has access rights (default).
      */
-    PRIVATE("private"),
+    PRIVATE,
     /**
      * Owner gets FULL_CONTROL and the anonymous identity is granted READ
      * access. If this policy is used on an object, it can be read from a
      * browser with no authentication.
      */
-    PUBLIC_READ("public-read"),
+    PUBLIC_READ,
     /**
      * Owner gets FULL_CONTROL, the anonymous identity is granted READ and
      * WRITE access. This can be a useful policy to apply to a bucket, but is
      * generally not recommended.
      */
-    PUBLIC_READ_WRITE("public-read-write"),
+    PUBLIC_READ_WRITE,
+    /**
+     * Owner gets FULL_CONTROL. Amazon EC2 gets READ access to GET an Amazon
+     * Machine Image (AMI) bundle from Amazon S3.
+     */
+    AWS_EXEC_READ,
     /**
      * Owner gets FULL_CONTROL, and any identity authenticated as a registered
      * Amazon S3 user is granted READ access.
      */
-    AUTHENTICATED_READ("authenticated-read");
-
-    private String policyName;
-
-    CannedAccessPolicy(String policyName) {
-	this.policyName = policyName;
-    }
+    AUTHENTICATED_READ,
+    /**
+     * Object owner gets FULL_CONTROL. Bucket owner gets READ access. If you
+     * specify this canned ACL when creating a bucket, Amazon S3 ignores it.
+     */
+    BUCKET_OWNER_READ,
+    /**
+     * Both the object owner and the bucket owner get FULL_CONTROL over the
+     * object. If you specify this canned ACL when creating a bucket, Amazon S3
+     * ignores it.
+     */
+    BUCKET_OWNER_FULL_CONTROL,
+    /**
+     * The LogDelivery group gets WRITE and READ_ACP permissions on the bucket.
+     * For more information about logs, see (Server Access Logging).
+     */
+    LOG_DELIVERY_WRITE;
 
     @Override
     public String toString() {
-	return policyName;
+       return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name());
     }
     
     /**
@@ -77,16 +94,6 @@ public enum CannedAccessPolicy {
      * policy.
      */
     public static CannedAccessPolicy fromHeader(String capHeader) {
-       if ("private".equals(capHeader)) {
-          return CannedAccessPolicy.PRIVATE;
-       } else if ("public-read".equals(capHeader)) {
-          return CannedAccessPolicy.PUBLIC_READ;
-       } else if ("public-read-write".equals(capHeader)) {
-          return CannedAccessPolicy.PUBLIC_READ_WRITE;
-       } else if ("authenticated-read".equals(capHeader)) {
-          return CannedAccessPolicy.AUTHENTICATED_READ;
-       } else {
-          return null;
-       }
+       return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, capHeader));
     }
 }