devabhishekpal commented on code in PR #7268: URL: https://github.com/apache/ozone/pull/7268#discussion_r1807926181
########## hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/conf/OzoneS3ConfigUtils.java: ########## @@ -0,0 +1,133 @@ +/* + * 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.ozone.conf; + +import org.apache.hadoop.hdds.conf.OzoneConfiguration; +import org.apache.hadoop.hdds.server.OzoneAdmins; +import org.apache.hadoop.security.UserGroupInformation; + +import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_ADMINISTRATORS; +import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_ADMINISTRATORS_GROUPS; +import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_S3_ADMINISTRATORS; +import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_S3_ADMINISTRATORS_GROUPS; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import jakarta.annotation.Nullable; + +import java.io.IOException; +import java.util.Collection; + +/** + * Config based utilities for Ozone S3. + */ +public final class OzoneS3ConfigUtils { + static final Logger LOG = LoggerFactory.getLogger(OzoneS3ConfigUtils.class); + + private OzoneS3ConfigUtils() { } + + /** + * Get the list of S3 administrators from Ozone config. + * + * @param conf An instance of {@link OzoneConfiguration} being used + * @return A {@link Collection} of the S3 administrator users + * + * If ozone.s3.administrators value is empty string or unset, + * defaults to ozone.administrators value. + */ + public static Collection<String> getS3AdminsFromConfig(OzoneConfiguration conf) throws IOException { + Collection<String> ozAdmins = conf.getTrimmedStringCollection(OZONE_S3_ADMINISTRATORS); + + if (ozAdmins == null || ozAdmins.isEmpty()) { + ozAdmins = conf.getTrimmedStringCollection(OZONE_ADMINISTRATORS); + } + String omSPN = UserGroupInformation.getCurrentUser().getShortUserName(); Review Comment: This is also present in the OzoneAdmins class when trying to get the OzoneAdmin from a config, we pass a starter user which is set as the admin in case the provided user is not already present as an admin -- 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]
