Exemplo n.º 1
0
        /// <summary>
        /// Modify data store for an iFolder Server.
        /// </summary>
        /// <param name="name">The name of the data store.</param>
        /// <returns>Bool true on success.</returns>
        public bool ModifyStore(string datapath, bool enabled)
        {
            log.Debug(" Modify store called - :  {0}", datapath);
            HostNode        host = HostNode.GetLocalHost();
            MultiValuedList mv   = host.Properties.GetProperties(PropertyTags.DataPath);

            foreach (Property prop in mv)
            {
                string[] comps = ((string)prop.Value).Split('|');
                if ((datapath.Equals(comps[0])))
                {
                    Store  store  = Store.GetStore();
                    Domain domain = store.GetDomain(store.DefaultDomain);

                    prop.Delete();
                    domain.Commit(host);
                    string storageFormat = String.Format("{0}|{1}", comps[0], comps[1]);
                    storageFormat = String.Format("{0}|{1}", storageFormat, enabled.ToString());
                    Property p = new Property(PropertyTags.DataPath, storageFormat);
                    p.LocalProperty = true;
                    host.Properties.AddProperty(p);
                    domain.Commit(host);
                }
            }

            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Delete data store for an iFolder Server.
        /// </summary>
        /// <param name="name">The name of the data store.</param>
        /// <returns>Bool true on success.</returns>
        public bool DeleteStore(string datapathname)
        {
            log.Debug(" Delete Store called with : {0}", datapathname);
            HostNode        host = HostNode.GetLocalHost();
            MultiValuedList mv   = host.Properties.GetProperties(PropertyTags.DataPath);

            foreach (Property prop in mv)
            {
                string[] comps = ((string)prop.Value).Split('|');
                if ((datapathname.Equals(comps[0])))
                {
                    Store  store  = Store.GetStore();
                    Domain domain = store.GetDomain(store.DefaultDomain);

                    if (!Directory.Exists(Path.Combine(comps[1], "SimiasFiles")))
                    {
                        prop.Delete();
                        domain.Commit(host);

                        //delete the source link of the symbolic link created
                        string storepath = Store.StorePath;
                        string tmppath   = Path.Combine(storepath, "SimiasFiles");
                        tmppath = Path.Combine(tmppath, datapathname);
                        Mono.Unix.Native.Syscall.unlink(tmppath);
                    }
                }
            }
            return(true);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Add a data store for an iFolder Server.
        /// </summary>
        /// <returns>Bool true on success.</returns>
        public int AddStore(string ServerID)
        {
            Store  store     = Store.GetStore();
            Domain domain    = store.GetDomain(store.DefaultDomain);
            string storepath = Store.StorePath;
            string tmppath   = Path.Combine(storepath, "SimiasFiles");

            tmppath = Path.Combine(tmppath, this.DataPath);
            int result = 0;

            if (Directory.Exists(tmppath) == true)
            {
                return(1);
            }
            else if (Directory.Exists(this.FullPath) != true)
            {
                return(2);
            }

            Mono.Unix.Native.Syscall.symlink(this.FullPath, tmppath);

            string storageFormat = String.Format("{0}|{1}", this.DataPath, this.FullPath);

            storageFormat = String.Format("{0}|{1}", storageFormat, this.Enabled.ToString());
            HostNode host = HostNode.GetLocalHost();
            Property p    = new Property(PropertyTags.DataPath, storageFormat);

            p.LocalProperty = true;
            host.Properties.AddProperty(p);
            domain.Commit(host);
            return(result);
        }
Exemplo n.º 4
0
        /// <summary>
        /// commit the encrypted password as part of member object
        /// </summary>
        /// <returns>true if setting is successful</returns>
        private bool SetAdminPassword()
        {
            bool status = false;

            // Bootstrap the domain from the Simias.config file
            Simias.Configuration config = Store.Config;
            string adminName            = config.Get("EnterpriseDomain", "AdminName");
            string adminPassword        = config.Get("EnterpriseDomain", "AdminPassword");

            if (adminName != null && adminName != "" && adminPassword != null)
            {
                try
                {
                    Member member = domain.GetMemberByName(adminName);
                    if (member != null)
                    {
                        Property pwd =
                            member.Properties.GetSingleProperty(InternalUser.pwdProperty);
                        if (pwd == null || pwd.Value == null)
                        {
                            pwd = new Property(InternalUser.pwdProperty, HashPassword(adminPassword));
                            member.Properties.ModifyProperty(pwd);

                            // Marker so we know this member was created internally
                            // and not through an external identity sync.
                            domain.SetType(member as Node, InternalUser.memberMarker);
                            domain.Commit(member);
                            status = true;
                        }
                    }
                }
                catch (Exception ap)
                {
                    log.Error(ap.Message);
                    log.Error(ap.StackTrace);
                }
            }

            return(status);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Method to get the Simias Enterprise server domain
        /// If the the domain does not exist and the create flag is true
        /// the domain will be created.  If create == false, ownerName is ignored
        /// </summary>
        internal Simias.Storage.Domain GetServerDomain(bool Create)
        {
            //  Check if the Server domain exists in the store
            Simias.Storage.Domain enterpriseDomain = null;
            bool master = true;

            try
            {
                Collection collection = store.GetSingleCollectionByType("Enterprise");
                if (collection != null)
                {
                    enterpriseDomain = store.GetDomain(collection.ID);
                    if (enterpriseDomain != null)
                    {
                        this.domainName = enterpriseDomain.Name;
                        this.id         = enterpriseDomain.ID;

                        // For backwards compatibility, if the report collection does not
                        // exist because the store was created with a previous version of
                        // simias, check and create it here.
                        // Don't create this directory on a slave server.

                        //TODO : Check with migration !!
                        Report.CreateReportCollection(store, enterpriseDomain);
                    }
                }

                if (enterpriseDomain == null && Create == true)
                {
                    // Bootstrap the domain from the Simias.config file
                    Simias.Configuration config = Store.Config;
                    string cfgValue             = config.Get("EnterpriseDomain", "SystemName");
                    if (cfgValue != null && cfgValue != String.Empty)
                    {
                        this.domainName = cfgValue;
                    }

                    cfgValue = config.Get("EnterpriseDomain", "Description");
                    if (cfgValue != null && cfgValue != String.Empty)
                    {
                        this.description = cfgValue;
                    }

                    cfgValue = config.Get("EnterpriseDomain", "AdminName");
                    if (cfgValue != null && cfgValue != String.Empty)
                    {
                        this.admin = cfgValue;
                    }

                    cfgValue = config.Get("Server", "MasterAddress");
                    if (cfgValue != null && cfgValue != String.Empty)
                    {
                        master = false;
                    }

                    /*
                     * cfgValue = config.Get( "EnterpriseDomain", "AdminPassword" );
                     * if ( cfgValue != null && cfgValue != "" )
                     * {
                     *      this.adminPassword = cfgValue;
                     * }
                     */

                    if (master == true)
                    {
                        cfgValue = config.Get("EnterpriseDomain", "DomainID");
                        if (cfgValue != null && cfgValue != String.Empty)
                        {
                            this.id = cfgValue;
                        }
                        else
                        {
                            this.id = Guid.NewGuid().ToString();
                        }

                        // Create the enterprise server domain.
                        enterpriseDomain =
                            new Simias.Storage.Domain(
                                store,
                                this.domainName,
                                this.id,
                                this.description,
                                Simias.Sync.SyncRoles.Master,
                                Simias.Storage.Domain.ConfigurationType.ClientServer);

                        // This needs to be added to allow the enterprise location provider
                        // to be able to resolve this domain.
                        enterpriseDomain.SetType(enterpriseDomain, "Enterprise");

                        // Create the owner member for the domain.
                        string provider = null;
                        cfgValue = config.Get("Identity", "Assembly");
                        if (cfgValue != null && cfgValue != String.Empty)
                        {
                            provider = cfgValue;
                        }

                        this.admin = ParseUserName(this.admin, provider);

                        Member member =
                            new Member(this.admin, Guid.NewGuid().ToString(), Access.Rights.Admin);

                        member.IsOwner = true;
                        enterpriseDomain.SetType(member as Node, "User");

                        // Marker so we know this member was created internally
                        // and not through an external identity sync.
                        enterpriseDomain.SetType(member as Node, "Internal");

                        enterpriseDomain.Commit(new Node[] { enterpriseDomain, member });

                        // Set the domain default
                        store.DefaultDomain = enterpriseDomain.ID;

                        // Create the name mapping.
                        store.AddDomainIdentity(enterpriseDomain.ID, member.UserID);
                    }
                    else
                    {
                        // Slave host so create the proxy domain and owner.
                        enterpriseDomain      = Simias.Host.SlaveSetup.GetDomain(Store.StorePath);
                        store.DefaultDomain   = enterpriseDomain.ID;
                        enterpriseDomain.Role = Simias.Sync.SyncRoles.Slave;
                        Member owner = Simias.Host.SlaveSetup.GetOwner(Store.StorePath);
                        enterpriseDomain.SetType(enterpriseDomain, "Enterprise");
                        enterpriseDomain.Proxy = true;
                        owner.Proxy            = true;
                        enterpriseDomain.Commit(new Node[] { enterpriseDomain, owner });
                    }

                    Report.CreateReportCollection(store, enterpriseDomain);
                }
            }
            catch (Exception gssd)
            {
                log.Error(gssd.Message);
                log.Error(gssd.StackTrace);
            }

            return(enterpriseDomain);
        }
Exemplo n.º 6
0
 private void Init()
 {
     hostAddress = MyDns.GetHostName();
        Store store = Store.GetStore();
        try
        {
     Uri localUri = Manager.LocalServiceUrl;
     Simias.Storage.Domain rDomain = store.GetDomain( ID );
     if (rDomain == null)
     {
      rDomain =
       new Simias.Storage.Domain(
        store,
        this.domainName,
        Simias.Gaim.GaimDomain.ID,
        this.description,
        Simias.Sync.SyncRoles.Master,
        Simias.Storage.Domain.ConfigurationType.Workgroup );
      rDomain.SetType( rDomain, "Workgroup" );
      string storedUserID = GetGaimUserID();
      if (storedUserID != null)
      {
       log.Debug("Creating the Gaim Domain with a saved UserID");
       userID = storedUserID;
      }
      else
      {
       log.Debug("Creating the Gaim Domain with a NEW UserID");
       userID = Guid.NewGuid().ToString();
      }
      Member member =
       new Member(
        userName,
        userID,
        Access.Rights.Admin );
      member.IsOwner = true;
      if (localUri == null)
      {
       localUri = Manager.LocalServiceUrl;
       if (localUri != null)
       {
        Simias.Storage.Property p = new Property("Gaim:SimiasURL", localUri.ToString());
        p.LocalProperty = true;
        member.Properties.AddProperty(p);
       }
       else
       {
        log.Debug("Manager.LocalServiceUrl returned NULL!");
       }
      }
      if (aliasName != null && aliasName.Length > 0)
      {
       Simias.Storage.Property p = new Property("Gaim:Alias", aliasName);
       p.LocalProperty = true;
       member.FN = string.Format("{0} ({1})", aliasName, hostName);
      }
      rDomain.Commit( new Node[] { rDomain, member } );
      store.AddDomainIdentity( rDomain.ID, member.UserID );
      GaimService.RegisterDomainProvider();
     }
     Member pMember;
     Simias.POBox.POBox poBox = null;
     string poBoxName = "POBox:" + Simias.Gaim.GaimDomain.ID + ":" + userID;
     try
     {
      poBox = Simias.POBox.POBox.FindPOBox( store, Simias.Gaim.GaimDomain.ID, userID );
     }
     catch{}
     if (poBox == null)
     {
      poBox = new Simias.POBox.POBox( store, poBoxName, ID );
      pMember =
       new Member( userName, userID, Access.Rights.ReadWrite );
      pMember.IsOwner = true;
      poBox.Commit(new Node[] { poBox, pMember });
     }
     else
     {
      pMember = poBox.GetMemberByID( userID );
      if (pMember == null)
      {
       pMember =
        new Member( userName, userID, Access.Rights.ReadWrite );
       pMember.IsOwner = true;
       poBox.Commit(new Node[] { pMember });
      }
     }
     poBoxID = poBox.ID;
        }
        catch( Exception e1 )
        {
     log.Error(e1.Message);
     log.Error(e1.StackTrace);
     throw e1;
        }
 }