yadavay-amzn commented on code in PR #57140: URL: https://github.com/apache/spark/pull/57140#discussion_r3549511124
########## core/src/main/java/org/apache/spark/security/UserCredentials.java: ########## @@ -0,0 +1,105 @@ +/* + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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.spark.security; + +import java.io.Serializable; +import java.util.Collections; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +import org.apache.spark.annotation.DeveloperApi; + +/** + * :: DeveloperApi :: + * A bundle of {@link ServiceCredential} instances keyed by scheme (e.g., "s3a", "abfss"). + * <p> + * Scheme keys are normalized to lowercase ({@link Locale#ROOT}) at construction time, and + * lookups via {@link #forScheme(String)} are case-insensitive. If the supplied map contains + * keys that differ only by case, the last entry (in iteration order) wins. + * <p> + * This class is transmitted to executors and does <b>not</b> contain any reference + * to {@link UserContext} or raw identity tokens. It is immutable and {@link Serializable}. + * + * @since 4.3.0 + */ +@DeveloperApi +public final class UserCredentials implements Serializable { + + private static final long serialVersionUID = 1L; + + private final Map<String, ServiceCredential> credentials; + + /** + * Constructs a new {@code UserCredentials} bundle. + * <p> + * Scheme keys are normalized to lowercase using {@link Locale#ROOT}. If multiple keys + * collide after lowercasing, the last entry in iteration order wins. + * + * @param credentials per-scheme map of service credentials (must not be null; defensively copied) + */ + public UserCredentials(Map<String, ServiceCredential> credentials) { + Objects.requireNonNull(credentials, "credentials must not be null"); + Map<String, ServiceCredential> normalized = new HashMap<>(credentials.size()); + for (Map.Entry<String, ServiceCredential> entry : credentials.entrySet()) { + normalized.put(entry.getKey().toLowerCase(Locale.ROOT), entry.getValue()); Review Comment: Done -- 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]
