ivandika3 commented on code in PR #8558:
URL: https://github.com/apache/ozone/pull/8558#discussion_r2146386006


##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/S3Owner.java:
##########
@@ -80,4 +85,57 @@ public String toString() {
         ", id='" + id + '\'' +
         '}';
   }
+
+  /**
+   * Verify the bucket owner condition.
+   *
+   * @param headers       HTTP headers
+   * @param bucketName    bucket name
+   * @param bucketOwner   bucket owner
+   * @throws OS3Exception if the expected bucket owner does not match
+   */
+  public static void verifyBucketOwnerCondition(HttpHeaders headers, String 
bucketName, String bucketOwner)
+      throws OS3Exception {
+    if (headers == null || bucketOwner == null) {
+      return;
+    }
+
+    final String expectedBucketOwner = 
headers.getHeaderString(S3Consts.EXPECTED_BUCKET_OWNER_HEADER);
+
+    if (StringUtils.isEmpty(expectedBucketOwner)) {
+      return;
+    }
+    if (expectedBucketOwner.equals(bucketOwner)) {
+      return;
+    }
+    throw S3ErrorTable.newError(S3ErrorTable.BUCKET_OWNER_MISMATCH, 
bucketName);
+  }
+
+  /**
+   * Verify the bucket owner condition on copy operation.
+   *
+   * @param headers       HTTP headers
+   * @param bucketName    bucket name
+   * @param sourceOwner   source bucket owner
+   * @param destOwner     destination bucket owner
+   * @throws OS3Exception if the expected source or destination bucket owner 
does not match
+   */
+  public static void verifyBucketOwnerConditionOnCopyOperation(HttpHeaders 
headers, String bucketName,
+                                                               String 
sourceOwner, String destOwner)

Review Comment:
   Since `copyObject` can be done across bucket, we need to specify both the 
`destBucketName` and `sourceBucketName` and use that in the 
`S3ErrorTable.newError(S3ErrorTable.BUCKET_OWNER_MISMATCH`)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to