/// <exception cref="System.Exception"/>
        private void AddOrUpdateToken(TokenIdent ident, AbstractDelegationTokenSecretManager.DelegationTokenInformation
                                      info, bool isUpdate)
        {
            string nodeCreatePath = GetNodePath(ZkDtsmTokensRoot, DelegationTokenPrefix + ident
                                                .GetSequenceNumber());
            ByteArrayOutputStream tokenOs  = new ByteArrayOutputStream();
            DataOutputStream      tokenOut = new DataOutputStream(tokenOs);
            ByteArrayOutputStream seqOs    = new ByteArrayOutputStream();

            try
            {
                ident.Write(tokenOut);
                tokenOut.WriteLong(info.GetRenewDate());
                tokenOut.WriteInt(info.GetPassword().Length);
                tokenOut.Write(info.GetPassword());
                if (Log.IsDebugEnabled())
                {
                    Log.Debug((isUpdate ? "Updating " : "Storing ") + "ZKDTSMDelegationToken_" + ident
                              .GetSequenceNumber());
                }
                if (isUpdate)
                {
                    zkClient.SetData().ForPath(nodeCreatePath, tokenOs.ToByteArray()).SetVersion(-1);
                }
                else
                {
                    zkClient.Create().WithMode(CreateMode.Persistent).ForPath(nodeCreatePath, tokenOs
                                                                              .ToByteArray());
                }
            }
            finally
            {
                seqOs.Close();
            }
        }
 CheckToken(TokenIdent identifier)
 {
     System.Diagnostics.Debug.Assert(Thread.HoldsLock(this));
     AbstractDelegationTokenSecretManager.DelegationTokenInformation info = GetTokenInfo
                                                                                (identifier);
     if (info == null)
     {
         throw new SecretManager.InvalidToken("token (" + identifier.ToString() + ") can't be found in cache"
                                              );
     }
     if (info.GetRenewDate() < Time.Now())
     {
         throw new SecretManager.InvalidToken("token (" + identifier.ToString() + ") is expired"
                                              );
     }
     return(info);
 }
 /// <summary>
 /// For subclasses externalizing the storage, for example Zookeeper
 /// based implementations
 /// </summary>
 /// <exception cref="System.IO.IOException"/>
 protected internal virtual void UpdateToken(TokenIdent ident, AbstractDelegationTokenSecretManager.DelegationTokenInformation
                                             tokenInfo)
 {
     currentTokens[ident] = tokenInfo;
     UpdateStoredToken(ident, tokenInfo.GetRenewDate());
 }