public virtual void TestACLs() { DelegationTokenManager tm1; string connectString = zkServer.GetConnectString(); Configuration conf = GetSecretConf(connectString); RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3); string userPass = "******"; ACL digestACL = new ACL(ZooDefs.Perms.All, new ID("digest", DigestAuthenticationProvider .GenerateDigest(userPass))); ACLProvider digestAclProvider = new _ACLProvider_319(digestACL); CuratorFramework curatorFramework = CuratorFrameworkFactory.Builder().ConnectString (connectString).RetryPolicy(retryPolicy).AclProvider(digestAclProvider).Authorization ("digest", Runtime.GetBytesForString(userPass, "UTF-8")).Build(); curatorFramework.Start(); ZKDelegationTokenSecretManager.SetCurator(curatorFramework); tm1 = new DelegationTokenManager(conf, new Text("bla")); tm1.Init(); // check ACL string workingPath = conf.Get(ZKDelegationTokenSecretManager.ZkDtsmZnodeWorkingPath ); VerifyACL(curatorFramework, "/" + workingPath, digestACL); tm1.Destroy(); ZKDelegationTokenSecretManager.SetCurator(null); curatorFramework.Close(); }
public override void StopThreads() { base.StopThreads(); try { if (tokenCache != null) { tokenCache.Close(); } } catch (Exception e) { Log.Error("Could not stop Delegation Token Cache", e); } try { if (delTokSeqCounter != null) { delTokSeqCounter.Close(); } } catch (Exception e) { Log.Error("Could not stop Delegation Token Counter", e); } try { if (keyIdSeqCounter != null) { keyIdSeqCounter.Close(); } } catch (Exception e) { Log.Error("Could not stop Key Id Counter", e); } try { if (keyCache != null) { keyCache.Close(); } } catch (Exception e) { Log.Error("Could not stop KeyCache", e); } try { if (!isExternalClient && (zkClient != null)) { zkClient.Close(); } } catch (Exception e) { Log.Error("Could not stop Curator Framework", e); } if (listenerThreadPool != null) { listenerThreadPool.Shutdown(); try { // wait for existing tasks to terminate if (!listenerThreadPool.AwaitTermination(shutdownTimeout, TimeUnit.Milliseconds)) { Log.Error("Forcing Listener threadPool to shutdown !!"); listenerThreadPool.ShutdownNow(); } } catch (Exception) { listenerThreadPool.ShutdownNow(); Thread.CurrentThread().Interrupt(); } } }