1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements.  See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership.  The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License.  You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 package org.apache.hadoop.security;
19 
20 import java.io.IOException;
21 import java.util.List;
22 
23 import org.apache.hadoop.classification.InterfaceAudience;
24 import org.apache.hadoop.classification.InterfaceStability;
25 import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
26 
27 /**
28  * An interface for the implementation of <userId, userName> mapping
29  * and <groupId, groupName> mapping
30  */
31 @InterfaceAudience.Public
32 @InterfaceStability.Evolving
33 public interface IdMappingServiceProvider {
34 
35   // Return uid for given user name
getUid(String user)36   public int getUid(String user) throws IOException;
37 
38   // Return gid for given group name
getGid(String group)39   public int getGid(String group) throws IOException;
40 
41   // Return user name for given user id uid, if not found, return
42   // <unknown> passed to this method
getUserName(int uid, String unknown)43   public String getUserName(int uid, String unknown);
44 
45   // Return group name for given groupd id gid, if not found, return
46   // <unknown> passed to this method
getGroupName(int gid, String unknown)47   public String getGroupName(int gid, String unknown);
48 
49   // Return uid for given user name.
50   // When can't map user, return user name's string hashcode
getUidAllowingUnknown(String user)51   public int getUidAllowingUnknown(String user);
52 
53   // Return gid for given group name.
54   // When can't map group, return group name's string hashcode
getGidAllowingUnknown(String group)55   public int getGidAllowingUnknown(String group);
56 }
57