示例#1
0
        /*
         * Helper to modify auth file
         */
        internal static void ModifyAuthFile(ApplicationContext context, ModifyAuthFileDelegate functor)
        {
            // Making sure we lock file as we retrieve it and allows caller to modify it
            lock (_passwordFileLocker) {
                // Retrieving auth file
                Node authFileNode = GetAuthFileInternal(context);

                // Invoking callback functor
                functor(authFileNode);

                // Saves updated authFileNode
                SaveAuthFileInternal(context, authFileNode);
            }
        }
示例#2
0
        /*
         * Helper to modify auth file.
         */
        internal static void ModifyAuthFile(ApplicationContext context, ModifyAuthFileDelegate functor)
        {
            // Making sure we lock file as we retrieve it and allows caller to modify it.
            _locker.EnterWriteLock();
            try {
                // In case this is our first attempt at tampering with auth file, we create a default "empty" file.
                if (_authFileContent == null)
                {
                    _authFileContent = new Node("").Add("users");
                }

                // Invoking callback functor.
                functor(_authFileContent);

                // Saves updated authFileNode.
                SaveAuthFileInternal(context);
            } finally {
                _locker.ExitWriteLock();
            }
        }