public bool CheckThreatLevel(string SessionID, string function, ThreatLevel defaultThreatLevel)
        {
            if (!m_useRegistrationService)
            {
                return(true);
            }

            GridRegistrationURLs urls = m_genericsConnector.GetGeneric <GridRegistrationURLs>(UUID.Zero,
                                                                                              "GridRegistrationUrls", SessionID);

            if (urls != null)
            {
                //Past time for it to expire
                if (m_useSessionTime && urls.Expiration < DateTime.UtcNow)
                {
                    MainConsole.Instance.Warn("[GridRegService]: URLs expired for " + SessionID);
                    RemoveUrlsForClient(SessionID);
                    return(false);
                }
                //First find the threat level that this setting has to have do be able to run
                ThreatLevel functionThreatLevel = PermissionSet.FindThreatLevelForFunction(function, defaultThreatLevel);
                //Now find the permission for that threat level
                //else, check it against the threat level that the region has
                ThreatLevel regionThreatLevel = FindRegionThreatLevel(SessionID);
                //Return whether the region threat level is higher than the function threat level
                if (!(functionThreatLevel <= regionThreatLevel))
                {
                    MainConsole.Instance.Warn("[GridRegService]: checkThreatLevel (" + function + ") failed for " + SessionID + ", fperm " + functionThreatLevel + ", rperm " + regionThreatLevel + "!");
                }
                return(functionThreatLevel <= regionThreatLevel);
            }
            MainConsole.Instance.Warn("[GridRegService]: Could not find URLs for checkThreatLevel for " + SessionID + "!");
            return(false);
        }
Esempio n. 2
0
        public bool CheckThreatLevel(string SessionID, ulong RegionHandle, string function, ThreatLevel defaultThreatLevel)
        {
            GridRegistrationURLs urls = m_genericsConnector.GetGeneric <GridRegistrationURLs>(UUID.Zero,
                                                                                              "GridRegistrationUrls", RegionHandle.ToString(), new GridRegistrationURLs());

            if (urls != null)
            {
                //Past time for it to expire
                if (urls.Expiration < DateTime.Now)
                {
                    RemoveUrlsForClient(SessionID, RegionHandle);
                    return(false);
                }
                //First find the threat level that this setting has to have do be able to run
                ThreatLevel functionThreatLevel = PermissionSet.FindThreatLevelForFunction(function, defaultThreatLevel);
                //Now find the permission for that threat level
                //else, check it against the threat level that the region has
                GridRegion region = FindRegion(RegionHandle);
                if (region == null)
                {
                    return(false);
                }
                string      rThreat           = region.GenericMap["ThreatLevel"].AsString();
                ThreatLevel regionThreatLevel = m_defaultRegionThreatLevel;
                if (rThreat != "")
                {
                    regionThreatLevel = (ThreatLevel)Enum.Parse(typeof(ThreatLevel), rThreat);
                }
                //Return whether the region threat level is higher than the function threat level
                return(functionThreatLevel <= regionThreatLevel);
            }
            return(false);
        }