Beispiel #1
0
        public EstateDataRobustConnector(IConfigSource config, IHttpServer server, string configName) :
            base(config, server, configName)
        {
            IConfig serverConfig = config.Configs[m_ConfigName];

            if (serverConfig == null)
            {
                throw new Exception(String.Format("No section {0} in config file", m_ConfigName));
            }

            string service = serverConfig.GetString("LocalServiceModule",
                                                    String.Empty);

            if (service == String.Empty)
            {
                throw new Exception("No LocalServiceModule in config file");
            }

            Object[]           args      = new Object[] { config };
            IEstateDataService e_service = ServerUtils.LoadPlugin <IEstateDataService>(service, args);

            IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName);;

            server.AddStreamHandler(new EstateServerGetHandler(e_service, auth));
            server.AddStreamHandler(new EstateServerPostHandler(e_service, auth));
        }
Beispiel #2
0
 public SimpleBinaryHandler(string httpmethod, string path, IServiceAuth auth, SimpleBinaryMethod processRequest)
     : base(path)
 {
     m_httMethod      = httpmethod.ToUpper();
     m_Auth           = auth;
     m_processRequest = processRequest;
 }
Beispiel #3
0
        public OfflineIMServiceRemoteConnector(IConfigSource config)
        {
            IConfig cnf = config.Configs["Messaging"];

            if (cnf == null)
            {
                m_log.WarnFormat("[OfflineIM.V2.RemoteConnector]: Missing Messaging configuration");
                return;
            }

            m_ServerURI = cnf.GetString("OfflineMessageURL", string.Empty);

            /// This is from BaseServiceConnector
            string authType = Util.GetConfigVarFromSections <string>(config, "AuthType", new string[] { "Network", "Messaging" }, "None");

            switch (authType)
            {
            case "BasicHttpAuthentication":
                m_Auth = new BasicHttpAuthentication(config, "Messaging");
                break;
            }
            ///
            m_log.DebugFormat("[OfflineIM.V2.RemoteConnector]: Offline IM server at {0} with auth {1}",
                              m_ServerURI, (m_Auth == null ? "None" : m_Auth.GetType().ToString()));
        }
Beispiel #4
0
        public XBakesConnector(IConfigSource config, IHttpServer server, string configName) :
            base(config, server, configName)
        {
            if (configName != String.Empty)
            {
                m_ConfigName = configName;
            }

            IConfig serverConfig = config.Configs[m_ConfigName];

            if (serverConfig == null)
            {
                throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName));
            }

            string assetService = serverConfig.GetString("LocalServiceModule",
                                                         String.Empty);

            if (assetService == String.Empty)
            {
                throw new Exception("No BakedTextureService in config file");
            }

            Object[] args = new Object[] { config };
            m_BakesService =
                ServerUtils.LoadPlugin <IBakedTextureService>(assetService, args);

            IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName);

            server.AddStreamHandler(new BakesServerGetHandler(m_BakesService, auth));
            server.AddStreamHandler(new BakesServerPostHandler(m_BakesService, auth));
        }
        public GroupsServiceRobustConnector(IConfigSource config, IHttpServer server, string configName) :
            base(config, server, configName)
        {
            string key = string.Empty;

            if (configName != String.Empty)
            {
                m_ConfigName = configName;
            }

            m_log.DebugFormat("[Groups.RobustConnector]: Starting with config name {0}", m_ConfigName);

            IConfig groupsConfig = config.Configs[m_ConfigName];

            if (groupsConfig != null)
            {
                key = groupsConfig.GetString("SecretKey", string.Empty);
                m_log.DebugFormat("[Groups.RobustConnector]: Starting with secret key {0}", key);
            }
            else
            {
                m_log.WarnFormat("[Groups.RobustConnector]: Unable to find {0} section in configuration", m_ConfigName);
            }

            m_GroupsService = new GroupsService(config);

            IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName);

            server.AddStreamHandler(new GroupsServicePostHandler(m_GroupsService, auth));
        }
        public GroupsServiceRemoteConnector(IConfigSource config)
        {
            IConfig groupsConfig = config.Configs["Groups"];
            string url = groupsConfig.GetString("GroupsServerURI", string.Empty);
            if (!Uri.IsWellFormedUriString(url, UriKind.Absolute))
                throw new Exception(string.Format("[Groups.RemoteConnector]: Malformed groups server URL {0}. Fix it or disable the Groups feature.", url));

            m_ServerURI = url;
            if (!m_ServerURI.EndsWith("/"))
                m_ServerURI += "/";

            /// This is from BaseServiceConnector
            string authType = Util.GetConfigVarFromSections<string>(config, "AuthType", new string[] { "Network", "Groups" }, "None");

            switch (authType)
            {
                case "BasicHttpAuthentication":
                    m_Auth = new BasicHttpAuthentication(config, "Groups");
                    break;
            }
            ///

            m_log.DebugFormat("[Groups.RemoteConnector]: Groups server at {0}, authentication {1}", 
                m_ServerURI, (m_Auth == null ? "None" : m_Auth.GetType().ToString()));
        }
        public GroupsServiceRemoteConnector(IConfigSource config)
        {
            IConfig groupsConfig = config.Configs["Groups"];
            string  url          = groupsConfig.GetString("GroupsServerURI", string.Empty);

            if (!Uri.IsWellFormedUriString(url, UriKind.Absolute))
            {
                throw new Exception(string.Format("[Groups.RemoteConnector]: Malformed groups server URL {0}. Fix it or disable the Groups feature.", url));
            }

            m_ServerURI = url;
            if (!m_ServerURI.EndsWith("/"))
            {
                m_ServerURI += "/";
            }

            /// This is from BaseServiceConnector
            string authType = Util.GetConfigVarFromSections <string>(config, "AuthType", new string[] { "Network", "Groups" }, "None");

            switch (authType)
            {
            case "BasicHttpAuthentication":
                m_Auth = new BasicHttpAuthentication(config, "Groups");
                break;
            }
            ///

            m_log.DebugFormat("[Groups.RemoteConnector]: Groups server at {0}, authentication {1}",
                              m_ServerURI, (m_Auth == null ? "None" : m_Auth.GetType().ToString()));
        }
        // Called from standalone configurations
        public AssetProxyConnector(IConfigSource config, IHttpServer server, string configName, IFriendsSimConnector localConn) : base(config, server, configName)
        {
            try
            {
                if (configName != String.Empty)
                {
                    m_ConfigName = configName;
                }

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

                m_AssetService = new AssetServerProxy(config, m_ConfigName);

                IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName);

                server.AddStreamHandler(new AssetServerGetHandler(m_AssetService, auth, string.Empty));
                server.AddStreamHandler(new AssetServerPostHandler(m_AssetService, auth));
                server.AddStreamHandler(new AssetServerDeleteHandler(m_AssetService, AllowedRemoteDeleteTypes.None, auth));
                server.AddStreamHandler(new AssetsExistHandler(m_AssetService));
            }catch (Exception error)
            {
                m_log.Error(error.Message);
                m_log.Error(error.StackTrace);
            }
        }
 public SimpleOSDMapHandler(string httpmethod, string path, IServiceAuth auth, SimpleOSDMapMethod processRequest, string name)
     : base(path, name)
 {
     m_httMethod      = httpmethod.ToUpper();
     m_Auth           = auth;
     m_processRequest = processRequest;
 }
Beispiel #10
0
        public XInventoryInConnector(IConfigSource config, IHttpServer server, string configName) :
            base(config, server, configName)
        {
            if (configName != String.Empty)
            {
                m_ConfigName = configName;
            }

            m_log.DebugFormat("[XInventoryInConnector]: Starting with config name {0}", m_ConfigName);

            IConfig serverConfig = config.Configs[m_ConfigName];

            if (serverConfig == null)
            {
                throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName));
            }

            string inventoryService = serverConfig.GetString("LocalServiceModule",
                                                             String.Empty);

            if (inventoryService == String.Empty)
            {
                throw new Exception("No InventoryService in config file");
            }

            Object[] args = new Object[] { config, m_ConfigName };
            m_InventoryService =
                ServerUtils.LoadPlugin <IInventoryService>(inventoryService, args);

            IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName);

            server.AddStreamHandler(new XInventoryConnectorPostHandler(m_InventoryService, auth));
        }
Beispiel #11
0
        public XBakesConnector(IConfigSource config, IHttpServer server, string configName) :
            base(config, server, configName)
        {
            if (configName != string.Empty)
            {
                m_ConfigName = configName;
            }

            IConfig serverConfig = config.Configs[m_ConfigName];

            if (serverConfig == null)
            {
                throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName));
            }

            string bakesServiceName = serverConfig.GetString("LocalServiceModule", string.Empty);

            if (string.IsNullOrWhiteSpace(bakesServiceName))
            {
                throw new Exception("No BakedTextureService in config file");
            }

            object[]             args         = new object[] { config };
            IBakedTextureService bakesService = ServerUtils.LoadPlugin <IBakedTextureService>(bakesServiceName, args);

            IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName);

            server.AddSimpleStreamHandler(new BakesServerHandler(bakesService, auth), true);
        }
Beispiel #12
0
        // just post data, ignoring result
        public async Task AsyncPOSTRequest(byte[] src, IServiceAuth auth)
        {
            int reqnum = WebUtil.RequestNumber++;

            try
            {
                _request               = (HttpWebRequest)WebRequest.Create(buildUri());
                _request.ContentType   = "application/xml";
                _request.Timeout       = 90000;
                _request.Method        = "POST";
                _asyncException        = null;
                _request.ContentLength = src.Length;
                if (auth != null)
                {
                    auth.AddAuthorization(_request.Headers);
                }
            }
            catch (Exception e)
            {
                m_log.WarnFormat("[REST]: AsyncPOST {0} failed with exception {1} {2}",
                                 _request.RequestUri, e.Message, e.StackTrace);
                return;
            }

            try
            {
                using (Stream dst = _request.GetRequestStream())
                {
                    await dst.WriteAsync(src, 0, src.Length).ConfigureAwait(false);
                }

                using (HttpWebResponse response = (HttpWebResponse)await _request.GetResponseAsync().ConfigureAwait(false))
                {
                    if (WebUtil.DebugLevel >= 5)
                    {
                        using (Stream responseStream = response.GetResponseStream())
                        {
                            using (StreamReader reader = new StreamReader(responseStream))
                            {
                                string responseStr = await reader.ReadToEndAsync().ConfigureAwait(false);

                                WebUtil.LogResponseDetail(reqnum, responseStr);
                            }
                        }
                    }
                }
            }
            catch (WebException e)
            {
                m_log.WarnFormat("[REST]: AsyncPOST {0} failed with status {1} and message {2}",
                                 _request.RequestUri, e.Status, e.Message);
                return;
            }
            catch (Exception e)
            {
                m_log.WarnFormat("[REST]: AsyncPOST {0} failed with exception {1} {2}",
                                 _request.RequestUri, e.Message, e.StackTrace);
                return;
            }
        }
 public AssetServerGetHandler(IAssetService service, IServiceAuth auth, string redirectURL) :
     base("GET", "/assets", auth)
 {
     m_AssetService = service;
     m_RedirectURL = redirectURL;
     if (!m_RedirectURL.EndsWith("/"))
         m_RedirectURL = m_RedirectURL.TrimEnd('/');
 }
Beispiel #14
0
        public void Initialise(IConfigSource configSource)
        {
            IConfig config = configSource.Configs["XBakes"];
            if (config == null)
                return;

            m_URL = config.GetString("URL", String.Empty);
            m_Auth = ServiceAuth.Create(configSource, "XBakes");
        }
Beispiel #15
0
 public AssetServerGetHandler(IAssetService service, IServiceAuth auth, string redirectURL) :
     base("GET", "/assets", auth)
 {
     m_AssetService = service;
     m_RedirectURL  = redirectURL;
     if (!m_RedirectURL.EndsWith("/"))
     {
         m_RedirectURL = m_RedirectURL.TrimEnd('/');
     }
 }
        public void Initialise(IConfigSource config, string section)
        {
            string authType = Util.GetConfigVarFromSections <string>(config, "AuthType", new string[] { "Network", section }, "None");

            switch (authType)
            {
            case "BasicHttpAuthentication":
                m_Auth = new BasicHttpAuthentication(config, section);
                break;
            }
        }
        public UserAccountServerPostHandler(IUserAccountService service, IConfig config, IServiceAuth auth) :
                base("POST", "/accounts", auth)
        {
            m_UserAccountService = service;

            if (config != null)
            {
                m_AllowCreateUser = config.GetBoolean("AllowCreateUser", m_AllowCreateUser);
                m_AllowSetAccount = config.GetBoolean("AllowSetAccount", m_AllowSetAccount);
            }
        }
        public void Initialise(IConfigSource config, string section)
        {
            string authType = Util.GetConfigVarFromSections<string>(config, "AuthType", new string[] { "Network", section }, "None");

            switch (authType)
            {
                case "BasicHttpAuthentication":
                    m_Auth = new BasicHttpAuthentication(config, section);
                    break;
            }

        }
        public AuthenticationServerPostHandler(IAuthenticationService service, IConfig config, IServiceAuth auth) :
                base("POST", "/auth", auth)
        {
            m_AuthenticationService = service;

            if (config != null)
            {
                m_AllowGetAuthInfo = config.GetBoolean("AllowGetAuthInfo", m_AllowGetAuthInfo);
                m_AllowSetAuthInfo = config.GetBoolean("AllowSetAuthInfo", m_AllowSetAuthInfo);
                m_AllowSetPassword = config.GetBoolean("AllowSetPassword", m_AllowSetPassword);
            }
        }
Beispiel #20
0
        public void Initialise(IConfigSource configSource)
        {
            IConfig config = configSource.Configs["XBakes"];

            if (config == null)
            {
                return;
            }

            m_URL  = config.GetString("URL", String.Empty);
            m_Auth = ServiceAuth.Create(configSource, "XBakes");
        }
Beispiel #21
0
        public OfflineIMServiceRobustConnector(IConfigSource config, IHttpServer server, string configName) :
            base(config, server, configName)
        {
            if (configName != String.Empty)
            {
                m_ConfigName = configName;
            }

            m_log.DebugFormat("[OfflineIM.V2.RobustConnector]: Starting with config name {0}", m_ConfigName);

            m_OfflineIMService = new OfflineIMService(config);

            IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName);

            server.AddStreamHandler(new OfflineIMServicePostHandler(m_OfflineIMService, auth));
        }
        public MapAddServiceConnector(IConfigSource config, IHttpServer server, string configName) :
            base(config, server, configName)
        {
            IConfig serverConfig = config.Configs[m_ConfigName];

            if (serverConfig == null)
            {
                throw new Exception(String.Format("No section {0} in config file", m_ConfigName));
            }

            string mapService = serverConfig.GetString("LocalServiceModule",
                                                       String.Empty);

            if (mapService == String.Empty)
            {
                throw new Exception("No LocalServiceModule in config file");
            }

            Object[] args = new Object[] { config };
            m_MapService = ServerUtils.LoadPlugin <IMapImageService>(mapService, args);

            string gridService = serverConfig.GetString("GridService", String.Empty);

            if (gridService != string.Empty)
            {
                m_GridService = ServerUtils.LoadPlugin <IGridService>(gridService, args);
            }

            if (m_GridService != null)
            {
                m_log.InfoFormat("[MAP IMAGE HANDLER]: GridService check is ON");
            }
            else
            {
                m_log.InfoFormat("[MAP IMAGE HANDLER]: GridService check is OFF");
            }

            bool         proxy = serverConfig.GetBoolean("HasProxy", false);
            IServiceAuth auth  = ServiceAuth.Create(config, m_ConfigName);

            server.AddStreamHandler(new MapServerPostHandler(m_MapService, m_GridService, proxy, auth));
        }
Beispiel #23
0
        public Stream Request(Stream src, IServiceAuth auth)
        {
            ServicePointManagerTimeoutSupport.ResetHosts();
            _request               = (HttpWebRequest)WebRequest.Create(buildUri());
            _request.KeepAlive     = false;
            _request.ContentType   = "application/xml";
            _request.Timeout       = 900000;
            _request.Method        = RequestMethod;
            _asyncException        = null;
            _request.ContentLength = src.Length;
            if (auth != null)
            {
                auth.AddAuthorization(_request.Headers);
            }

            src.Seek(0, SeekOrigin.Begin);

            Stream dst = _request.GetRequestStream();

            byte[] buf    = new byte[1024];
            int    length = src.Read(buf, 0, 1024);

            while (length > 0)
            {
                dst.Write(buf, 0, length);
                length = src.Read(buf, 0, 1024);
            }

            _response = (HttpWebResponse)_request.GetResponse();

//            IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request);

            // TODO! Implement timeout, without killing the server
            // this line implements the timeout, if there is a timeout, the callback fires and the request becomes aborted
            //ThreadPool.RegisterWaitForSingleObject(responseAsyncResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true);

            return(null);
        }
        // Called from Robust
        public HGGetDisplayNames(IConfigSource config, IHttpServer server, string configName)
        {
            IConfig serverConfig = config.Configs[m_ConfigName];

            if (serverConfig == null)
            {
                throw new Exception(String.Format("No section {0} in config file", m_ConfigName));
            }

            string service = serverConfig.GetString("LocalServiceModule",
                                                    String.Empty);

            if (service == String.Empty)
            {
                throw new Exception("No LocalServiceModule in config file");
            }

            Object[] args = new Object[] { config };
            m_UserAccountService = ServerUtils.LoadPlugin <IUserAccountService>(service, args);

            IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName);

            server.AddStreamHandler(new HGGetDisplayNamesPostHandler(m_UserAccountService));
        }
Beispiel #25
0
        public AgentPreferencesServiceConnector(IConfigSource config, IHttpServer server, string configName) :
            base(config, server, configName)
        {
            IConfig serverConfig = config.Configs[m_ConfigName];

            if (serverConfig == null)
            {
                throw new Exception(String.Format("No section {0} in config file", m_ConfigName));
            }

            string service = serverConfig.GetString("LocalServiceModule", String.Empty);

            if (String.IsNullOrWhiteSpace(service))
            {
                throw new Exception("No LocalServiceModule in config file");
            }

            Object[] args = new Object[] { config };
            m_AgentPreferencesService = ServerUtils.LoadPlugin <IAgentPreferencesService>(service, args);

            IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName);;

            server.AddStreamHandler(new AgentPreferencesServerPostHandler(m_AgentPreferencesService, auth));
        }
        public ExperienceServiceConnector(IConfigSource config, IHttpServer server, string configName) :
            base(config, server, configName)
        {
            IConfig serverConfig = config.Configs[m_ConfigName];

            if (serverConfig == null)
            {
                throw new Exception(String.Format("No section {0} in config file", m_ConfigName));
            }

            string service = serverConfig.GetString("LocalServiceModule", String.Empty);

            if (service == String.Empty)
            {
                throw new Exception("LocalServiceModule not present in ExperienceService config file ExperienceService section");
            }

            Object[] args = new Object[] { config };
            m_ExperienceService = ServerUtils.LoadPlugin <IExperienceService>(service, args);

            IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName);

            server.AddStreamHandler(new ExperienceServerPostHandler(m_ExperienceService, auth));
        }
        public OfflineIMServiceRemoteConnector(IConfigSource config)
        {
            IConfig cnf = config.Configs["Messaging"];
            if (cnf == null)
            {
                m_log.WarnFormat("[OfflineIM.V2.RemoteConnector]: Missing Messaging configuration");
                return;
            }

            m_ServerURI = cnf.GetString("OfflineMessageURL", string.Empty);

            /// This is from BaseServiceConnector
            string authType = Util.GetConfigVarFromSections<string>(config, "AuthType", new string[] { "Network", "Messaging" }, "None");

            switch (authType)
            {
                case "BasicHttpAuthentication":
                    m_Auth = new BasicHttpAuthentication(config, "Messaging");
                    break;
            }
            ///
            m_log.DebugFormat("[OfflineIM.V2.RemoteConnector]: Offline IM server at {0} with auth {1}", 
                m_ServerURI, (m_Auth == null ? "None" : m_Auth.GetType().ToString()));
        }
        // Possibilities
        // /estates/estate/?region=uuid&create=[t|f]
        // /estates/estate/?eid=int
        // /estates/?name=string
        // /estates/?owner=uuid
        // /estates/  (all)
        // /estates/regions/?eid=int

        public EstateServerGetHandler(IEstateDataService service, IServiceAuth auth) :
            base("GET", "/estates", auth)
        {
            m_EstateService = service;
        }
 protected BaseStreamHandler(string httpMethod, string path, IServiceAuth auth)
     : base(httpMethod, path, null, null) 
 {
     m_Auth = auth;
 }
 public AssetServerPostHandler(IAssetService service, IServiceAuth auth) :
     base("POST", "/assets", auth)
 {
     m_AssetService = service;
 }
 public void RemoveAuthenticator(IServiceAuth auth)
 {
     m_authentications.Remove(auth);
 }
 public GridServerPostHandler(IGridService service, IServiceAuth auth) :
         base("POST", "/grid", auth)
 {
     m_GridService = service;
 }
Beispiel #33
0
        /// <summary>
        /// Perform a synchronous request
        /// </summary>
        public Stream Request(IServiceAuth auth)
        {
            lock (_lock)
            {
                int reqnum = WebUtil.RequestNumber++;
                try
                {
                    _request             = (HttpWebRequest)WebRequest.Create(buildUri());
                    _request.ContentType = "application/xml";
                    _request.Timeout     = 90000;
                    _request.Method      = RequestMethod;
                    _asyncException      = null;
                    if (auth != null)
                    {
                        auth.AddAuthorization(_request.Headers);
                    }

                    if (WebUtil.DebugLevel >= 3)
                    {
                        m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} REST {1} to {2}", reqnum, _request.Method, _request.RequestUri);
                    }

                    using (_response = (HttpWebResponse)_request.GetResponse())
                    {
                        using (Stream src = _response.GetResponseStream())
                        {
                            int length = src.Read(_readbuf, 0, BufferSize);
                            while (length > 0)
                            {
                                _resource.Write(_readbuf, 0, length);
                                length = src.Read(_readbuf, 0, BufferSize);
                            }
                        }
                    }
                }
                catch (WebException e)
                {
                    using (HttpWebResponse errorResponse = e.Response as HttpWebResponse)
                    {
                        if (null != errorResponse && HttpStatusCode.NotFound == errorResponse.StatusCode)
                        {
                            // This is often benign. E.g., requesting a missing asset will return 404.
                            m_log.DebugFormat("[REST CLIENT] Resource not found (404): {0}", _request.Address.ToString());
                        }
                        else
                        {
                            m_log.Error(string.Format("[REST CLIENT] Error fetching resource from server: {0} ", _request.Address.ToString()), e);
                        }
                    }
                    return(null);
                }

                if (_asyncException != null)
                {
                    throw _asyncException;
                }

                if (_resource != null)
                {
                    _resource.Flush();
                    _resource.Seek(0, SeekOrigin.Begin);
                }

                if (WebUtil.DebugLevel >= 5)
                {
                    WebUtil.LogResponseDetail(reqnum, _resource);
                }

                return(_resource);
            }
        }
        public UserAccountServerPostHandler(IUserAccountService service, IConfig config, IServiceAuth auth) :
            base("POST", "/accounts", auth)
        {
            m_UserAccountService = service;

            if (config != null)
            {
                m_AllowCreateUser = config.GetBoolean("AllowCreateUser", m_AllowCreateUser);
                m_AllowSetAccount = config.GetBoolean("AllowSetAccount", m_AllowSetAccount);
            }
        }
 public void AddAuthenticator(IServiceAuth auth)
 {
     m_authentications.Add(auth);
 }
 public AssetsExistHandler(IAssetService service, IServiceAuth auth) :
     base("POST", "/get_assets_exist", auth)
 {
     m_AssetService = service;
 }
        public AssetServiceConnector(IConfigSource config, IHttpServer server, string configName) :
            base(config, server, configName)
        {
            if (configName != String.Empty)
            {
                m_ConfigName = configName;
            }

            IConfig serverConfig = config.Configs[m_ConfigName];

            if (serverConfig == null)
            {
                throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName));
            }

            string assetService = serverConfig.GetString("LocalServiceModule",
                                                         String.Empty);

            if (assetService == String.Empty)
            {
                throw new Exception("No LocalServiceModule in config file");
            }

            Object[] args = new Object[] { config, m_ConfigName };
            m_AssetService =
                ServerUtils.LoadPlugin <IAssetService>(assetService, args);

            if (m_AssetService == null)
            {
                throw new Exception(String.Format("Failed to load AssetService from {0}; config is {1}", assetService, m_ConfigName));
            }

            bool allowDelete         = serverConfig.GetBoolean("AllowRemoteDelete", false);
            bool allowDeleteAllTypes = serverConfig.GetBoolean("AllowRemoteDeleteAllTypes", false);

            string redirectURL = serverConfig.GetString("RedirectURL", string.Empty);

            AllowedRemoteDeleteTypes allowedRemoteDeleteTypes;

            if (!allowDelete)
            {
                allowedRemoteDeleteTypes = AllowedRemoteDeleteTypes.None;
            }
            else
            {
                if (allowDeleteAllTypes)
                {
                    allowedRemoteDeleteTypes = AllowedRemoteDeleteTypes.All;
                }
                else
                {
                    allowedRemoteDeleteTypes = AllowedRemoteDeleteTypes.MapTile;
                }
            }

            IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName);

            server.AddStreamHandler(new AssetServerGetHandler(m_AssetService, auth, redirectURL));
            server.AddStreamHandler(new AssetServerPostHandler(m_AssetService, auth));
            server.AddStreamHandler(new AssetServerDeleteHandler(m_AssetService, allowedRemoteDeleteTypes, auth));
            server.AddStreamHandler(new AssetsExistHandler(m_AssetService));

            MainConsole.Instance.Commands.AddCommand("Assets", false,
                                                     "show asset",
                                                     "show asset <ID>",
                                                     "Show asset information",
                                                     HandleShowAsset);

            MainConsole.Instance.Commands.AddCommand("Assets", false,
                                                     "delete asset",
                                                     "delete asset <ID>",
                                                     "Delete asset from database",
                                                     HandleDeleteAsset);

            MainConsole.Instance.Commands.AddCommand("Assets", false,
                                                     "dump asset",
                                                     "dump asset <ID>",
                                                     "Dump asset to a file",
                                                     "The filename is the same as the ID given.",
                                                     HandleDumpAsset);
        }
 public MapServerPostHandler(IMapImageService service, IGridService grid, bool proxy, IServiceAuth auth) :
     base("POST", "/map", auth)
 {
     m_MapService = service;
     m_GridService = grid;
     m_Proxy = proxy;
 }
 public FriendsServerPostHandler(IFriendsService service, IServiceAuth auth) :
         base("POST", "/friends", auth)
 {
     m_FriendsService = service;
 }
Beispiel #40
0
        /// <summary>
        /// Perform a synchronous request
        /// </summary>
        public Stream Request(IServiceAuth auth)
        {
            lock (_lock)
            {
                _request             = (HttpWebRequest)WebRequest.Create(buildUri());
                _request.KeepAlive   = false;
                _request.ContentType = "application/xml";
                _request.Timeout     = 200000;
                _request.Method      = RequestMethod;
                _asyncException      = null;
                if (auth != null)
                {
                    auth.AddAuthorization(_request.Headers);
                }

                int reqnum = WebUtil.RequestNumber++;
                if (WebUtil.DebugLevel >= 3)
                {
                    m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} REST {1} to {2}", reqnum, _request.Method, _request.RequestUri);
                }

//                IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request);

                try
                {
                    using (_response = (HttpWebResponse)_request.GetResponse())
                    {
                        using (Stream src = _response.GetResponseStream())
                        {
                            int length = src.Read(_readbuf, 0, BufferSize);
                            while (length > 0)
                            {
                                _resource.Write(_readbuf, 0, length);
                                length = src.Read(_readbuf, 0, BufferSize);
                            }

                            // TODO! Implement timeout, without killing the server
                            // this line implements the timeout, if there is a timeout, the callback fires and the request becomes aborted
                            //ThreadPool.RegisterWaitForSingleObject(responseAsyncResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true);

                            //                _allDone.WaitOne();
                        }
                    }
                }
                catch (WebException e)
                {
                    using (HttpWebResponse errorResponse = e.Response as HttpWebResponse)
                    {
                        if (null != errorResponse && HttpStatusCode.NotFound == errorResponse.StatusCode)
                        {
                            // This is often benign. E.g., requesting a missing asset will return 404.
                            m_log.DebugFormat("[REST CLIENT] Resource not found (404): {0}", _request.Address.ToString());
                        }
                        else
                        {
                            m_log.Error(string.Format("[REST CLIENT] Error fetching resource from server: {0} ", _request.Address.ToString()), e);
                        }
                    }
                    return(null);
                }


                if (_asyncException != null)
                {
                    throw _asyncException;
                }

                if (_resource != null)
                {
                    _resource.Flush();
                    _resource.Seek(0, SeekOrigin.Begin);
                }

                if (WebUtil.DebugLevel >= 5)
                {
                    WebUtil.LogResponseDetail(reqnum, _resource);
                }

                return(_resource);
            }
        }
Beispiel #41
0
 public AvatarServerPostHandler(IAvatarService service, IServiceAuth auth) :
     base("POST", "/avatar", auth)
 {
     m_AvatarService = service;
 }
 public EmfluenceService(IServiceAuth auth) : base(auth) { }
Beispiel #43
0
        /// <summary>
        /// Perform a synchronous request
        /// </summary>
        public Stream Request(IServiceAuth auth)
        {
            lock (_lock)
            {
                _request = (HttpWebRequest) WebRequest.Create(buildUri());
                _request.KeepAlive = false;
                _request.ContentType = "application/xml";
                _request.Timeout = 200000;
                _request.Method = RequestMethod;
                _asyncException = null;
                if (auth != null)
                    auth.AddAuthorization(_request.Headers);

                int reqnum = WebUtil.RequestNumber++;
                if (WebUtil.DebugLevel >= 3)
                    m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} REST {1} to {2}", reqnum, _request.Method, _request.RequestUri);

//                IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request);
                try
                {
                    _response = (HttpWebResponse) _request.GetResponse();
                }
                catch (WebException e)
                {
                    HttpWebResponse errorResponse = e.Response as HttpWebResponse;
                    if (null != errorResponse && HttpStatusCode.NotFound == errorResponse.StatusCode)
                    {
                        // This is often benign. E.g., requesting a missing asset will return 404.
                        m_log.DebugFormat("[REST CLIENT] Resource not found (404): {0}", _request.Address.ToString());
                    }
                    else
                    {
                        m_log.Error(string.Format("[REST CLIENT] Error fetching resource from server: {0} ", _request.Address.ToString()), e);
                    }

                    return null;
                }

                Stream src = _response.GetResponseStream();
                int length = src.Read(_readbuf, 0, BufferSize);
                while (length > 0)
                {
                    _resource.Write(_readbuf, 0, length);
                    length = src.Read(_readbuf, 0, BufferSize);
                }


                // TODO! Implement timeout, without killing the server
                // this line implements the timeout, if there is a timeout, the callback fires and the request becomes aborted
                //ThreadPool.RegisterWaitForSingleObject(responseAsyncResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true);

//                _allDone.WaitOne();
                if (_response != null)
                    _response.Close();
                if (_asyncException != null)
                    throw _asyncException;

                if (_resource != null)
                {
                    _resource.Flush();
                    _resource.Seek(0, SeekOrigin.Begin);
                }

                if (WebUtil.DebugLevel >= 5)
                    WebUtil.LogResponseDetail(reqnum, _resource);

                return _resource;
            }
        }
Beispiel #44
0
        // Possibilities
        // /estates/estate/?region=uuid&create=[t|f]
        // /estates/estate/?eid=int
        // /estates/?name=string
        // /estates/?owner=uuid
        // /estates/  (all)
        // /estates/regions/?eid=int

        public EstateServerGetHandler(IEstateDataService service, IServiceAuth auth) :
            base("GET", "/estates", auth)
        {
            m_EstateService = service;
        }
Beispiel #45
0
 public AssetServerPostHandler(IAssetService service, IServiceAuth auth) :
     base("POST", "/assets", auth)
 {
     m_AssetService = service;
 }
 public AvatarServerPostHandler(IAvatarService service, IServiceAuth auth) :
         base("POST", "/avatar", auth)
 {
     m_AvatarService = service;
 }
Beispiel #47
0
        public Stream Request(Stream src, IServiceAuth auth)
        {
            _request = (HttpWebRequest) WebRequest.Create(buildUri());
            _request.KeepAlive = false;
            _request.ContentType = "application/xml";
            _request.Timeout = 900000;
            _request.Method = RequestMethod;
            _asyncException = null;
            _request.ContentLength = src.Length;
            if (auth != null)
                auth.AddAuthorization(_request.Headers);

            src.Seek(0, SeekOrigin.Begin);

            int reqnum = WebUtil.RequestNumber++;
            if (WebUtil.DebugLevel >= 3)
                m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} REST {1} to {2}", reqnum, _request.Method, _request.RequestUri);
            if (WebUtil.DebugLevel >= 5)
                WebUtil.LogOutgoingDetail(string.Format("SEND {0}: ", reqnum), src);

            Stream dst = _request.GetRequestStream();

            byte[] buf = new byte[1024];
            int length = src.Read(buf, 0, 1024);
            while (length > 0)
            {
                dst.Write(buf, 0, length);
                length = src.Read(buf, 0, 1024);
            }

            try
            {
                _response = (HttpWebResponse)_request.GetResponse();
            }
            catch (WebException e)
            {
                m_log.WarnFormat("[REST]: Request {0} {1} failed with status {2} and message {3}",
                                  RequestMethod, _request.RequestUri, e.Status, e.Message);
                return null;
            }
            catch (Exception e)
            {
                m_log.WarnFormat(
                    "[REST]: Request {0} {1} failed with exception {2} {3}",
                    RequestMethod, _request.RequestUri, e.Message, e.StackTrace);
                return null;
            }

            if (WebUtil.DebugLevel >= 5)
            {
                using (Stream responseStream = _response.GetResponseStream())
                {
                    using (StreamReader reader = new StreamReader(responseStream))
                    {
                        string responseStr = reader.ReadToEnd();
                        WebUtil.LogResponseDetail(reqnum, responseStr);
                    }
                }
            }

            _response.Close();

//            IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request);

            // TODO! Implement timeout, without killing the server
            // this line implements the timeout, if there is a timeout, the callback fires and the request becomes aborted
            //ThreadPool.RegisterWaitForSingleObject(responseAsyncResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true);

            return null;
        }
Beispiel #48
0
        public Stream Request(Stream src, IServiceAuth auth)
        {
            ServicePointManagerTimeoutSupport.ResetHosts();
            _request = (HttpWebRequest)WebRequest.Create(buildUri());
            _request.KeepAlive = false;
            _request.ContentType = "application/xml";
            _request.Timeout = 900000;
            _request.Method = RequestMethod;
            _asyncException = null;
            _request.ContentLength = src.Length;
            if (auth != null)
                auth.AddAuthorization(_request.Headers);

            src.Seek(0, SeekOrigin.Begin);
            
            Stream dst = _request.GetRequestStream();

            byte[] buf = new byte[1024];
            int length = src.Read(buf, 0, 1024);
            while (length > 0)
            {
                dst.Write(buf, 0, length);
                length = src.Read(buf, 0, 1024);
            }

            _response = (HttpWebResponse) _request.GetResponse();

//            IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request);

            // TODO! Implement timeout, without killing the server
            // this line implements the timeout, if there is a timeout, the callback fires and the request becomes aborted
            //ThreadPool.RegisterWaitForSingleObject(responseAsyncResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true);

            return null;
        }
 public AssetServerDeleteHandler(IAssetService service, AllowedRemoteDeleteTypes allowedTypes, IServiceAuth auth) :
     base("DELETE", "/assets", auth)
 {
     m_AssetService = service;
     m_allowedTypes = allowedTypes;
 }
 public BakesServerPostHandler(IBakedTextureService service, IServiceAuth auth) :
         base("POST", "/bakes", auth)
 {
     m_BakesService = service;
 }
        public AuthenticationServerPostHandler(IAuthenticationService service, IConfig config, IServiceAuth auth) :
            base("POST", "/auth", auth)
        {
            m_AuthenticationService = service;

            if (config != null)
            {
                m_AllowGetAuthInfo = config.GetBoolean("AllowGetAuthInfo", m_AllowGetAuthInfo);
                m_AllowSetAuthInfo = config.GetBoolean("AllowSetAuthInfo", m_AllowSetAuthInfo);
                m_AllowSetPassword = config.GetBoolean("AllowSetPassword", m_AllowSetPassword);
            }
        }
 public GroupsServicePostHandler(GroupsService service, IServiceAuth auth) :
     base("POST", "/groups", auth)
 {
     m_GroupsService = service;
 }
Beispiel #53
0
        public Stream Request(Stream src, IServiceAuth auth)
        {
            _request               = (HttpWebRequest)WebRequest.Create(buildUri());
            _request.KeepAlive     = false;
            _request.ContentType   = "application/xml";
            _request.Timeout       = 90000;
            _request.Method        = RequestMethod;
            _asyncException        = null;
            _request.ContentLength = src.Length;
            if (auth != null)
            {
                auth.AddAuthorization(_request.Headers);
            }

            src.Seek(0, SeekOrigin.Begin);

            int reqnum = WebUtil.RequestNumber++;

            if (WebUtil.DebugLevel >= 3)
            {
                m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} REST {1} to {2}", reqnum, _request.Method, _request.RequestUri);
            }
            if (WebUtil.DebugLevel >= 5)
            {
                WebUtil.LogOutgoingDetail(string.Format("SEND {0}: ", reqnum), src);
            }


            try
            {
                using (Stream dst = _request.GetRequestStream())
                {
//                    m_log.Debug("[REST]: GetRequestStream is ok");

                    byte[] buf    = new byte[1024];
                    int    length = src.Read(buf, 0, 1024);
//                    m_log.Debug("[REST]: First Read is ok");
                    while (length > 0)
                    {
                        dst.Write(buf, 0, length);
                        length = src.Read(buf, 0, 1024);
                    }
                }

                _response = (HttpWebResponse)_request.GetResponse();
            }
            catch (WebException e)
            {
                m_log.WarnFormat("[REST]: Request {0} {1} failed with status {2} and message {3}",
                                 RequestMethod, _request.RequestUri, e.Status, e.Message);
                return(null);
            }
            catch (Exception e)
            {
                m_log.WarnFormat(
                    "[REST]: Request {0} {1} failed with exception {2} {3}",
                    RequestMethod, _request.RequestUri, e.Message, e.StackTrace);
                return(null);
            }

            if (WebUtil.DebugLevel >= 5)
            {
                using (Stream responseStream = _response.GetResponseStream())
                {
                    using (StreamReader reader = new StreamReader(responseStream))
                    {
                        string responseStr = reader.ReadToEnd();
                        WebUtil.LogResponseDetail(reqnum, responseStr);
                    }
                }
            }

            if (_response != null)
            {
                _response.Close();
            }

//            IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request);

            // TODO! Implement timeout, without killing the server
            // this line implements the timeout, if there is a timeout, the callback fires and the request becomes aborted
            //ThreadPool.RegisterWaitForSingleObject(responseAsyncResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true);

            return(null);
        }
 public AgentPreferencesServerPostHandler(IAgentPreferencesService service, IServiceAuth auth) :
 base("POST", "/agentprefs", auth)
 {
     m_AgentPreferencesService = service;
 }
 public OfflineIMServicePostHandler(IOfflineIMService service, IServiceAuth auth) :
     base("POST", "/offlineim", auth)
 {
     m_OfflineIMService = service;
 }
 public XInventoryConnectorPostHandler(IInventoryService service, IServiceAuth auth) :
         base("POST", "/xinventory", auth)
 {
     m_InventoryService = service;
 }
 public GroupsServicePostHandler(GroupsService service, IServiceAuth auth) :
     base("POST", "/groups", auth)
 {
     m_GroupsService = service;
 }
 public PresenceServerPostHandler(IPresenceService service, IServiceAuth auth) :
         base("POST", "/presence", auth)
 {
     m_PresenceService = service;
 }