public bool TryAuthenticateUser(string userId, out User user)
 {
     User foundUser = GetUser(userId);
     bool isAuthenticated = false;
     if (foundUser != null)
     {
         isAuthenticated = foundUser.IsAuthenticated;
     }
     user = foundUser;
     return isAuthenticated;
 }
        public override User GetUser(string userPrefix)
        {
            User user = null;
            bool isAuthenticated = false;

            var userXmlNode = _documentFromStream.Descendants("user")
                .Where(userElement => (string)userElement.Attribute("prefix") == userPrefix)
                .FirstOrDefault();

            if (userXmlNode != null)
            {
                string isAuthenticatedAttribute = (string)userXmlNode.Attribute("allow");
                string username = (string)userXmlNode.Attribute("prefix");
                isAuthenticated = Boolean.Parse(isAuthenticatedAttribute);
                ICollection<Command> commands = LoadCommandsFromUserNode(userXmlNode);
                user = new User(isAuthenticated, username, commands);
            }

            return user;
        }
        public bool MayUserWriteToCommand(string username, string commandName, out User commandUser)
        {
            bool isUserAuthenticated = false;
            bool mayUserWrite = false;
            User user;
            if (isUserAuthenticated = _userAuthenticationProvider.TryAuthenticateUser(username, out user))
            {
                Command command = user.Commands.Where(selectedCommand => selectedCommand.Name == commandName).FirstOrDefault();
                if (command != null)
                {
                    if (command.Rights.Any(right => right.RightType == CommandRightType.Write))
                    {
                        mayUserWrite = true;
                    }
                }
            }

            commandUser = user;
            return isUserAuthenticated && mayUserWrite;
        }
 public bool TryAuthenticateUser(string userId, out User user)
 {
     return _userAuthenticationProvider.TryAuthenticateUser(userId, out user);
 }
 public bool MayUserWriteToCommand(string user, string commandName, out User commandUser)
 {
     return _commandAuthenticationProvider.MayUserExecuteCommand(user, commandName, out commandUser);
 }
 public bool MayUserReadFromCommand(string user, string commandName, out User commandUser)
 {
     return _commandAuthenticationProvider.MayUserReadFromCommand(user, commandName, out commandUser);
 }