public virtual void Refresh(Configuration conf, PolicyProvider provider) { // Get the system property 'hadoop.policy.file' string policyFile = Runtime.GetProperty("hadoop.policy.file", HadoopPolicyFile); // Make a copy of the original config, and load the policy file Configuration policyConf = new Configuration(conf); policyConf.AddResource(policyFile); RefreshWithLoadedConfiguration(policyConf, provider); }
public virtual void RefreshWithLoadedConfiguration(Configuration conf, PolicyProvider provider) { IDictionary <Type, AccessControlList[]> newAcls = new IdentityHashMap <Type, AccessControlList []>(); IDictionary <Type, MachineList[]> newMachineLists = new IdentityHashMap <Type, MachineList []>(); string defaultAcl = conf.Get(CommonConfigurationKeys.HadoopSecurityServiceAuthorizationDefaultAcl , AccessControlList.WildcardAclValue); string defaultBlockedAcl = conf.Get(CommonConfigurationKeys.HadoopSecurityServiceAuthorizationDefaultBlockedAcl , string.Empty); string defaultServiceHostsKey = GetHostKey(CommonConfigurationKeys.HadoopSecurityServiceAuthorizationDefaultAcl ); string defaultMachineList = conf.Get(defaultServiceHostsKey, MachineList.WildcardValue ); string defaultBlockedMachineList = conf.Get(defaultServiceHostsKey + Blocked, string.Empty ); // Parse the config file Service[] services = provider.GetServices(); if (services != null) { foreach (Service service in services) { AccessControlList acl = new AccessControlList(conf.Get(service.GetServiceKey(), defaultAcl )); AccessControlList blockedAcl = new AccessControlList(conf.Get(service.GetServiceKey () + Blocked, defaultBlockedAcl)); newAcls[service.GetProtocol()] = new AccessControlList[] { acl, blockedAcl }; string serviceHostsKey = GetHostKey(service.GetServiceKey()); MachineList machineList = new MachineList(conf.Get(serviceHostsKey, defaultMachineList )); MachineList blockedMachineList = new MachineList(conf.Get(serviceHostsKey + Blocked , defaultBlockedMachineList)); newMachineLists[service.GetProtocol()] = new MachineList[] { machineList, blockedMachineList }; } } // Flip to the newly parsed permissions protocolToAcls = newAcls; protocolToMachineLists = newMachineLists; }