Esempio n. 1
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="Context">Http context</param>
 /// <param name="ParentCollection">parent collection of this collection</param>
 /// <param name="SN">shallow node for collection</param>
 public Item(HttpContext Context, Collection ParentCollection, ShallowNode SN)
 {
     ctx        = Context;
     store      = Store.GetStore();
     collection = ParentCollection;
     node       = new Node(collection, SN);
 }
Esempio n. 2
0
        /// <summary>
        /// POBox factory method that constructs a POBox object for the specified user in the specified domain.
        /// </summary>
        /// <param name="storeObject">The Store object that the POBox belongs to.</param>
        /// <param name="domainId">The ID of the domain that the POBox belongs to.</param>
        /// <param name="userId">The ID of the user that the POBox belongs to.</param>
        /// <returns></returns>
        public static POBox FindPOBox(Store storeObject, string domainId, string userId)
        {
            POBox poBox = null;

            // Build the name of the POBox.
            string name = "POBox:" + domainId + ":" + userId;

            // Search for the POBox.
            ICSEnumerator listEnum = storeObject.GetCollectionsByName(name).GetEnumerator() as ICSEnumerator;

            // There should only be one value returned...
            if (listEnum.MoveNext())
            {
                ShallowNode shallowNode = (ShallowNode)listEnum.Current;

                if (listEnum.MoveNext())
                {
                    // TODO: multiple values were returned ... throw an exception.
                }

                poBox = new POBox(storeObject, shallowNode);
            }

            listEnum.Dispose();
            return(poBox);
        }
Esempio n. 3
0
 /// <summary>
 /// Constructor that creates browser shallow node from a shallow node
 /// </summary>
 /// <param name="sn">Shallow node object</param>
 public BrowserShallowNode(ShallowNode sn)
 {
     this.name = sn.Name;
     this.id   = sn.ID;
     this.type = sn.Type;
     this.cid  = sn.CollectionID;
 }
Esempio n. 4
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="Context">http context object</param>
 /// <param name="CurrentStore">store object</param>
 /// <param name="SN">shallow node of the collection</param>
 public Channel(HttpContext Context, Store CurrentStore, ShallowNode SN)
 {
     ctx        = Context;
     store      = CurrentStore;
     collection = new Collection(Store.GetStore(), SN);
     types      = new ArrayList();
 }
Esempio n. 5
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="ParentCollection">parent colection for this collection</param>
 /// <param name="SN">shallownode for collection</param>
 public Item(Collection ParentCollection, ShallowNode SN)
 {
     store      = Store.GetStore();
     collection = ParentCollection;
     node       = new Node(collection, SN);
     published  = (DateTime)
                  node.Properties.GetSingleProperty(Simias.RssFeed.Util.LastModified).Value;
 }
Esempio n. 6
0
        /// <summary>
        /// Continues the search for domain members from the current record location.
        /// </summary>
        /// <param name="searchContext">Domain provider specific search context returned by FindFirstDomainMembers method.</param>
        /// <param name="count">Maximum number of member objects to return.</param>
        /// <param name="memberList">Receives an array object that contains the domain Member objects.</param>
        /// <returns>True if there are more domain members. Otherwise false is returned.</returns>
        public bool FindNextDomainMembers(ref string searchContext, int count, out Member[] memberList)
        {
            bool moreEntries = false;

            // Initialize the outputs.
            memberList = null;

            // See if there is a valid search context.
            SearchState searchState = SearchState.GetSearchState(searchContext);

            if (searchState != null)
            {
                // See if entries are to be returned.
                if (count > 0)
                {
                    // Get the domain being searched.
                    Domain domain = store.GetDomain(searchState.DomainID);
                    if (domain != null)
                    {
                        // Allocate a list to hold the member objects.
                        ArrayList     tempList   = new ArrayList(count);
                        ICSEnumerator enumerator = searchState.Enumerator;
                        while ((count > 0) && enumerator.MoveNext())
                        {
                            // The enumeration returns ShallowNode objects.
                            ShallowNode sn = enumerator.Current as ShallowNode;
                            if (sn.Type == NodeTypes.MemberType)
                            {
                                tempList.Add(new Member(domain, sn));
                                --count;
                            }
                        }

                        if (tempList.Count > 0)
                        {
                            memberList = tempList.ToArray(typeof(Member)) as Member[];
                            searchState.CurrentRecord += memberList.Length;
                            searchState.LastCount      = memberList.Length;
                            moreEntries = (count == 0) ? true : false;
                        }
                    }
                }
                else
                {
                    if (searchState.CurrentRecord < searchState.TotalRecords)
                    {
                        moreEntries = true;
                    }
                }
            }

            return(moreEntries);
        }
Esempio n. 7
0
        /// <summary>
        /// Commits the member object on master server, will be called by slave
        /// </summary>
        /// <param name="domainID">domain id</param>
        /// <param name="member">member object to be committed</param>
        /// <param name="sn">shallow node object, but currently unused</param>
        /// <returns>true if success</returns>
        public bool CommitOnMaster(string domainID, Member member, ShallowNode sn)
        {
            Store    store  = Store.GetStore();
            Domain   domain = store.GetDomain(domainID);
            string   userID = store.GetUserIDFromDomainID(domain.ID);
            HostNode mNode  = HostNode.GetMaster(domainID);
            bool     result = false;

            if (mNode == null)
            {
                return(false);
            }
            try
            {
                Node ModifiedNode = member as Node;
                log.Debug("going to call xnode constr and loading its : ");
                XmlDocument xNode = new XmlDocument();
                xNode.LoadXml(ModifiedNode.Properties.ToString());
                log.Debug("modifiednode.prop.string is : " + ModifiedNode.Properties.ToString());

                SimiasConnection smConn = new SimiasConnection(domainID, userID, SimiasConnection.AuthType.PPK, mNode);
                SimiasWebService svc    = new SimiasWebService();
                svc.Url = mNode.PublicUrl;
                smConn.Authenticate();
                smConn.InitializeWebClient(svc, "Simias.asmx");
                log.Debug("going to call svc.commitdomainmember");
                result = svc.CommitDomainMember(domain.ID, xNode);
                log.Debug("returned from web-service call and return is  " + result);
            }
            catch (Exception ex)
            {
                log.Debug("simiasconnection to master failed: " + ex.ToString());
                log.Debug("Could not establish connection to master for user: " + member.UserID);
                result = false;
            }
            return(result);
        }
Esempio n. 8
0
        /// <summary>
        /// Compare File and Directory Shallow Nodes
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <returns></returns>
        public int Compare(object x, object y)
        {
            ShallowNode a = (ShallowNode)x;
            ShallowNode b = (ShallowNode)y;

            int result = 0;

            if (a.IsBaseType(NodeTypes.DirNodeType))
            {
                if (b.IsBaseType(NodeTypes.DirNodeType))
                {
                    // a and b are both directories so sort by name
                    result = a.Name.CompareTo(b.Name);
                }
                else
                {
                    // a is a directy and b is a file, so a less than b
                    result = -1;
                }
            }
            else
            {
                if (b.IsBaseType(NodeTypes.DirNodeType))
                {
                    // a is a file and b is a directory, so b greater than a
                    result = 1;
                }
                else
                {
                    // a and b are both files so sort by name
                    result = a.Name.CompareTo(b.Name);
                }
            }

            return(result);
        }
Esempio n. 9
0
 /// <summary>
 /// Constructor to create a POBox object from a ShallowNode object.
 /// </summary>
 /// <param name="storeObject">The Store object that this POBox belongs to.</param>
 /// <param name="shallowNode">The ShallowNode object to contruct the POBox object from.</param>
 internal POBox(Store storeObject, ShallowNode shallowNode) :
     base(storeObject, shallowNode)
 {
 }
Esempio n. 10
0
        /// <summary>
        /// write the response back
        /// </summary>
        public void Send()
        {
            ctx.Response.Write("<channel>");

            ctx.Response.Write("<title>");
            ctx.Response.Write(collection.Name);
            ctx.Response.Write("</title>");

            /*
             * if (slog.Link != "")
             * {
             *      ctx.Response.Write("<link>");
             *      ctx.Response.Write( slog.Link );
             *      ctx.Response.Write("</link>");
             * }
             */

            ctx.Response.Write("<language>");
            ctx.Response.Write("en-us");
            ctx.Response.Write("</language>");

            ctx.Response.Write("<copyright>");
            ctx.Response.Write("(c) Novell, Inc.");
            ctx.Response.Write("</copyright>");

            ctx.Response.Write("<managingEditor>");
            Domain domain = store.GetDomain(store.DefaultDomain);

            if (collection.Owner.FN != null && collection.Owner.FN != "")
            {
                ctx.Response.Write(collection.Owner.FN);
            }
            else
            {
                ctx.Response.Write(collection.Owner.Name);
            }
            ctx.Response.Write("</managingEditor>");

            ctx.Response.Write("<webmaster>");
            //member = domain.GetMemberByID( domain.Owner );
            if (domain.Owner.FN != null && domain.Owner.FN != "")
            {
                ctx.Response.Write(domain.Owner.FN);
            }
            else
            {
                ctx.Response.Write(domain.Owner.Name);
            }
            ctx.Response.Write("</webmaster>");

            try
            {
                Simias.Storage.Property descProp =
                    collection.Properties.GetSingleProperty("Description");
                if (descProp != null)
                {
                    ctx.Response.Write("<description>" + descProp.Value.ToString() + "</description>");
                }
                else
                {
                    ctx.Response.Write("<description>" + collection.Type.ToString() + "</description>");
                }
            }
            catch {}

            ctx.Response.Write(
                String.Format(
                    "<link>{0}{1}:{2}{3}{4}?feed={5}</link>",
                    ctx.Request.IsSecureConnection ? "https://" : "http://",
                    ctx.Request.Url.Host,
                    ctx.Request.Url.Port.ToString(),
                    ctx.Request.ApplicationPath,
                    (publicAccess == true) ? "/pubrss.ashx" : "/rss.ashx",
                    HttpUtility.UrlEncode(collection.Name)));

            Simias.Storage.Property colProp =
                collection.Properties.GetSingleProperty(Simias.RssFeed.Util.LastModified);
            DateTime latest = (colProp != null) ? (DateTime)colProp.Value : collection.CreationTime;


            /*
             * ICSList nodes = collection.Search( Simias.RssFeed.Util.LastModified, dt, SearchOp.Greater );
             * ICSEnumerator nodesEnum = null;
             * if ( nodes.Count > 0 )
             * {
             *      nodesEnum = nodes.GetEnumerator() as ICSEnumerator;
             *      if ( nodesEnum != null &&
             *                      nodesEnum.SetCursor( IndexOrigin.SET, nodesEnum.Count - 1 ) == true )
             *      {
             *              nodesEnum.MoveNext();
             *
             *              try
             *              {
             *                      ShallowNode sn = nodesEnum.Current as ShallowNode;
             *                      log.Debug( "sn: " + sn.Name );
             *
             *                      Item item = new Item( collection, sn );
             *                      if ( item.Published > latest )
             *                      {
             *                              latest = item.Published;
             *                      }
             *              }
             *              catch( Exception e )
             *              {
             *                      log.Debug( e.Message );
             *              }
             *      }
             * }
             */

            Simias.RssFeed.Util.SendPublishDate(ctx, latest);

            ctx.Response.Write("<lastBuildDate>");
            ctx.Response.Write(Util.GetRfc822Date(latest));
            ctx.Response.Write("</lastBuildDate>");

            ctx.Response.Write("<generator>");
            ctx.Response.Write("Simias");
            ctx.Response.Write("</generator>");

            /*
             *      ctx.Response.Write("<cloud>");
             *      ctx.Response.Write( node.Cloud );
             *      ctx.Response.Write("</cloud>");
             */

            ctx.Response.Write("<ttl>");
            ctx.Response.Write(Simias.RssFeed.Util.DefaultTtl.ToString());
            ctx.Response.Write("</ttl>");

            ctx.Response.Write("<rating>");
            ctx.Response.Write(Simias.RssFeed.Util.DefaultRating);
            ctx.Response.Write("</rating>");

            if (strict == false)
            {
                ctx.Response.Write("<authorID>" + collection.Owner.UserID + "</authorID>");
                ctx.Response.Write("<type>" + collection.Type.ToString() + "</type>");
                ctx.Response.Write("<id>" + collection.ID + "</id>");
            }

            if (items == true)
            {
                ICSList nodes =
                    collection.Search(
                        Simias.RssFeed.Util.LastModified,
                        new DateTime(1992, 1, 1, 0, 0, 0),
                        SearchOp.Greater);
                if (nodes != null && nodes.Count > 0)
                {
                    ICSEnumerator nodesEnum = nodes.GetEnumerator() as ICSEnumerator;
                    int           count     = nodesEnum.Count;
                    while (count-- > 0)
                    {
                        if (nodesEnum.SetCursor(IndexOrigin.SET, count) == true)
                        {
                            nodesEnum.MoveNext();
                            ShallowNode sn   = nodesEnum.Current as ShallowNode;
                            Item        item = null;
                            if (this.types.Count == 0)
                            {
                                if (sn.Type == "FileNode")
                                {
                                    item = new Item(collection, sn, publicAccess);
                                }
                            }
                            else
                            {
                                foreach (string ctype in this.types)
                                {
                                    if (ctype == sn.Type)
                                    {
                                        item = new Item(collection, sn, publicAccess);
                                        break;
                                    }
                                }
                            }

                            if (item != null)
                            {
                                item.Strict     = this.strict;
                                item.Enclosures = this.enclosures;
                                item.Send(ctx);
                            }
                        }
                    }
                }
            }

            ctx.Response.Write("</channel>");
        }
Esempio n. 11
0
 /// <summary>
 /// Constructor for creating a existing Message object.
 /// </summary>
 /// <param name="collection">Collection that the ShallowNode belongs to.</param>
 /// <param name="shallowNode">ShallowNode object to create the Message object from.</param>
 public Message(Collection collection, ShallowNode shallowNode) :
     base(collection, shallowNode)
 {
 }
Esempio n. 12
0
 /// <summary>
 /// Constructor for creating an existing Subscription object.
 /// </summary>
 /// <param name="collection">Collection that the ShallowNode belongs to.</param>
 /// <param name="shallowNode">ShallowNode object to create the Subscription object from.</param>
 public Subscription(Collection collection, ShallowNode shallowNode) :
     base(collection, shallowNode)
 {
 }
Esempio n. 13
0
 public SlogEntry(Slog slog, ShallowNode sNode)
     : base(slog, sNode)
 {
 }
Esempio n. 14
0
 /// <summary>
 /// Constructs a SyncNodeInfo from a ShallowNode.
 /// </summary>
 /// <param name="collection"></param>
 /// <param name="sn"></param>
 public SyncNodeInfo(Collection collection, ShallowNode sn) :
     this(new Node(collection, sn))
 {
 }
Esempio n. 15
0
        /// <summary>
        /// Extracts all the member policies from POBox and stores them as part of member object on master . No aggregation is done.
        /// </summary>
        public void ExtractMemberPolicies(string domainID, Member member, ShallowNode sn, bool OnMaster)
        {
            Store  store    = Store.GetStore();
            Domain domain   = store.GetDomain(domainID);
            string RuleList = "RuleList";

            Simias.Policy.Rule rule = null;
            int      Value          = -1;
            bool     committed      = false;
            Property FileTypeProperty;
            Property EncProperty;
            Property SyncIntervalProperty;
            ICSList  list;

            POBox.POBox poBox = POBox.POBox.FindPOBox(store, domainID, member.UserID);
            if (poBox == null)
            {
                return;
            }

            // First extract rule based policies

            // Extracting FileType policy
            list = poBox.Search(PropertyTags.PolicyID, Simias.Policy.FileTypeFilter.FileTypeFilterPolicyID, SearchOp.Equal);
            Simias.Policy.Policy tempPolicy = null;
            foreach (ShallowNode snl in list)
            {
                tempPolicy = new Simias.Policy.Policy(poBox, snl);
                if (tempPolicy.IsSystemPolicy)
                {
                    MultiValuedList mvl = tempPolicy.Properties.GetProperties(RuleList);
                    if (mvl.Count > 0)
                    {
                        log.Debug("mvl count for filetype filter is" + mvl.Count);
                        foreach (Property p in mvl)
                        {
                            if (p != null)
                            {
                                rule             = new Simias.Policy.Rule(p.Value);
                                FileTypeProperty = new Property(Simias.Policy.FileTypeFilter.FileTypeFilterPolicyID, rule.ToString());
                                FileTypeProperty.ServerOnlyProperty = true;
                                member.Properties.AddNodeProperty(FileTypeProperty);
                            }
                        }
                    }
                }
            }
            GetRuleForPolicyID(poBox, Simias.Policy.DiskSpaceQuota.DiskSpaceQuotaPolicyID, ref member);
            GetRuleForPolicyID(poBox, Simias.Policy.FileSizeFilter.FileSizeFilterPolicyID, ref member);
            Value = GetValueForPolicyID(poBox, Simias.Policy.SecurityState.EncryptionStatePolicyID, Simias.Policy.SecurityState.StatusTag);
            if (Value != -1)
            {
                EncProperty = new Property(Simias.Policy.SecurityState.EncryptionStatePolicyID, Value);
                EncProperty.ServerOnlyProperty = true;
                member.Properties.ModifyProperty(EncProperty);
            }
            Value = GetValueForPolicyID(poBox, Simias.Policy.SyncInterval.SyncIntervalPolicyID, Simias.Policy.SyncInterval.IntervalTag);
            if (Value != -1)
            {
                SyncIntervalProperty = new Property(Simias.Policy.SyncInterval.SyncIntervalPolicyID, Value);
                SyncIntervalProperty.ServerOnlyProperty = true;
                member.Properties.ModifyProperty(SyncIntervalProperty);
            }

            if (OnMaster)
            {
                // User is provisioned on master so no need to call web-service
                domain.Commit(member);
                poBox.Commit(poBox.Delete());
                log.Debug("Committed member's property(policy) on master successfully so deleting his POBox.. " + member.FN);
            }
            else
            {
                committed = CommitOnMaster(domainID, member, sn);
                if (committed == true)
                {
                    log.Debug("Committed member's property(policy) on master successfully so deleting his POBox.. " + member.FN);
                    poBox.Commit(poBox.Delete());
                }
                else
                {
                    log.Debug("Could not commit member's property(policy) on master so not deleting his POBox.. Next time it can be tried");
                }
            }
        }