Пример #1
0
        private static int CacheRemove(string[] args)
        {
            Authenticator authenticator = new Authenticator();
            string        realm         = null;
            string        account       = null;
            bool          all           = false;

            foreach (string arg in args)
            {
                if (arg == "-all")
                {
                    all = true;
                }
                else if (arg.StartsWith("-realm:"))
                {
                    realm = arg.Substring(7);
                }
                else if (arg.StartsWith("-account:"))
                {
                    account = arg.Substring(9);
                }
            }

            if (realm == null && account == null && !all)
            {
                Program.Error("One of -realm, -account, or -all must be specified.");
                return(1);
            }

            try
            {
                authenticator.Open(Program.Router, new AuthenticatorSettings());

                if (all)
                {
                    authenticator.BroadcastCacheClear();
                }
                else if (account == null)
                {
                    authenticator.BroadcastCacheRemove(realm);
                }
                else
                {
                    authenticator.BroadcastCacheRemove(realm, account);
                }
            }
            finally
            {
                authenticator.Close();
            }

            return(0);
        }