Exemplo n.º 1
0
        public virtual void Initialise(IConfigSource source)
        {
            IConfig gridConfig = source.Configs["GridUserService"];

            if (gridConfig == null)
            {
                m_log.Error("[GRID USER CONNECTOR]: GridUserService missing from OpenSim.ini");
                throw new Exception("GridUser connector init error");
            }

            string serviceURI = gridConfig.GetString("GridUserServerURI", string.Empty);

            if (string.IsNullOrWhiteSpace(serviceURI))
            {
                m_log.Error("[GRIDUSER CONNECTOR]: GridUserServerURI not found section GridUserService");
                throw new Exception("GridUser connector init error");
            }

            OSHHTPHost tmp = new OSHHTPHost(serviceURI, true);

            if (!tmp.IsResolvedHost)
            {
                m_log.ErrorFormat("[GRIDUSER CONNECTOR]: {0}", tmp.IsValidHost ? "Could not resolve GridUserServerURI" : "GridUserServerURI is a invalid host");
                throw new Exception("User account connector init error");
            }

            m_ServerURI = tmp.URI;

            base.Initialise(source, "GridUserService");
        }
Exemplo n.º 2
0
        // Check that the service token was generated for *this* grid.
        // If it wasn't then that's a fake agent.
        protected bool CheckAddress(string serviceToken)
        {
            string[] parts = serviceToken.Split(new char[] { ';' });
            if (parts.Length < 2)
            {
                return(false);
            }

            OSHHTPHost reqGrid = new OSHHTPHost(parts[0], false);

            if (!reqGrid.IsValidHost)
            {
                m_log.DebugFormat("[GATEKEEPER SERVICE]: Visitor provided malformed gird address {0}", parts[0]);
                return(false);
            }

            m_log.DebugFormat("[GATEKEEPER SERVICE]: Verifying grid {0} against {1}", reqGrid.URI, m_gatekeeperHost.URI);

            if (m_gatekeeperHost.Equals(reqGrid))
            {
                return(true);
            }
            if (m_gateKeeperAlias != null && m_gateKeeperAlias.Contains(reqGrid))
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 3
0
        protected bool Authenticate(AgentCircuitData aCircuit)
        {
            if (!CheckAddress(aCircuit.ServiceSessionID))
            {
                return(false);
            }

            if (string.IsNullOrEmpty(aCircuit.IPAddress))
            {
                m_log.DebugFormat("[GATEKEEPER SERVICE]: Agent did not provide a client IP address.");
                return(false);
            }

            string userURL = string.Empty;

            if (aCircuit.ServiceURLs.ContainsKey("HomeURI"))
            {
                userURL = aCircuit.ServiceURLs["HomeURI"].ToString();
            }

            OSHHTPHost userHomeHost = new OSHHTPHost(userURL, true);

            if (!userHomeHost.IsResolvedHost)
            {
                m_log.DebugFormat("[GATEKEEPER SERVICE]: Agent did not provide an authentication server URL");
                return(false);
            }

            if (m_gatekeeperHost.Equals(userHomeHost))
            {
                return(m_UserAgentService.VerifyAgent(aCircuit.SessionID, aCircuit.ServiceSessionID));
            }
            else
            {
                IUserAgentService userAgentService = new UserAgentServiceConnector(userURL);

                try
                {
                    return(userAgentService.VerifyAgent(aCircuit.SessionID, aCircuit.ServiceSessionID));
                }
                catch
                {
                    m_log.DebugFormat("[GATEKEEPER SERVICE]: Unable to contact authentication service at {0}", userURL);
                    return(false);
                }
            }
        }
        public virtual void Initialise(IConfigSource source)
        {
            IConfig netconfig = source.Configs["Network"];

            IConfig assetConfig = source.Configs["AssetService"];

            if (assetConfig == null)
            {
                m_log.Error("[ASSET CONNECTOR]: AssetService missing from OpenSim.ini");
                throw new Exception("Asset connector init error");
            }

            m_ServerURI = assetConfig.GetString("AssetServerURI", string.Empty);
            if (string.IsNullOrEmpty(m_ServerURI))
            {
                if (netconfig != null)
                {
                    m_ServerURI = netconfig.GetString("asset_server_url", string.Empty);
                }
            }
            if (string.IsNullOrEmpty(m_ServerURI))
            {
                m_log.Error("[ASSET CONNECTOR]: AssetServerURI not defined in section AssetService");
                throw new Exception("Asset connector init error");
            }

            OSHHTPHost m_GridAssetsURL = new OSHHTPHost(m_ServerURI, true);

            if (!m_GridAssetsURL.IsResolvedHost)
            {
                m_log.Error("[ASSET CONNECTOR]: Could not parse or resolve AssetServerURI");
                throw new Exception("Asset connector init error");
            }

            m_ServerURI = m_GridAssetsURL.URI;
            Initialise(source, "AssetService");
        }
        public AssetServicesConnector(string serverURI)
        {
            OSHHTPHost tmp = new OSHHTPHost(serverURI, true);

            m_ServerURI = tmp.IsResolvedHost ? tmp.URI : null;
        }
Exemplo n.º 6
0
        public GatekeeperService(IConfigSource config, ISimulationService simService)
        {
            if (!m_Initialized)
            {
                m_Initialized = true;

                IConfig serverConfig = config.Configs["GatekeeperService"];
                if (serverConfig == null)
                {
                    throw new Exception(String.Format("No section GatekeeperService in config file"));
                }

                string accountService    = serverConfig.GetString("UserAccountService", string.Empty);
                string homeUsersService  = serverConfig.GetString("UserAgentService", string.Empty);
                string gridService       = serverConfig.GetString("GridService", string.Empty);
                string presenceService   = serverConfig.GetString("PresenceService", string.Empty);
                string simulationService = serverConfig.GetString("SimulationService", string.Empty);
                string gridUserService   = serverConfig.GetString("GridUserService", string.Empty);
                string bansService       = serverConfig.GetString("BansService", string.Empty);
                // These are mandatory, the others aren't
                if (gridService == string.Empty || presenceService == string.Empty)
                {
                    throw new Exception("Incomplete specifications, Gatekeeper Service cannot function.");
                }

                string scope = serverConfig.GetString("ScopeID", UUID.Zero.ToString());
                UUID.TryParse(scope, out m_ScopeID);
                //m_WelcomeMessage = serverConfig.GetString("WelcomeMessage", "Welcome to OpenSim!");
                m_AllowTeleportsToAnyRegion = serverConfig.GetBoolean("AllowTeleportsToAnyRegion", true);

                string[] sections     = new string[] { "Const, Startup", "Hypergrid", "GatekeeperService" };
                string   externalName = Util.GetConfigVarFromSections <string>(config, "GatekeeperURI", sections, string.Empty);
                if (string.IsNullOrEmpty(externalName))
                {
                    externalName = serverConfig.GetString("ExternalName", string.Empty);
                }

                m_gatekeeperHost = new OSHHTPHost(externalName, true);
                if (!m_gatekeeperHost.IsResolvedHost)
                {
                    m_log.Error((m_gatekeeperHost.IsValidHost ? "Could not resolve GatekeeperURI" : "GatekeeperURI is a invalid host ") + externalName ?? "");
                    throw new Exception("GatekeeperURI is invalid");
                }
                m_gatekeeperURL = m_gatekeeperHost.URIwEndSlash;

                string gatekeeperURIAlias = Util.GetConfigVarFromSections <string>(config, "GatekeeperURIAlias", sections, string.Empty);

                if (!string.IsNullOrWhiteSpace(gatekeeperURIAlias))
                {
                    string[] alias = gatekeeperURIAlias.Split(',');
                    for (int i = 0; i < alias.Length; ++i)
                    {
                        OSHHTPHost tmp = new OSHHTPHost(alias[i].Trim(), false);
                        if (tmp.IsValidHost)
                        {
                            if (m_gateKeeperAlias == null)
                            {
                                m_gateKeeperAlias = new HashSet <OSHHTPHost>();
                            }
                            m_gateKeeperAlias.Add(tmp);
                        }
                    }
                }

                object[] args = new object[] { config };
                m_GridService     = ServerUtils.LoadPlugin <IGridService>(gridService, args);
                m_PresenceService = ServerUtils.LoadPlugin <IPresenceService>(presenceService, args);

                if (accountService != string.Empty)
                {
                    m_UserAccountService = ServerUtils.LoadPlugin <IUserAccountService>(accountService, args);
                }
                if (homeUsersService != string.Empty)
                {
                    m_UserAgentService = ServerUtils.LoadPlugin <IUserAgentService>(homeUsersService, args);
                }
                if (gridUserService != string.Empty)
                {
                    m_GridUserService = ServerUtils.LoadPlugin <IGridUserService>(gridUserService, args);
                }
                if (bansService != string.Empty)
                {
                    m_BansService = ServerUtils.LoadPlugin <IBansService>(bansService, args);
                }

                if (simService != null)
                {
                    m_SimulationService = simService;
                }
                else if (simulationService != string.Empty)
                {
                    m_SimulationService = ServerUtils.LoadPlugin <ISimulationService>(simulationService, args);
                }

                string[] possibleAccessControlConfigSections = new string[] { "AccessControl", "GatekeeperService" };
                m_AllowedClients = Util.GetConfigVarFromSections <string>(
                    config, "AllowedClients", possibleAccessControlConfigSections, string.Empty);
                m_DeniedClients = Util.GetConfigVarFromSections <string>(
                    config, "DeniedClients", possibleAccessControlConfigSections, string.Empty);
                m_DeniedMacs = Util.GetConfigVarFromSections <string>(
                    config, "DeniedMacs", possibleAccessControlConfigSections, string.Empty);
                m_ForeignAgentsAllowed = serverConfig.GetBoolean("ForeignAgentsAllowed", true);

                LoadDomainExceptionsFromConfig(serverConfig, "AllowExcept", m_ForeignsAllowedExceptions);
                LoadDomainExceptionsFromConfig(serverConfig, "DisallowExcept", m_ForeignsDisallowedExceptions);

                if (m_GridService == null || m_PresenceService == null || m_SimulationService == null)
                {
                    throw new Exception("Unable to load a required plugin, Gatekeeper Service cannot function.");
                }

                IConfig presenceConfig = config.Configs["PresenceService"];
                if (presenceConfig != null)
                {
                    m_allowDuplicatePresences = presenceConfig.GetBoolean("AllowDuplicatePresences", m_allowDuplicatePresences);
                }

                IConfig messagingConfig = config.Configs["Messaging"];
                if (messagingConfig != null)
                {
                    m_messageKey = messagingConfig.GetString("MessageKey", String.Empty);
                }
                m_log.Debug("[GATEKEEPER SERVICE]: Starting...");
            }
        }
Exemplo n.º 7
0
        private void SetExtraServiceURLs(IConfigSource config)
        {
            IConfig loginConfig = config.Configs["LoginService"];
            IConfig gridConfig  = config.Configs["GridService"];

            if (loginConfig == null || gridConfig == null)
            {
                return;
            }

            string configVal;

            configVal = loginConfig.GetString("SearchURL", string.Empty);
            if (!string.IsNullOrEmpty(configVal))
            {
                m_ExtraFeatures["search-server-url"] = configVal;
            }

            configVal = loginConfig.GetString("MapTileURL", string.Empty);
            if (!string.IsNullOrEmpty(configVal))
            {
                // This URL must end with '/', the viewer doesn't check
                configVal = configVal.Trim();
                if (!configVal.EndsWith("/"))
                {
                    configVal = configVal + "/";
                }
                m_ExtraFeatures["map-server-url"] = configVal;
            }

            configVal = loginConfig.GetString("DestinationGuide", string.Empty);
            if (!string.IsNullOrEmpty(configVal))
            {
                m_ExtraFeatures["destination-guide-url"] = configVal;
            }

            configVal = Util.GetConfigVarFromSections <string>(
                config, "GatekeeperURI", new string[] { "Startup", "Hypergrid" }, string.Empty);
            if (!string.IsNullOrEmpty(configVal))
            {
                m_ExtraFeatures["GridURL"] = configVal;
            }

            configVal = Util.GetConfigVarFromSections <string>(
                config, "GridName", new string[] { "Const", "Hypergrid" }, string.Empty);
            if (string.IsNullOrEmpty(configVal))
            {
                configVal = Util.GetConfigVarFromSections <string>(
                    config, "gridname", new string[] { "GridInfo", "GridInfoService" }, string.Empty);
            }
            if (!string.IsNullOrEmpty(configVal))
            {
                m_ExtraFeatures["GridName"] = configVal;
            }

            configVal = Util.GetConfigVarFromSections <string>(
                config, "GridNick", new string[] { "Const", "Hypergrid" }, string.Empty);
            if (string.IsNullOrEmpty(configVal))
            {
                configVal = Util.GetConfigVarFromSections <string>(
                    config, "gridnick", new string[] { "GridInfo", "GridInfoService" }, string.Empty);
            }
            if (!string.IsNullOrEmpty(configVal))
            {
                m_ExtraFeatures["GridNick"] = configVal;
            }

            m_ExtraFeatures["ExportSupported"] = gridConfig.GetString("ExportSupported", "true");

            string[] sections           = new string[] { "Const, Startup", "Hypergrid", "GatekeeperService" };
            string   gatekeeperURIAlias = Util.GetConfigVarFromSections <string>(config, "GatekeeperURIAlias", sections, string.Empty);

            if (!string.IsNullOrWhiteSpace(gatekeeperURIAlias))
            {
                string[] alias = gatekeeperURIAlias.Split(',');
                if (alias.Length > 0)
                {
                    StringBuilder sb   = osStringBuilderCache.Acquire();
                    int           last = alias.Length - 1;
                    for (int i = 0; i < alias.Length; ++i)
                    {
                        OSHHTPHost tmp = new OSHHTPHost(alias[i], false);
                        if (tmp.IsValidHost)
                        {
                            sb.Append(tmp.URI);
                            if (i < last)
                            {
                                sb.Append(',');
                            }
                        }
                    }
                    if (sb.Length > 0)
                    {
                        m_ExtraFeatures["GridURLAlias"] = osStringBuilderCache.GetStringAndRelease(sb);
                    }
                    else
                    {
                        osStringBuilderCache.Release(sb);
                    }
                }
            }
        }