Beispiel #1
0
        public void Upgrade()
        {
            //This is used to upgrade old configuration formats
            if (Privileges.Count == 0)
            {
                //Unluckily lists default to empty lists instead of null so there is no nicer way to detect the necessity of an upgrade unless we stop using the current XML serialisation scheme without any further customisations
                PrivilegeClass privilegedClass = new PrivilegeClass();
                privilegedClass.EnabledAPIFunctions.AddRange(WebService.NonPrivilegedHandlers);
                privilegedClass.EnabledAPIFunctions.AddRange(WebService.PrivilegedHandlers);
                privilegedClass.Addresses.Add("127.0.0.1");

                PrivilegeClass nonPrivilegedClass = new PrivilegeClass();
                nonPrivilegedClass.EnabledAPIFunctions.AddRange(WebService.NonPrivilegedHandlers);
                nonPrivilegedClass.MatchAllAddresses = true;

                Privileges.Add(privilegedClass);
                Privileges.Add(nonPrivilegedClass);
            }

            //Old configuration formats didn't permit customised connection strings
            if (Database == "RiotControl.sqlite")
            {
                Database = string.Format("Data Source = {0}", Database);
            }
        }
Beispiel #2
0
        List <string> GetPrivileges(Request request)
        {
            PrivilegeClass privilegeClass = GetRequestClass(request);

            if (privilegeClass == null)
            {
                return(new List <string>());
            }
            else
            {
                return(privilegeClass.EnabledAPIFunctions);
            }
        }
Beispiel #3
0
        public void Upgrade()
        {
            //This is used to upgrade old configuration formats
            if (Privileges.Count == 0)
            {
                //Unluckily lists default to empty lists instead of null so there is no nicer way to detect the necessity of an upgrade unless we stop using the current XML serialisation scheme without any further customisations
                PrivilegeClass privilegedClass = new PrivilegeClass();
                privilegedClass.EnabledAPIFunctions.AddRange(WebService.NonPrivilegedHandlers);
                privilegedClass.EnabledAPIFunctions.AddRange(WebService.PrivilegedHandlers);
                privilegedClass.Addresses.Add("127.0.0.1");

                PrivilegeClass nonPrivilegedClass = new PrivilegeClass();
                nonPrivilegedClass.EnabledAPIFunctions.AddRange(WebService.NonPrivilegedHandlers);
                nonPrivilegedClass.MatchAllAddresses = true;

                Privileges.Add(privilegedClass);
                Privileges.Add(nonPrivilegedClass);
            }

            //Old configuration formats didn't permit customised connection strings
            if (Database == "RiotControl.sqlite")
                Database = string.Format("Data Source = {0}", Database);
        }
Beispiel #4
0
        bool IsPrivileged(Request request)
        {
            PrivilegeClass privilegeClass = GetRequestClass(request);

            return(privilegeClass != null && privilegeClass.EnabledAPIFunctions.Contains(request.RequestHandler.Name));
        }