Exemple #1
0
        /// <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);
        }
Exemple #2
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);
        }
Exemple #3
0
        public virtual UserPolicy GetAuthenticatedUserPolicy()
        {
            UserPolicy result = null;

            try
            {
                string accessID = GetAccessID();

                result = UserPolicy.GetPolicy(accessID);
            }
            catch (Exception e)
            {
                SmartException.Throw(e);
            }

            return(result);
        }
Exemple #4
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);
        }
Exemple #5
0
        /// <summary>
        /// Get the user groups Encryption  policy.
        /// </summary>
        /// <param name="userID">The User ID</param>
        /// <returns> Returns the user groups Encryption policy value </returns>
        public static int GetUserGroupEncryptionPolicy(string userID)
        {
            int        groupEncryption = 0;
            UserPolicy userPolicy      = null;

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

            string[] GIDs = domain.GetMemberFamilyList(userID);
            foreach (string gid in GIDs)
            {
                if (gid != userID)
                {
                    userPolicy      = UserPolicy.GetPolicy(gid);
                    groupEncryption = userPolicy.EncryptionStatus;
                    if (groupEncryption != 0)
                    {
                        break;
                    }
                }
            }
            return(groupEncryption);
        }
Exemple #6
0
        /// <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));
            }
        }
Exemple #7
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);
        }