Exemplo n.º 1
0
        private string                  m_InitialLocalPath; // - the path in the inventory that webdav operations operate 
                                                            // for example "/avatar/" or "/"

        public WebDAVPropertyHandler(WebDAVServerConnector connector,
                                     IInventoryService inventory_service,
                                     IAssetService asset_service,
                                     IPropertyProvider property_provider,
                                     WebDAVLockHandler lock_handler,
                                     string domain,
                                     string local_initial_path) 
        {
            m_WebDAVServerConnector     = connector;
            m_InventoryService          = inventory_service;
            m_AssetService              = asset_service;
            m_PropertyProvider          = property_provider;
            m_SubDomain                 = domain;
            m_InitialLocalPath          = local_initial_path;
            m_LockHandler               = lock_handler;
        }
Exemplo n.º 2
0
        public WebDAVServerConnector(IConfigSource config, IHttpServer server) :
            base(config, server, CONFIG_NAME)
        {
            IConfig serverConfig = config.Configs["InventoryService"];
            if (serverConfig == null)
                throw new Exception("No InventoryService section in config file");

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

            IConfig assetConfig = config.Configs["AssetService"];
            if (assetConfig == null)
                throw new Exception("No InventoryService section in config file");

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

            Object[] args = new Object[] { config };
            m_InventoryService = ServerUtils.LoadPlugin<IInventoryService>(inventoryService, args);
            m_AssetService = ServerUtils.LoadPlugin<IAssetService>(assetService, args);
            
            if (m_InventoryService == null)
                throw new Exception("Failed to load IInventoryService \"" + inventoryService + "\"");

            IConfig cablebeachConfig = config.Configs["CableBeachService"];
            if (cablebeachConfig == null)
                throw new Exception("No CableBeachService section in config file");

            m_OpenIDProvider = cablebeachConfig.GetString("OpenIDProvider", String.Empty);
            m_UserService = cablebeachConfig.GetString("UserService", String.Empty);
            m_ServiceTimeout = cablebeachConfig.GetInt("ServiceTimeOut", 10000);
            m_UseLocks = cablebeachConfig.GetBoolean("UseLocks", true);
            m_UseLockTimeouts = cablebeachConfig.GetBoolean("UseLockTimeouts", true);

            // Get property provider in ini file: choices currently NHibernatePropertyStorage and DummyPropertyProvider
            string propertyProvider = cablebeachConfig.GetString("PropertyProvider", "NHibernatePropertyStorage");

            // Get all property providers in this assembly
            System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly();
            Type[] constructorParams = new Type[] { };
            object[] parameters = new object[] { };
            bool found = false;
            foreach (Type t in a.GetTypes())
            {
                try
                {
                    Type[] interfaces = t.GetInterfaces();
                    foreach (Type i in interfaces)
                    {
                        if (i.Name.Equals("IPropertyProvider"))
                            if (t.Name == propertyProvider)
                            {
                                System.Reflection.ConstructorInfo info = t.GetConstructor(constructorParams);
                                m_PropertyProvider = (IPropertyProvider)info.Invoke(parameters);
                                found = true;
                                break;
                            }
                    }
                    if (found)
                        break;
                }
                catch (Exception e) { throw e; }
            }
            m_PropertyProvider.Initialize(config);
            //m_PropertyProvider = new DummyPropertyProvider();

            m_InventoryLockHandler = new WebDAVLockHandler(this, m_InventoryPropertyHandler, "inventory", "/");
            m_AvatarPropertyHandler = new WebDAVPropertyHandler(this, m_InventoryService, m_AssetService, m_PropertyProvider, m_InventoryLockHandler, "avatar", AVATAR_FOLDER_PATH);
            m_InventoryPropertyHandler = new WebDAVPropertyHandler(this, m_InventoryService, m_AssetService, m_PropertyProvider, m_InventoryLockHandler, "inventory", "/");
            

            // Avatar WebDAV service endpoint
            WebDAVListener avatarWebdav = new WebDAVListener(server, "/avatar");
            avatarWebdav.Authentication = AuthenticationType.None;
            avatarWebdav.OnPropFind += m_AvatarPropertyHandler.PropFindHandler;
            avatarWebdav.OnGet += AvatarGetHandler;
            //avatarWebdav.OnLock += AvatarLockHandler;
            //avatarWebdav.OnUnlock += AvatarUnlockHandler;

            // Inventory WebDAV service endpoint
            WebDAVListener inventoryWebdav = new WebDAVListener(server, "/inventory");
            //inventoryWebdav.Authentication = AuthenticationType.None;
            //inventoryWebdav.Authentication = AuthenticationType.Digest;
            inventoryWebdav.Authentication = AuthenticationType.Basic;

            inventoryWebdav.OnGet += InventoryGetHandler;
            inventoryWebdav.OnCopy += InventoryCopyHandler;
            inventoryWebdav.OnPropFind += m_InventoryPropertyHandler.PropFindHandler;
            //inventoryWebdav.OnDigestAuthenticate += InventoryOnDigestAuthenticateHandler;
            //inventoryWebdav.OnDigestAuthenticate += new DigestAuthenticationCallback(inventoryWebdav_OnDigestAuthenticate);
            inventoryWebdav.OnBasicAuthenticate += InventoryBasicAuthenticationHandler;

            // if we use locks and timeouts we proxy these calls, through timeout handler and then through lock handler
            // if we use locks but not timeouts we only through lock handler
            if (m_UseLocks && m_UseLockTimeouts) 
            {
                WebDAVTransparentLockTimeOutHandler handler = WebDAVTransparentLockTimeOutHandler.CreateProxyHandler<ILockProxy>(m_InventoryLockHandler, m_InventoryLockHandler);
                ILockProxy proxy = (ILockProxy)handler.GetTransparentProxy();
                
                m_InventoryLockHandler.m_useTimeOuts = true;
                m_InventoryLockHandler.m_WebDAVTimeOutHandler = handler;
                WebDAVTransparentLockTimeOutHandler.MAX_TIME_OUT = cablebeachConfig.GetLong("MaxTimeOut", 60 * 60 * 24 * 7); // default set to one week
                                                                                                                             // -1 = infinite
                WebDAVTransparentLockTimeOutHandler.FORCE_SERVER_TIMEOUT = cablebeachConfig.GetBoolean("ForseServerTimeOut", false);
                inventoryWebdav.OnNewCol += proxy.MkcolCallback;
                inventoryWebdav.OnMove += proxy.MoveCallback;
                inventoryWebdav.OnPut += proxy.PutCallback;
                inventoryWebdav.OnDelete += proxy.DeleteCallback;
                inventoryWebdav.OnPropPatch += proxy.PropPatchCallback;
                inventoryWebdav.OnLock += proxy.LockHandler;
                inventoryWebdav.OnUnlock += m_InventoryLockHandler.UnlockHandler; // dont need to be proxied
            }
            else if (m_UseLocks && !m_UseLockTimeouts)
            {
                inventoryWebdav.OnNewCol += m_InventoryLockHandler.MkcolCallback;
                inventoryWebdav.OnMove += m_InventoryLockHandler.MoveCallback;
                inventoryWebdav.OnPut += m_InventoryLockHandler.PutCallback;
                inventoryWebdav.OnDelete += m_InventoryLockHandler.DeleteCallback;
                inventoryWebdav.OnPropPatch += m_InventoryLockHandler.PropPatchCallback;
                inventoryWebdav.OnLock += m_InventoryLockHandler.LockHandler;
                inventoryWebdav.OnUnlock += m_InventoryLockHandler.UnlockHandler;
            }
            else
            {
                inventoryWebdav.OnNewCol += InventoryNewColHandler;
                inventoryWebdav.OnMove += InventoryMoveHandler;
                inventoryWebdav.OnPut += InventoryPutHandler;
                inventoryWebdav.OnDelete += InventoryDeleteHandler;
                inventoryWebdav.OnPropPatch += m_InventoryPropertyHandler.PropPatchHandler;
            }


            // Register this server connector as a Cable Beach service
            CableBeachServerState.RegisterService(new Uri(CableBeachServices.FILESYSTEM), CreateCapabilitiesHandler);

            CableBeachServerState.Log.Info("[CABLE BEACH WEBDAV]: WebDAVServerConnector is running");
        }
Exemplo n.º 3
0
 public WebDAVTimeOutHandler(WebDAVLockHandler lockHandler)
 { 
     m_LockHandler = lockHandler;
     m_TimeOuts = new OrderedTimeLockDictionary(lockHandler);
 }