devabhishekpal commented on code in PR #7268:
URL: https://github.com/apache/ozone/pull/7268#discussion_r1817193219
##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/OzoneAdmins.java:
##########
@@ -186,4 +192,91 @@ public static Collection<String>
getOzoneReadOnlyAdminsGroupsFromConfig(
return conf.getTrimmedStringCollection(
OZONE_READONLY_ADMINISTRATORS_GROUPS);
}
+
+ /**
+ * Get the list of S3 administrators from Ozone config.
+ * <p/>
+ * <strong>Notes</strong>:
+ * <ul>
+ * <li>If <code>ozone.s3.administrators</code> value is empty string or
unset,
+ * defaults to <code>ozone.administrators</code> value.</li>
+ * <li>If current user is not part of the administrators group,
+ * {@link UserGroupInformation#getCurrentUser()} will be added to the
resulting list</li>
+ * </ul>
+ * @param conf An instance of {@link OzoneConfiguration} being used
+ * @return A {@link Collection} of the S3 administrator users
+ *
+ */
+ public static Set<String> getS3AdminsFromConfig(OzoneConfiguration conf)
throws IOException {
+ Set<String> ozoneAdmins = new
HashSet<>(conf.getTrimmedStringCollection(OZONE_S3_ADMINISTRATORS));
+
+ if (ozoneAdmins.isEmpty()) {
+ ozoneAdmins = new
HashSet<>(conf.getTrimmedStringCollection(OZONE_ADMINISTRATORS));
+ }
+
+ String omSPN = UserGroupInformation.getCurrentUser().getShortUserName();
+ if (!ozoneAdmins.contains(omSPN)) {
Review Comment:
Thanks for pointing this out, addressed in
[e569e5f](https://github.com/apache/ozone/pull/7268/commits/e569e5f31b92e6426b3797d0a436457fe59b3da0)
##########
hadoop-hdds/framework/src/test/java/org/apache/hadoop/hdds/server/TestOzoneAdmins.java:
##########
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
under
+ * the License.
+ *
+ */
+
+package org.apache.hadoop.hdds.server;
+
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.ozone.OzoneConfigKeys;
+import org.apache.hadoop.security.UserGroupInformation;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.CsvSource;
+import org.junit.jupiter.params.provider.ValueSource;
+
+import java.io.IOException;
+import java.util.Arrays;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * This class is to test the utilities present in the OzoneAdmins class.
+ */
+class TestOzoneAdmins {
Review Comment:
Addressed in
[e569e5f](https://github.com/apache/ozone/pull/7268/commits/e569e5f31b92e6426b3797d0a436457fe59b3da0)
--
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]