예제 #1
0
        /// <summary>
        /// Get the iFolder System Policy
        /// </summary>
        /// <returns>An SystemPolicy Object</returns>
        public static SystemPolicy GetPolicy()
        {
            SystemPolicy props = new SystemPolicy();

            Store store = Store.GetStore();

            string domain = store.DefaultDomain;

            // space limit
            props.SpaceLimitUser = DiskSpaceQuota.GetLimit(domain);

            //ifolder limit
            props.NoiFoldersLimit = iFolderLimit.GetLimit(domain);

            // sync internval
            props.SyncInterval = Simias.Policy.SyncInterval.GetInterval(domain);

            // file size
            props.FileSizeLimit = FileSizeFilter.GetLimit(domain);

            props.EncryptionStatus = Simias.Policy.SecurityState.GetStatus(domain);

            // Disable sharing policy
            props.SharingStatus = Simias.Policy.Sharing.GetStatus(domain);

            // file types
            SystemPolicy.SplitFileTypes(FileTypeFilter.GetPatterns(domain),
                                        out props.FileTypesIncludes, out props.FileTypesExcludes);

            return(props);
        }
예제 #2
0
파일: UserPolicy.cs 프로젝트: lulzzz/simias
        /// <summary>
        /// Get the User Policy
        /// </summary>
        /// <param name="userID">The User ID</param>
        /// <returns>The UserPolicy Object</returns>
        public static UserPolicy GetPolicy(string userID, string AdminId)
        {
            UserPolicy props = new UserPolicy();

            props.UserID = userID;

            Store store = Store.GetStore();

            Domain domain = store.GetDomain(store.DefaultDomain);

            Member member = domain.GetMemberByID(userID);

            if (member == null)
            {
                throw new UserDoesNotExistException(userID);
            }

            Access.Rights rights = (member != null) ? member.Rights : Access.Rights.Deny;

            props.isAdmin = (rights == Access.Rights.Admin);

            props.LoginEnabled = !(domain.GetLoginpolicy(userID));

            // disk space
            DiskSpaceQuota quota = DiskSpaceQuota.Get(member);

            props.SpaceLimitEffective = quota.Limit;
            //props.SpaceUsed = quota.UsedSpace;
            props.SpaceUsed = Simias.Server.Catalog.GetUsedSpaceOfUserID(userID);
            //props.SpaceAvailable = quota.AvailableSpace;

            props.SpaceLimit       = DiskSpaceQuota.GetLimit(member);
            props.SpaceAvailable   = props.SpaceLimitEffective - props.SpaceUsed;
            props.EncryptionStatus = Simias.Policy.SecurityState.GetStatus(member);

            // To return disable sharing value for an user
            props.SharingStatus = Simias.Policy.Sharing.GetStatus(member);

            // file size
            props.FileSizeLimit          = FileSizeFilter.GetLimit(member);
            props.FileSizeLimitEffective = FileSizeFilter.Get(member).Limit;

            //No of ifolders limit
            props.NoiFoldersLimit = iFolderLimit.Get(member).Limit;

            // sync interval
            props.SyncInterval          = Simias.Policy.SyncInterval.GetInterval(member);
            props.SyncIntervalEffective = Simias.Policy.SyncInterval.Get(member).Interval;

            // file types
            SystemPolicy.SplitFileTypes(FileTypeFilter.GetPatterns(member),
                                        out props.FileTypesIncludes, out props.FileTypesExcludes);

            // file types effective
            SystemPolicy.SplitFileTypes(FileTypeFilter.Get(member, false).FilterUserList,
                                        out props.FileTypesIncludesEffective, out props.FileTypesExcludesEffective);
            props.AdminGroupRights = iFolderUser.GetAdminRights(AdminId, userID);
            return(props);
        }
예제 #3
0
        public virtual int GetiFolderLimitPolicyStatus(string userID)
        {
            long         userpolicy = 0, syspolicy = 0;
            UserPolicy   user     = null;
            SystemPolicy system   = null;
            string       accessID = null;

            if (userID == null)
            {
                accessID = GetAccessID();                 //new iFolder
            }
            else
            {
                accessID = userID;                 // transfer of ownership
            }
            int result = 1;

            try
            {
                iFolderUserDetails userdetails = iFolderUserDetails.GetDetails(accessID);
                user       = UserPolicy.GetPolicy(accessID);
                system     = SystemPolicy.GetPolicy();
                userpolicy = user.NoiFoldersLimit;
                syspolicy  = system.NoiFoldersLimit;

                if (userpolicy != -1 && userpolicy != -2)
                {
                    if (userpolicy <= userdetails.OwnediFolderCount)
                    {
                        result = 0;
                    }
                }
                else
                {
                    if (Simias.Service.Manager.LdapServiceEnabled == true)
                    {
                        int groupStatus = UserPolicy.GetUserGroupiFolderLimitPolicy(accessID, userdetails.OwnediFolderCount);
                        if (groupStatus == 0)
                        {
                            return(result);
                        }
                        else if (groupStatus == -1)
                        {
                            result = 0;
                        }
                    }
                    if (syspolicy <= userdetails.OwnediFolderCount && syspolicy != -1)
                    {
                        result = 0;
                    }
                }
                return(result);
            }
            catch (Exception e)
            {
                SmartException.Throw(e);
            }
            return(result);
        }
예제 #4
0
        /// <summary>
        /// Get the iFolder Policy
        /// </summary>
        /// <param name="ifolderID">The iFolder ID</param>
        /// <param name="accessID">The Access User ID</param>
        /// <param name="adminID">The logged in Admin ID</param>
        /// <returns>An iFolderPolicy Object</returns>
        public static iFolderPolicy GetPolicy(string ifolderID, string accessID, string adminID)
        {
            iFolderPolicy props = new iFolderPolicy();

            props.iFolderID = ifolderID;

            Store store = Store.GetStore();

            Collection c = store.GetCollectionByID(ifolderID);

            if (c == null)
            {
                throw new iFolderDoesNotExistException(ifolderID);
            }

            // impersonate
            iFolder.Impersonate(c, accessID);

            // disk space
            DiskSpaceQuota dsq = DiskSpaceQuota.Get(c);

            props.SpaceLimitEffective = dsq.Limit;
            props.SpaceAvailable      = dsq.AvailableSpace;
            props.SpaceUsed           = c.StorageSize;
            props.SpaceLimit          = DiskSpaceQuota.GetLimit(c);

            // no syncing (locked)
            //props.Locked = IsLocked(c);
            props.Locked = c.Disabled;

            // sync interval
            props.SyncInterval          = Simias.Policy.SyncInterval.GetInterval(c);
            props.SyncIntervalEffective = Simias.Policy.SyncInterval.Get(c).Interval;

            // to return the value of disable sharing policy for an iFolder
            props.SharingStatus = Simias.Policy.Sharing.GetStatus(c);

            // file types
            SystemPolicy.SplitFileTypes(FileTypeFilter.GetPatterns(c),
                                        out props.FileTypesIncludes, out props.FileTypesExcludes);

            SystemPolicy.SplitFileTypes(FileTypeFilter.Get(c, false).FilterList,
                                        out props.FileTypesIncludesEffective, out props.FileTypesExcludesEffective);

            // file size
            props.FileSizeLimit          = Simias.Policy.FileSizeFilter.GetLimit(c);
            props.FileSizeLimitEffective = Simias.Policy.FileSizeFilter.Get(c).Limit;
            props.AdminGroupRights       = iFolderUser.GetAdminRights(adminID, c.Owner.UserID);
            return(props);
        }
예제 #5
0
        /// <summary>
        /// Set the iFolder System Policy
        /// </summary>
        /// <param name="props">The SystemPolicy Object</param>
        public static void SetPolicy(SystemPolicy props)
        {
            Store store = Store.GetStore();

            string domain = store.DefaultDomain;

            // space limit
            if (props.SpaceLimitUser >= -1)
            {
                DiskSpaceQuota.Set(domain, props.SpaceLimitUser);
            }

            // ifolder limit
            iFolderLimit.Set(domain, props.NoiFoldersLimit);

            // sync interval
            if (props.SyncInterval >= 0)
            {
                Simias.Policy.SyncInterval.Set(domain, props.SyncInterval);
            }
            // Added by Ramesh
            //Encryption Status
            Simias.Policy.SecurityState.Create(domain, props.EncryptionStatus);

            // Setting the enumerator value for disabling sharing
            Simias.Policy.Sharing.Create(domain, props.SharingStatus);

            // file size
            if (props.FileSizeLimit >= 0)
            {
                FileSizeFilter.Set(domain, props.FileSizeLimit);
            }

            // file types
            if ((props.FileTypesExcludes != null) || (props.FileTypesIncludes != null))
            {
                FileTypeFilter.Set(domain, SystemPolicy.CombineFileTypes(
                                       props.FileTypesIncludes, props.FileTypesExcludes));
            }
        }
예제 #6
0
        public virtual int GetEncryptionPolicy()
        {
            UserPolicy   user = null;
            SystemPolicy system = null;
            int          SysEncrPolicy = 0, UserEncrPolicy = 0, securityStatus = 0;

            try
            {
                string accessID = GetAccessID();
                user           = UserPolicy.GetPolicy(accessID);
                system         = SystemPolicy.GetPolicy();
                UserEncrPolicy = user.EncryptionStatus;
                SysEncrPolicy  = system.EncryptionStatus;
                int GroupEncrPolicy = UserPolicy.GetUserGroupEncryptionPolicy(accessID);
                securityStatus += DeriveStatus(SysEncrPolicy, GroupEncrPolicy, UserEncrPolicy, UserEncrPolicy);
            }
            catch (Exception e)
            {
                SmartException.Throw(e);
            }
            return(securityStatus);
        }
예제 #7
0
파일: UserPolicy.cs 프로젝트: lulzzz/simias
        /// <summary>
        /// Set the User Policy
        /// </summary>
        /// <param name="props">The UserPolicy Object</param>
        public static void SetPolicy(UserPolicy props)
        {
            Store store = Store.GetStore();

            Domain domain = store.GetDomain(store.DefaultDomain);

            Member member = domain.GetMemberByID(props.UserID);

            if (member == null)
            {
                throw new UserDoesNotExistException(props.UserID);
            }

            if (props.LoginEnabled == true)
            {
                domain.SetLoginDisabled(props.UserID, false);
            }
            else
            {
                domain.SetLoginDisabled(props.UserID, true);
            }


// Added by Ramesh
            if (props.EncryptionStatus >= 0)
            {
                Simias.Policy.SecurityState.Create(member, props.EncryptionStatus);
            }

            // to set disable sharing policy value for an user
            if (props.SharingStatus >= 0)
            {
                Simias.Policy.Sharing.Create(member, props.SharingStatus);
            }

            // disk space
            if (props.SpaceLimit >= -1)
            {
                DiskSpaceQuota.Set(member, props.SpaceLimit);
            }


            //limiting no of ifolder per user policy.
            if (props.NoiFoldersLimit >= -2)
            {
                iFolderLimit.Set(member, props.NoiFoldersLimit);
            }


            // file size
            if (props.FileSizeLimit >= 0)
            {
                FileSizeFilter.Set(member, props.FileSizeLimit);
            }

            // sync interval
            if (props.SyncInterval >= 0)
            {
                Simias.Policy.SyncInterval.Set(member, props.SyncInterval);
            }

            // file types
            if ((props.FileTypesExcludes != null) || (props.FileTypesIncludes != null))
            {
                FileTypeFilter.Set(member, SystemPolicy.CombineFileTypes(
                                       props.FileTypesIncludes, props.FileTypesExcludes));
            }
        }
예제 #8
0
        public virtual bool GetSharingPolicy(string iFolderID)
        {
            //return base.GetDisableSharingPolicy ( iFolderID );
            iFolder       ifolder              = base.GetiFolder(iFolderID);
            UserPolicy    userPolicy           = UserPolicy.GetPolicy(ifolder.OwnerID);
            SystemPolicy  systemPolicy         = SystemPolicy.GetPolicy();
            iFolderPolicy ifolderPolicy        = iFolderPolicy.GetPolicy(iFolderID, GetAccessID());
            int           iFolderSharingStatus = ifolderPolicy.SharingStatus;
            int           UserSharingStatus    = userPolicy.SharingStatus;
            int           GroupSharingStatus   = UserPolicy.GetUserGroupSharingPolicy(ifolder.OwnerID);
            int           SystemSharingStatus  = systemPolicy.SharingStatus;

            if (((SystemSharingStatus & (int)Share.EnforcedSharing) == (int)Share.EnforcedSharing))
            {
                /// If on system level or user level, enforcement of policy is there, it means the iFolder must not be shared
                if ((SystemSharingStatus & (int)Share.Sharing) == (int)Share.Sharing)
                {
                    return(true);
                }
                return(false);
            }
            else if (((GroupSharingStatus & (int)Share.EnforcedSharing) == (int)Share.EnforcedSharing))
            {
                if ((GroupSharingStatus & (int)Share.Sharing) == (int)Share.Sharing)
                {
                    return(true);
                }
                return(false);
            }
            else if (((UserSharingStatus & (int)Share.EnforcedSharing) == (int)Share.EnforcedSharing))
            {
                if ((UserSharingStatus & (int)Share.Sharing) == (int)Share.Sharing)
                {
                    return(true);
                }
                return(false);
            }
            else
            {
                if (iFolderSharingStatus != 0)
                {
                    if ((iFolderSharingStatus & (int)Share.Sharing) == (int)Share.Sharing || iFolderSharingStatus == 0)
                    {
                        /// it means, on iFolder Details page, admin had unchecked the box so sharing is enabled now
                        return(true);
                    }
                    if ((iFolderSharingStatus & (int)Share.DisableSharing) == (int)Share.DisableSharing)
                    {
                        /// it means, on iFolder Details page, admin had checked the box so sharing is disabled
                        return(false);
                    }
                }
                else
                {
                    /// no iFolder level policy present , now if current user is not an owner , then check for system level policy
                    /// if current user is owner of the iFolder, then check for user level and then for system level

                    if ((UserSharingStatus & (int)Share.Sharing) == (int)Share.Sharing)
                    {
                        /// it means, on User Details page, admin had unchecked the box so sharing is enabled now
                        return(true);
                    }
                    if ((UserSharingStatus & (int)Share.DisableSharing) == (int)Share.DisableSharing)
                    {
                        /// it means, on User Details page, admin had checked the box so sharing is disabled
                        return(false);
                    }

                    /// check for Group level policy as there was no user level or ifolder level policy applied
                    /// No policy found on iFolder level or User level, no enforcement also, so follow group level
                    if ((GroupSharingStatus & (int)Share.DisableSharing) == (int)Share.DisableSharing)
                    {
                        return(false);
                    }
                    if ((GroupSharingStatus & (int)Share.Sharing) == (int)Share.Sharing)
                    {
                        return(true);
                    }

                    /// check for system level policy as there was no user level or ifolder level policy applied
                    /// No policy found on iFolder level or User level, no enforcement also, so follow system level
                    if ((SystemSharingStatus & (int)Share.DisableSharing) == (int)Share.DisableSharing)
                    {
                        return(false);
                    }
                    if ((SystemSharingStatus & (int)Share.Sharing) == (int)Share.Sharing || SystemSharingStatus == 0)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
예제 #9
0
        /// <summary>
        /// Set the iFolder Policy
        /// </summary>
        /// <param name="props">The iFolderPolicy Object</param>
        /// <param name="accessID">The Access User ID</param>
        public static void SetPolicy(iFolderPolicy props, string accessID)
        {
            Store store = Store.GetStore();

            Collection c = store.GetCollectionByID(props.iFolderID);

            if (c == null)
            {
                throw new iFolderDoesNotExistException(props.iFolderID);
            }

            // impersonate
            iFolder.Impersonate(c, accessID);

            // NOTE: always unlock the collection so other policy properties
            // can be modified
            if (c.IsLockedByName(lockName))
            {
                c.Unlock(lockName);
            }

            // disk space
            if (props.SpaceLimit >= -1)
            {
                DiskSpaceQuota.Set(c, props.SpaceLimit);
            }

            // sync interval
            if (props.SyncInterval >= 0)
            {
                Simias.Policy.SyncInterval.Set(c, props.SyncInterval);
            }

            // to set the value for disable sharing policy for this iFolder
            if (props.SharingStatus >= 0)
            {
                Simias.Policy.Sharing.Set(c, props.SharingStatus);
            }

            // file types
            if ((props.FileTypesExcludes != null) || (props.FileTypesIncludes != null))
            {
                FileTypeFilter.Set(c, SystemPolicy.CombineFileTypes(
                                       props.FileTypesIncludes, props.FileTypesExcludes));
            }

            // file size
            if (props.FileSizeLimit >= 0)
            {
                Simias.Policy.FileSizeFilter.Set(c, props.FileSizeLimit);
            }

            // no syncing (locked)
            // NOTE: re-lock the collection (see the beginning of the method)
            // if a lock was requested
            //if (props.Locked)
            {
                //	c.Lock(lockName);
                c.Disabled = props.Locked;
                c.Commit();
            }
        }