static TestZKRMStateStoreZKClientConnections()
 {
     try
     {
         DigestUserHash = DigestAuthenticationProvider.GenerateDigest(DigestUserPass);
     }
     catch (NoSuchAlgorithmException e)
     {
         throw new RuntimeException(e);
     }
 }
Пример #2
0
 static TestZKFailoverController()
 {
     // Set up ZK digest-based credentials for the purposes of the tests,
     // to make sure all of our functionality works with auth and ACLs
     // present.
     try
     {
         DigestUserHash = DigestAuthenticationProvider.GenerateDigest(DigestUserPass);
     }
     catch (NoSuchAlgorithmException e)
     {
         throw new RuntimeException(e);
     }
 }
Пример #3
0
 /// <summary>Generate a base-64 encoded digest of the idPasswordPair pair</summary>
 /// <param name="idPasswordPair">id:password</param>
 /// <returns>a string that can be used for authentication</returns>
 /// <exception cref="System.IO.IOException"/>
 public virtual string Digest(string idPasswordPair)
 {
     if (StringUtils.IsEmpty(idPasswordPair) || !IsValid(idPasswordPair))
     {
         throw new IOException("Invalid id:password: " + idPasswordPair);
     }
     try
     {
         return(DigestAuthenticationProvider.GenerateDigest(idPasswordPair));
     }
     catch (NoSuchAlgorithmException e)
     {
         // unlikely since it is standard to the JVM, but maybe JCE restrictions
         // could trigger it
         throw new IOException(e.ToString(), e);
     }
 }
        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();
        }