private Configuration LoadACLs() { Log.Debug("Loading ACLs file"); lastReload = Runtime.CurrentTimeMillis(); Configuration conf = KMSConfiguration.GetACLsConf(); // triggering the resource loading. conf.Get(KMSACLs.Type.Create.GetAclConfigKey()); return(conf); }
public virtual void Run() { try { if (KMSConfiguration.IsACLsFileNewer(lastReload)) { SetKMSACLs(LoadACLs()); SetKeyACLs(LoadACLs()); } } catch (Exception ex) { Log.Warn(string.Format("Could not reload ACLs file: '%s'", ex.ToString()), ex); } }
public virtual void ContextInitialized(ServletContextEvent sce) { try { string confDir = Runtime.GetProperty(KMSConfiguration.KmsConfigDir); if (confDir == null) { throw new RuntimeException("System property '" + KMSConfiguration.KmsConfigDir + "' not defined"); } kmsConf = KMSConfiguration.GetKMSConf(); InitLogging(confDir); Log.Info("-------------------------------------------------------------"); Log.Info(" Java runtime version : {}", Runtime.GetProperty("java.runtime.version" )); Log.Info(" KMS Hadoop Version: " + VersionInfo.GetVersion()); Log.Info("-------------------------------------------------------------"); kmsAcls = new KMSACLs(); kmsAcls.StartReloader(); metricRegistry = new MetricRegistry(); jmxReporter = JmxReporter.ForRegistry(metricRegistry).Build(); jmxReporter.Start(); generateEEKCallsMeter = metricRegistry.Register(GenerateEekMeter, new Meter()); decryptEEKCallsMeter = metricRegistry.Register(DecryptEekMeter, new Meter()); adminCallsMeter = metricRegistry.Register(AdminCallsMeter, new Meter()); keyCallsMeter = metricRegistry.Register(KeyCallsMeter, new Meter()); invalidCallsMeter = metricRegistry.Register(InvalidCallsMeter, new Meter()); unauthorizedCallsMeter = metricRegistry.Register(UnauthorizedCallsMeter, new Meter ()); unauthenticatedCallsMeter = metricRegistry.Register(UnauthenticatedCallsMeter, new Meter()); kmsAudit = new KMSAudit(kmsConf.GetLong(KMSConfiguration.KmsAuditAggregationWindow , KMSConfiguration.KmsAuditAggregationWindowDefault)); // this is required for the the JMXJsonServlet to work properly. // the JMXJsonServlet is behind the authentication filter, // thus the '*' ACL. sce.GetServletContext().SetAttribute(HttpServer2.ConfContextAttribute, kmsConf); sce.GetServletContext().SetAttribute(HttpServer2.AdminsAcl, new AccessControlList (AccessControlList.WildcardAclValue)); // intializing the KeyProvider string providerString = kmsConf.Get(KMSConfiguration.KeyProviderUri); if (providerString == null) { throw new InvalidOperationException("No KeyProvider has been defined"); } KeyProvider keyProvider = KeyProviderFactory.Get(new URI(providerString), kmsConf ); if (kmsConf.GetBoolean(KMSConfiguration.KeyCacheEnable, KMSConfiguration.KeyCacheEnableDefault )) { long keyTimeOutMillis = kmsConf.GetLong(KMSConfiguration.KeyCacheTimeoutKey, KMSConfiguration .KeyCacheTimeoutDefault); long currKeyTimeOutMillis = kmsConf.GetLong(KMSConfiguration.CurrKeyCacheTimeoutKey , KMSConfiguration.CurrKeyCacheTimeoutDefault); keyProvider = new CachingKeyProvider(keyProvider, keyTimeOutMillis, currKeyTimeOutMillis ); } Log.Info("Initialized KeyProvider " + keyProvider); keyProviderCryptoExtension = KeyProviderCryptoExtension.CreateKeyProviderCryptoExtension (keyProvider); keyProviderCryptoExtension = new EagerKeyGeneratorKeyProviderCryptoExtension(kmsConf , keyProviderCryptoExtension); if (kmsConf.GetBoolean(KMSConfiguration.KeyAuthorizationEnable, KMSConfiguration. KeyAuthorizationEnableDefault)) { keyProviderCryptoExtension = new KeyAuthorizationKeyProvider(keyProviderCryptoExtension , kmsAcls); } Log.Info("Initialized KeyProviderCryptoExtension " + keyProviderCryptoExtension); int defaultBitlength = kmsConf.GetInt(KeyProvider.DefaultBitlengthName, KeyProvider .DefaultBitlength); Log.Info("Default key bitlength is {}", defaultBitlength); Log.Info("KMS Started"); } catch (Exception ex) { System.Console.Out.WriteLine(); System.Console.Out.WriteLine("ERROR: Hadoop KMS could not be started"); System.Console.Out.WriteLine(); System.Console.Out.WriteLine("REASON: " + ex.ToString()); System.Console.Out.WriteLine(); System.Console.Out.WriteLine("Stacktrace:"); System.Console.Out.WriteLine("---------------------------------------------------" ); Runtime.PrintStackTrace(ex, System.Console.Out); System.Console.Out.WriteLine("---------------------------------------------------" ); System.Console.Out.WriteLine(); System.Environment.Exit(1); } }