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.yarn.server.resourcemanager.security.authorize;
19 
20 import org.apache.hadoop.classification.InterfaceAudience;
21 import org.apache.hadoop.classification.InterfaceAudience.Private;
22 import org.apache.hadoop.classification.InterfaceStability;
23 import org.apache.hadoop.classification.InterfaceStability.Unstable;
24 import org.apache.hadoop.fs.CommonConfigurationKeys;
25 import org.apache.hadoop.ha.HAServiceProtocol;
26 import org.apache.hadoop.security.authorize.PolicyProvider;
27 import org.apache.hadoop.security.authorize.Service;
28 import org.apache.hadoop.yarn.api.ApplicationMasterProtocolPB;
29 import org.apache.hadoop.yarn.api.ApplicationClientProtocolPB;
30 import org.apache.hadoop.yarn.api.ContainerManagementProtocolPB;
31 import org.apache.hadoop.yarn.conf.YarnConfiguration;
32 import org.apache.hadoop.yarn.server.api.ResourceManagerAdministrationProtocolPB;
33 import org.apache.hadoop.yarn.server.api.ResourceTrackerPB;
34 
35 /**
36  * {@link PolicyProvider} for YARN ResourceManager protocols.
37  */
38 @InterfaceAudience.Private
39 @InterfaceStability.Unstable
40 public class RMPolicyProvider extends PolicyProvider {
41 
42   private static RMPolicyProvider rmPolicyProvider = null;
43 
RMPolicyProvider()44   private RMPolicyProvider() {}
45 
46   @Private
47   @Unstable
getInstance()48   public static RMPolicyProvider getInstance() {
49     if (rmPolicyProvider == null) {
50       synchronized(RMPolicyProvider.class) {
51         if (rmPolicyProvider == null) {
52           rmPolicyProvider = new RMPolicyProvider();
53         }
54       }
55     }
56     return rmPolicyProvider;
57   }
58 
59   private static final Service[] resourceManagerServices =
60       new Service[] {
61     new Service(
62         YarnConfiguration.YARN_SECURITY_SERVICE_AUTHORIZATION_RESOURCETRACKER_PROTOCOL,
63         ResourceTrackerPB.class),
64     new Service(
65         YarnConfiguration.YARN_SECURITY_SERVICE_AUTHORIZATION_APPLICATIONCLIENT_PROTOCOL,
66         ApplicationClientProtocolPB.class),
67     new Service(
68         YarnConfiguration.YARN_SECURITY_SERVICE_AUTHORIZATION_APPLICATIONMASTER_PROTOCOL,
69         ApplicationMasterProtocolPB.class),
70     new Service(
71         YarnConfiguration.YARN_SECURITY_SERVICE_AUTHORIZATION_RESOURCEMANAGER_ADMINISTRATION_PROTOCOL,
72         ResourceManagerAdministrationProtocolPB.class),
73     new Service(
74         YarnConfiguration.YARN_SECURITY_SERVICE_AUTHORIZATION_CONTAINER_MANAGEMENT_PROTOCOL,
75         ContainerManagementProtocolPB.class),
76     new Service(
77         CommonConfigurationKeys.SECURITY_HA_SERVICE_PROTOCOL_ACL,
78         HAServiceProtocol.class),
79   };
80 
81   @Override
getServices()82   public Service[] getServices() {
83     return resourceManagerServices;
84   }
85 
86 }
87