Example #1
0
        /// <summary>
        /// Page_Load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ConnectToMaster( )
        {
            iFolderServer[] list = web.GetServers();

            foreach (iFolderServer server in list)
            {
                if (server.IsMaster)
                {
                    UriBuilder remoteurl = new UriBuilder(server.PublicUrl);
                    remoteurl.Path = (new Uri(web.Url)).PathAndQuery;
                    web.Url        = remoteurl.Uri.ToString();
                    break;
                }
            }

            try
            {
                iFolder domain = web.GetiFolder(web.GetSystem().ID);
                SuperAdminID = domain.OwnerID;
            }
            catch (Exception e)
            {
                web.Url = currentServerURL;
                throw new Exception("Unable to connect to master server" + e);
            }
        }
Example #2
0
        /// <summary>
        /// Start the binding of data to the Page.
        /// </summary>
        private void StartBindingData()
        {
            // data
            BindData();
            iFolder ifolder = web.GetiFolder(ifolderID);

            // strings
            EntryPagging.LabelSingular = GetString("ITEM");
            EntryPagging.LabelPlural   = GetString("ITEMS");
            NewFolderLink.Text         = GetString("NEWFOLDER");
            UploadFilesLink.Text       = GetString("UPLOADFILES");
            DeleteButton.Text          = GetString("DELETE");
            DeleteDisabled.Text        = GetString("DELETE");
            FirstSingleStick.Text      = "|";
            SecondSingleStick.Text     = "|";
            DeleteDisabled.Visible     = true;
            EntryPagging.Visible       = true;
            FirstSingleStick.Visible   = true;
            SecondSingleStick.Visible  = true;

            // links
            NewFolderLink.NavigateUrl = String.Format("NewFolder.aspx?iFolder={0}&Entry={1}", ifolderID, entryID);
            //UploadFilesLink.NavigateUrl = String.Format("Upload.aspx?iFolder={0}&Entry={1}", ifolderID, entryID);
            UploadFilesLink.NavigateUrl = String.Format("Upload.aspx?iFolder={0}&Entry={1}&Alg={2}", ifolderID, entryID, ifolder.EncryptionAlgorithm);

            PassPhraseLabel.Visible = PassPhraseText.Visible = OKButton.Visible = CancelButton.Visible = false;
        }
Example #3
0
        /// <summary>
        /// Bind the Data to the Page.
        /// </summary>
        private void BindParentData()
        {
            try
            {
                // ifolder
                iFolder ifolder = web.GetiFolder(ifolderID);

                // rights
                Actions.Visible = (ifolder.MemberRights != Rights.ReadOnly);
                EntryData.Columns[1].Visible = Actions.Visible;

                // parent
                iFolderEntry entry;

                if ((entryID == null) || (entryID.Length == 0))
                {
                    entry   = web.GetEntries(ifolderID, ifolderID, 0, 1).Items[0];
                    entryID = entry.ID;
                }
                else
                {
                    entry = web.GetEntry(ifolderID, entryID);
                }
            }
            catch (SoapException ex)
            {
                if (!HandleException(ex))
                {
                    throw;
                }
            }

            // state
            ViewState["EntryID"] = entryID;
        }
Example #4
0
        /// <summary>
        /// Page load event.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Page_Load(object sender, System.EventArgs e)
        {
            // connection
            web = Session["Connection"] as iFolderAdmin;

            // localization
            rm = Application["RM"] as ResourceManager;
            //string userID = Session[ "UserID" ] as String;

            if (!IsPostBack)
            {
                // Initialize the localized fields.
                DisableButton.Text   = GetString("DISABLE");
                EnableButton.Text    = GetString("ENABLE");
                ProvisionButton.Text = GetString("PROVISION");
                SaveButton.Text      = GetString("SAVE");

                // Initialize state variables.
                CurrentUserOffset        = 0;
                TotalUsers               = 0;
                AllUsersCheckBox.Checked = false;
                CheckedUsers             = new Hashtable();
                ServerProvisioningNames  = new Hashtable();

                IdentityPolicy policy = web.GetIdentityPolicy();
                if (policy.CanCreate)
                {
                    CreateButton.Text    = GetString("CREATE");
                    CreateButton.Visible = true;
                }

                if (policy.CanDelete)
                {
                    DeleteButton.Text    = GetString("DELETE");
                    DeleteButton.Visible = true;
                }

                // Get the owner of the system.
                iFolder domain = web.GetiFolder(web.GetSystem().ID);
                SuperAdminID = domain.OwnerID;
            }

            // In ru/pl/hu as the PROVISION string is too long , increase the width for this language.
            string code = Thread.CurrentThread.CurrentUICulture.Name;

            if (code.StartsWith("ru") || code.StartsWith("hu"))
            {
                ProvisionButton.Width = 250;
            }
            else if (code.StartsWith("pl"))
            {
                ProvisionButton.Width = 180;
            }
            else if (code.StartsWith("pt") || code.StartsWith("de"))
            {
                DisableButton.Width = 120;
            }
        }
Example #5
0
        /// <summary>
        /// Determine to show the search tab or not for encrypted folders
        /// </summary>
        private bool IfSearchEnabled()
        {
            string PassPhrase = Session["SessionPassPhrase"] as string;

            ifolderID = Request.QueryString.Get("iFolder");
            iFolder ifolder             = web.GetiFolder(ifolderID);
            string  EncryptionAlgorithm = ifolder.EncryptionAlgorithm;

            return(web.ShowTabDetails(PassPhrase, EncryptionAlgorithm));
        }
Example #6
0
        /// <summary>
        /// before loading the page, see if the ifolder was encrypted and show the page accordingly
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CheckForThePassPhrase()
        {
            string PassPhrase = Session["SessionPassPhrase"] as string;

            ifolderID = Request.QueryString.Get("iFolder");
            iFolder ifolder             = web.GetiFolder(ifolderID);
            string  EncryptionAlgorithm = ifolder.EncryptionAlgorithm;

            if (EncryptionAlgorithm == null || (EncryptionAlgorithm == String.Empty))
            {
                // It is not an encrypted ifolder , just return and display normal page

                PassPhraseLabel.Visible = PassPhraseText.Visible = OKButton.Visible = CancelButton.Visible = false;
                if (!IsPostBack)
                {
                    StartBindingData();
                }
            }
            else
            {
                if (PassPhrase != null)
                {
                    // User is in current session and has already given the passphrase, use this and display normal page
                    // Validate the passphrase...
                    Status ObjValidate = web.ValidatePassPhrase(PassPhrase);
                    if (ObjValidate.statusCode != StatusCodes.Success)
                    {
                        PassPhrase = null;
                        Session["SessionPassPhrase"] = null;
                    }
                }

                //Passphrase will become null if incorrect
                if (PassPhrase != null)
                {
                    PassPhraseLabel.Visible = PassPhraseText.Visible = OKButton.Visible = CancelButton.Visible = false;
                    if (!IsPostBack)
                    {
                        StartBindingData();
                    }
                }
                else
                {
                    PassPhraseLabel.Visible   = PassPhraseText.Visible = OKButton.Visible = CancelButton.Visible = true;
                    PassPhraseLabel.Text      = GetString("ENTERPASSPHRASE");
                    OKButton.Text             = GetString("OK");
                    CancelButton.Text         = GetString("CANCEL");
                    DeleteDisabled.Visible    = false;
                    EntryPagging.Visible      = false;
                    FirstSingleStick.Visible  = false;
                    SecondSingleStick.Visible = false;
                }
            }
        }
Example #7
0
        /// <summary>
        /// Page Load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Page_Load(object sender, EventArgs e)
        {
            // query
            ifolderID = Request.QueryString.Get("iFolder");
            entryID   = Request.QueryString.Get("Entry");
            rm        = (ResourceManager)Application["RM"];
            // connection
            web = (iFolderWeb)Session["Connection"];
            iFolder ifolder = null;

            try
            {
                ifolder = web.GetiFolder(ifolderID);
            }
            catch (Exception)
            {
                Response.Redirect("iFolders.aspx?ErrorMsg=Member does not exist " + ifolderID);
            }
            if (ifolder == null)
            {
                Response.Redirect("iFolders.aspx?ErrorMsg=iFolder does not exist " + ifolderID);
            }

            // localization

            if (!IsPostBack)
            {
                EntryData.Columns[3].HeaderText = GetString("NAME");
                EntryData.Columns[4].HeaderText = GetString("DATE");
                EntryData.Columns[5].HeaderText = GetString("SIZE");
                EntryData.Columns[6].HeaderText = GetString("HISTORY");

                // Pass this page information to create the help link
                Head.AddHelpLink(GetString("BROWSE"));

                string EncryptionAlgorithm = ifolder.EncryptionAlgorithm;
                if (!(EncryptionAlgorithm == null || (EncryptionAlgorithm == String.Empty)))
                {
                    // It is an encrypted ifolder , Make the Members tab invisible
                    Tabs.MakeMembersLinkInvisible();
                }

                // this function will check whether an ifolder is encrypted or not, if yes, it will ask for passphrase
                // if passphrase matches , then the real page will be loaded.
                CheckForThePassPhrase();
            }
            else
            {
                entryID   = (string)ViewState["EntryID"];
                entryPath = (string)ViewState["EntryPath"];
                CheckForThePassPhrase();
            }
        }
Example #8
0
        /// <summary>
        /// Delete Button Click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RemoveMemberDeleteButton_Click(object sender, EventArgs e)
        {
            iFolder ifolder = null;

            // selected members
            try
            {
                foreach (DataGridItem item in iFolderData.Items)
                {
                    CheckBox checkBox = (CheckBox)item.FindControl("Select");

                    if (checkBox.Checked)
                    {
                        string id = item.Cells[0].Text;
                        ifolder = web.GetiFolder(id);

                        if (!ifolder.IsOwner)
                        {
                            string     ifolderLocation = web.GetiFolderLocation(id);
                            string     CurrentURL      = web.Url;
                            UriBuilder remoteurl       = new UriBuilder(ifolderLocation);
                            remoteurl.Path = (new Uri(web.Url)).PathAndQuery;
                            web.Url        = remoteurl.Uri.ToString();
                            web.RemoveMembership(id);
                            web.Url = CurrentURL;
                        }
                        else
                        {
                            web.DeleteiFolder(id);
                        }
                    }
                }
            }

            catch (SoapException ex)
            {
                if (ex.Message.IndexOf("readonly rights") != -1)
                {
                    Message.Text = GetString("GROUPACCESSEXCEPTION");
                    return;
                }

                if (!HandleException(ex))
                {
                    throw;
                }
            }

            Response.Redirect("iFolders.aspx");
        }
Example #9
0
        /// <summary>
        /// Bind the Data to the Page.
        /// </summary>
        private void BindParentData()
        {
            try
            {
                // ifolder
                string ifolderLocation = web.GetiFolderLocation(ifolderID);
                if (ifolderLocation == null)
                {
                    //if we are not able to get the ifolder location for a particular ifolder we show the iFolder page instead of an error
                    // we fail to get the location, due to catalog update delay
                    Response.Redirect("iFolders.aspx");
                }

                UriBuilder remoteurl = new UriBuilder(ifolderLocation);
                remoteurl.Path = (new Uri(web.Url)).PathAndQuery;
                web.Url        = remoteurl.Uri.ToString();

                iFolder ifolder = web.GetiFolder(ifolderID);

                // rights
                Actions.Visible = (ifolder.MemberRights != Rights.ReadOnly);
                EntryData.Columns[1].Visible = Actions.Visible;

                // parent
                iFolderEntry entry;

                if ((entryID == null) || (entryID.Length == 0))
                {
                    entry   = web.GetEntries(ifolderID, ifolderID, 0, 1).Items[0];
                    entryID = entry.ID;
                }
                else
                {
                    entry = web.GetEntry(ifolderID, entryID);
                }

                entryPath = entry.Path;
            }
            catch (SoapException ex)
            {
                if (!HandleException(ex))
                {
                    throw;
                }
            }

            // state
            ViewState["EntryID"]   = entryID;
            ViewState["EntryPath"] = entryPath;
        }
Example #10
0
        /// <summary>
        /// Bind the Data to the Page.
        /// </summary>
        private void BindData()
        {
            try
            {
                iFolder ifolder = web.GetiFolder(ifolderID);

                Remove.Visible = !ifolder.IsOwner;
                Delete.Visible = ifolder.IsOwner;
            }
            catch (SoapException ex)
            {
                if (!HandleException(ex))
                {
                    throw;
                }
            }
        }
Example #11
0
        public virtual iFolder CreateiFolder(string name, string description, bool ssl, string encryptionAlgorithm, string PassPhrase)
        {
            iFolder result = null;

            try
            {
                Authorize();

                string accessID = GetAccessID();
                result = iFolder.CreateiFolder(name, accessID, description, accessID, ssl, encryptionAlgorithm, PassPhrase);
            }
            catch (Exception e)
            {
                SmartException.Throw(e);
            }

            return(result);
        }
Example #12
0
        /// <summary>
        /// OK Button Click, It will validate the passphrase, and then it will load page.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OKButton_Click(object sender, EventArgs e)
        {
            //string PassPhrase = Session["SessionPassPhrase"] as string;
            ifolderID = Request.QueryString.Get("iFolder");
            iFolder ifolder             = web.GetiFolder(ifolderID);
            string  EncryptionAlgorithm = ifolder.EncryptionAlgorithm;

            if (EncryptionAlgorithm != "")
            {
                string PassPhraseStr = PassPhraseText.Text.Trim();
                if (PassPhraseStr == String.Empty)
                {
                    Message.Text        = GetString("PASSPHRASE_INCORRECT");
                    PassPhraseText.Text = "";
                    return;
                }
                try
                {
                    Status ObjValidate = web.ValidatePassPhrase(PassPhraseStr);
                    if (ObjValidate.statusCode != StatusCodes.Success)
                    {
                        Message.Text        = GetString("PASSPHRASE_INCORRECT");
                        PassPhraseText.Text = "";
                        return;
                    }
                    Session["SessionPassPhrase"] = PassPhraseStr;
                }
                catch (SoapException ex)
                {
                    if (!HandleException(ex))
                    {
                        Message.Text = ex.Message;
                    }
                    return;
                }
                catch (Exception ex)
                {
                    Message.Text = ex.Message;
                    return;
                }
                StartBindingData();
            }
        }
Example #13
0
        /// <summary>
        /// Page Load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Page_Load(object sender, EventArgs e)
        {
            // query
            ifolderID = Request.QueryString.Get("iFolder");

            // connection
            web = (iFolderWeb)Session["Connection"];

            // localization
            rm = (ResourceManager)Application["RM"];

            if (!IsPostBack)
            {
                iFolder ifolder = web.GetiFolder(ifolderID);

                //Load this page only if passphrase was provided for the encrypted iFolder
                if (!IfDetailsEnabled())
                {
                    // Return to Browse page, if passphrase was not provided for that encrypted ifolder.

                    Response.Redirect(String.Format("Browse.aspx?iFolder={0}", ifolderID));
                }

                string EncryptionAlgorithm = ifolder.EncryptionAlgorithm;
                if (!(EncryptionAlgorithm == null || (EncryptionAlgorithm == String.Empty)))
                {
                    // It is an encrypted ifolder , Make the Members tab invisible
                    Tabs.MakeMembersLinkInvisible();
                }

                // data
                BindData();

                // strings
                PropertyEditLink.Text = GetString("EDIT");
                PolicyEditLink.Text   = GetString("EDIT");

                // links
                PropertyEditLink.NavigateUrl = "iFolderEdit.aspx?iFolder=" + ifolderID;
                PolicyEditLink.NavigateUrl   = "iFolderPolicyEdit.aspx?iFolder=" + ifolderID;
            }
        }
Example #14
0
        /// <summary>
        /// Sets the policy for the user.
        /// </summary>
        /// <param name="policy">iFolder policy where the  information will be set.</param>
        public void SetDisableSharingPolicy(iFolderPolicy policy, string PolicyID)
        {
            int          DisableSharingStatus = 0;
            iFolder      ifolder              = web.GetiFolder(PolicyID);
            string       OwnerID              = ifolder.OwnerID;
            SystemPolicy systemPolicy         = web.GetSystemPolicy();
            UserPolicy   userPolicy           = web.GetUserPolicy(OwnerID);
            int          iFolderDisableStatus = policy.DisableSharingStatus;
            int          UserDisableStatus    = userPolicy.DisableSharingStatus;
            int          SystemDisableStatus  = systemPolicy.DisableSharingStatus;

            if (((iFolderDisableStatus & (int)DisableShare.EnableSharing) == (int)DisableShare.EnableSharing) && disableSharingOn.Checked == false)
            {
                /// it means for this iFolder , admin had earlier enabled the sharing on iFolderDetails page, so retain that
                DisableSharingStatus += (int)DisableShare.EnableSharing;                  //8
            }
            else if ((((SystemDisableStatus & (int)DisableShare.DisableSharing) == (int)DisableShare.DisableSharing) || ((UserDisableStatus & (int)DisableShare.DisableSharing) == (int)DisableShare.DisableSharing) || ((iFolderDisableStatus & (int)DisableShare.DisableSharing) == (int)DisableShare.DisableSharing)) && disableSharingOn.Checked == false)
            {
                /// if for this iFolder , disable sharing was "on" (either iFolder, user or system level) , and now admin has unchecked the box , then also store enable sharing -- 8
                DisableSharingStatus += (int)DisableShare.EnableSharing;                  //8
            }
            if (disableSharingOn.Checked && iFolderDisableStatus != 0)
            {
                /// consider the case when no disable of sharing on iFolder level but disable past sharing is applied.
                DisableSharingStatus += (int)DisableShare.DisableSharing;                 //1;
            }
            else if (disableSharingOn.Checked && (UserDisableStatus == 0 || ((UserDisableStatus & (int)DisableShare.EnableSharing) == (int)DisableShare.EnableSharing)))
            {
                /// if on user level, it was enabled and then if on iFolder level it is disabled , then for that case
                DisableSharingStatus += (int)DisableShare.DisableSharing;                 //1;
            }

            policy.DisableSharingStatus = DisableSharingStatus;

            /// Next change is to remove the past sharing ,
            if (disablePastSharing.Checked)
            {
                /// pass the iFolderID
                web.DisableiFolderPastSharing(PolicyID);
                disablePastSharing.Checked = false;
            }
        }
Example #15
0
        /// <summary>
        /// Page Load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Page_Load(object sender, EventArgs e)
        {
            // query
            ifolderID = Request.QueryString.Get("iFolder");
            entryID   = Request.QueryString.Get("Entry");

            // connection
            web = (iFolderWeb)Session["Connection"];

            // localization
            rm = (ResourceManager)Application["RM"];

            if (!IsPostBack)
            {
                if (!IfSearchEnabled())
                {
                    // Don't load this page , if passphrase was not provided for that encrypted ifolder.
                    Response.Redirect(String.Format("Browse.aspx?iFolder={0}&Entry={1}", ifolderID,
                                                    entryID));
                }

                iFolder ifolder             = web.GetiFolder(ifolderID);
                string  EncryptionAlgorithm = ifolder.EncryptionAlgorithm;
                if (!(EncryptionAlgorithm == null || (EncryptionAlgorithm == String.Empty)))
                {
                    // It is an encrypted ifolder , Make the Members tab invisible
                    Tabs.MakeMembersLinkInvisible();
                }

                // data
                BindData();

                // strings
                EntryPagging.LabelSingular = GetString("ITEM");
                EntryPagging.LabelPlural   = GetString("ITEMS");
                DeleteButton.Text          = GetString("DELETE");
            }
            else
            {
                entryID = (string)ViewState["EntryID"];
            }
        }
Example #16
0
        /// <summary>
        /// Page Load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Page_Load(object sender, EventArgs e)
        {
            // query
            ifolderID = Request.QueryString.Get("iFolder");

            // connection
            web = (iFolderWeb)Session["Connection"];

            // localization
            rm = (ResourceManager)Application["RM"];

            if (!IsPostBack)
            {
                iFolder ifolder = web.GetiFolder(ifolderID);
                HistoryData.Columns[2].HeaderText = GetString("NAME");
                HistoryData.Columns[3].HeaderText = GetString("ACTION");
                HistoryData.Columns[4].HeaderText = GetString("DATE/TIME");

                //Load this page only if passphrase was provided for the encrypted iFolder
                if (!IfHistoryEnabled())
                {
                    // Return to Browse page, if passphrase was not provided for that encrypted ifolder.

                    Response.Redirect(String.Format("Browse.aspx?iFolder={0}", ifolderID));
                }

                string EncryptionAlgorithm = ifolder.EncryptionAlgorithm;
                if (!(EncryptionAlgorithm == null || (EncryptionAlgorithm == String.Empty)))
                {
                    // It is an encrypted ifolder , Make the Members tab invisible
                    Tabs.MakeMembersLinkInvisible();
                }

                // data
                BindData();

                // strings
                HistoryPagging.LabelSingular = GetString("CHANGE");
                HistoryPagging.LabelPlural   = GetString("CHANGES");
            }
        }
Example #17
0
        /// <summary>
        /// Page Load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Page_Load(object sender, EventArgs e)
        {
            // query
            ifolderID = Request.QueryString.Get("iFolder");
            entryID   = Request.QueryString.Get("Entry");

            // connection
            web = (iFolderWeb)Session["Connection"];

            // localization
            rm = (ResourceManager)Application["RM"];

            iFolder ifolder = web.GetiFolder(ifolderID);

            EncryptionAlgorithm = ifolder.EncryptionAlgorithm;
            EncryptionKey       = ifolder.EncryptionKey;

            if (!IsPostBack)
            {
                string PassPhrase = Session["SessionPassPhrase"] as string;
                if (PassPhrase == null)
                {
                    bool PPSet = web.IsPassPhraseSet();

                    if (PPSet && (EncryptionAlgorithm != null && EncryptionAlgorithm != String.Empty))
                    {
                        PassPhraseLabel.Visible = true;
                        PassPhraseText.Visible  = true;
                        PassPhraseLabel.Text    = GetString("ENTERPASSPHRASE");
                    }
                }
                // data
                BindData();

                // strings
                UploadButton.Text          = GetString("UPLOAD");
                CancelButton.Text          = GetString("CANCEL");
                OverWriteExistingFile.Text = GetString("TEXTOVERWRITE");
                OverWriteCheckbox.Checked  = true;
            }
        }
Example #18
0
        /// <summary>
        /// Bind the Data to the Page.
        /// </summary>
        private void BindData()
        {
            try
            {
                // ifolder
                iFolder ifolder = web.GetiFolder(ifolderID);

                // context
                iFolderName.Text = ifolder.Name;

                // description
                iFolderDescription.Text = ifolder.Description;
            }
            catch (SoapException ex)
            {
                if (!HandleException(ex))
                {
                    throw;
                }
            }
        }
Example #19
0
 /// <summary>
 /// Bind the Data to the Page.
 /// </summary>
 private void BindData()
 {
     try
     {
         // ifolder
         iFolder ifolder         = web.GetiFolder(ifolderID);
         string  ShortenedName   = null;
         int     ShortenedLength = 70;
         if (ifolder.Name.Length > ShortenedLength)
         {
             ShortenedName = web.GetShortenedName(ifolder.Name, ShortenedLength);
         }
         iFolderLink.Text    = (ifolder.Name.Length > ShortenedLength) ? ShortenedName : ifolder.Name;
         iFolderLink.ToolTip = ifolder.Name;
     }
     catch (SoapException ex)
     {
         if (!HandleException(ex))
         {
             throw;
         }
     }
 }
Example #20
0
        /// <summary>
        /// Bind the Data to the Page.
        /// </summary>
        private void BindCurrentMembersData()
        {
            try
            {
                // name
                iFolder ifolder = web.GetiFolder(ifolderID);
                iFolderName.Text = ifolder.Name;

                // current members
                iFolderUserSet members = web.GetMembers(ifolderID, 0, 0);

                foreach (iFolderUser member in members.Items)
                {
                    currentMembers.Add(member.ID, member.UserName);
                }
            }
            catch (SoapException ex)
            {
                if (!HandleException(ex))
                {
                    throw;
                }
            }
        }
Example #21
0
        /// <summary>
        /// Process the Request
        /// </summary>
        /// <param name="context">The HttpContext object</param>
        public void ProcessRequest(HttpContext context)
        {
            Blowfish bf           = null;
            int      boundary     = 0;
            int      count        = 0;
            long     bytesWritten = 0;
            // query
            string ifolderID = context.Request.QueryString["iFolder"];
            string entryID   = context.Request.QueryString["Entry"];

            try
            {
                // connection
                iFolderWeb web = (iFolderWeb)context.Session["Connection"];
                if (web == null)
                {
                    context.Response.Redirect("Login.aspx");
                }
                iFolder ifolder = web.GetiFolder(ifolderID);

                // Check if the passphrase is valid or not...
                if (ifolder.EncryptionAlgorithm != null && ifolder.EncryptionAlgorithm != "")
                {
                    //string PassPhrase = context.Request.QueryString["PassPhrase"];
                    string PassPhraseStr = (string)context.Session["SessionPassPhrase"];
                    Status ObjValidate   = web.ValidatePassPhrase(PassPhraseStr);
                    if (ObjValidate.statusCode != StatusCodes.Success)
                    {
                        String MessageString = GetString("PASSPHRASE_INCORRECT");
                        context.Session["SessionPassPhrase"] = null;
                        context.Response.Redirect(String.Format("Browse.aspx?iFolder={0}&Message={1}", ifolderID, MessageString));
                        return;
                    }
                }
                // request
                UriBuilder uri = new UriBuilder(web.Url);

                // Location of ifolder.
                string ifolderLocation = web.GetiFolderLocation(ifolderID);

                UriBuilder remoteurl = new UriBuilder(ifolderLocation);
                remoteurl.Path = (new Uri(web.Url)).PathAndQuery;
                web.Url        = remoteurl.Uri.ToString();

                uri.Path = String.Format("/simias10/Download.ashx?iFolder={0}&Entry={1}", ifolderID, entryID);

                WebRequest webRequest = (WebRequest)WebRequest.Create(uri.Uri);
                webRequest.Method          = "GET";
                webRequest.PreAuthenticate = true;
                webRequest.Credentials     = web.Credentials;
                //webRequest.CookieContainer = web.CookieContainer;

                WebResponse webResponse = (WebResponse)webRequest.GetResponse();

                Stream webStream = webResponse.GetResponseStream();

                // filename
                string filename = webResponse.Headers["Content-Disposition"];
                filename = filename.Substring(filename.IndexOf('=') + 1);

                // filename fix-up for Firefox and Safari
                if ((context.Request.UserAgent.IndexOf("Firefox") != -1) ||
                    (context.Request.UserAgent.IndexOf("Safari") != -1))
                {
                    filename = HttpUtility.UrlDecode(filename, System.Text.Encoding.UTF8);
                }

                // response
                //			iFolder ifolder = web.GetiFolder(ifolderID);
                iFolderEntry nodeEntry = web.GetEntry(ifolderID, entryID);

                context.Response.Clear();
                context.Response.AddHeader("Content-Disposition", String.Format("attachment; filename={0}", filename));
                //context.Response.AddHeader("Content-Length", webResponse.ContentLength.ToString());
                context.Response.AddHeader("Content-Length", nodeEntry.Size.ToString());                //actual size (padd bytes discarded below)
                context.Response.ContentType  = "application/octet-stream";
                context.Response.BufferOutput = false;


                if (ifolder.EncryptionAlgorithm != null && ifolder.EncryptionAlgorithm != "")
                {
                    //string PassPhrase = context.Request.QueryString["PassPhrase"];
                    string PassPhrase = (string)context.Session["SessionPassPhrase"];
//					UTF8Encoding utf8 = new UTF8Encoding();
                    string DecryptedCryptoKey;

                    //Hash the passphrase and use it for encryption and decryption
                    PassphraseHash hash       = new PassphraseHash();
                    byte[]         passphrase = hash.HashPassPhrase(PassPhrase);

                    Key key = new Key(ifolder.EncryptionKey);
                    key.DecrypytKey(passphrase, out DecryptedCryptoKey);
                    //Decrypt the key using passphrase and use it
                    bf       = new Blowfish(Convert.FromBase64String(DecryptedCryptoKey));
                    boundary = 8;
                }

                try
                {
                    Stream output = context.Response.OutputStream;

                    byte[] buffer = new byte[BUFFERSIZE];

                    while ((count = webStream.Read(buffer, 0, BUFFERSIZE)) > 0)
                    {
                        if (ifolder.EncryptionAlgorithm != null && ifolder.EncryptionAlgorithm != "")
                        {
                            bf.Decipher(buffer, count);

                            if ((bytesWritten + count) > nodeEntry.Size)
                            {
                                count = count - (boundary - (int)(nodeEntry.Size % boundary));
                            }
                        }
                        output.Write(buffer, 0, count);

                        bytesWritten += count;
                        output.Flush();
                    }
                }
                finally
                {
                    webStream.Close();
                }
            }
            catch
            {
                throw;
                try{
                    ResourceManager rm = (ResourceManager)context.Application["RM"];

                    context.Server.Transfer(String.Format(
                                                "{0}&Message={1}",
                                                context.Request.UrlReferrer,
                                                context.Server.UrlEncode(WebUtility.GetString("ENTRY.FAILEDDOWNLOAD", rm))));
                }
                catch
                {
                    string RedirectToUrl = string.Format("Browse.aspx?iFolder={0}", ifolderID);
                    context.Response.Redirect(RedirectToUrl);
                }
            }
        }
Example #22
0
        /// <summary>
        /// Creates a list of iFolders where the user is a member.
        /// </summary>
        /// <returns>A DataView object containing the iFolder list.</returns>
        private DataView CreateiFolderList()
        {
            string    folderState = String.Empty;
            DataTable dt          = new DataTable();
            DataRow   dr;

            dt.Columns.Add(new DataColumn("VisibleField", typeof(bool)));
            dt.Columns.Add(new DataColumn("IDField", typeof(string)));
            dt.Columns.Add(new DataColumn("OwnerIDField", typeof(string)));
            dt.Columns.Add(new DataColumn("SharedField", typeof(bool)));
            dt.Columns.Add(new DataColumn("DisabledField", typeof(bool)));
            dt.Columns.Add(new DataColumn("EncryptedField", typeof(bool)));
            dt.Columns.Add(new DataColumn("NameField", typeof(string)));
            dt.Columns.Add(new DataColumn("OwnerNameField", typeof(string)));
            dt.Columns.Add(new DataColumn("ReachableField", typeof(bool)));
            dt.Columns.Add(new DataColumn("FullNameField", typeof(string)));
            dt.Columns.Add(new DataColumn("folderSize", typeof(string)));
            dt.Columns.Add(new DataColumn("FolderMoveState", typeof(string)));

            // Get the iFolder list for this user.
            iFolderSet list;

            list = web.GetiFoldersByMember(UserID, MemberRole.Owner, CurrentiFolderOffset, iFolderList.PageSize);
            iFolder ifolder = null;

            foreach (iFolder folder in list.Items)
            {
                bool encrypted = false;

                try
                {
                    string     ifolderLocation = web.GetiFolderLocation(folder.ID);
                    UriBuilder remoteurl       = new UriBuilder(ifolderLocation);
                    remoteurl.Path = (new Uri(web.Url)).PathAndQuery;
                    web.Url        = remoteurl.Uri.ToString();
                }
                catch
                {
                    //skip exceptions
                    continue;
                }

                try
                {
                    ifolder = web.GetiFolder(folder.ID);
                }
                catch
                {
                    web.Url   = currentServerURL;
                    ifolder   = web.GetiFolder(folder.ID);
                    reachable = false;
                }
                string EncryptionAlgorithm = ifolder.EncryptionAlgorithm;
                if (!(EncryptionAlgorithm == null || (EncryptionAlgorithm == String.Empty)))
                {
                    // It is an encrypted ifolder
                    encrypted = true;
                }
                string ShortenedName   = null;
                int    ShortenedLength = 40;
                if (folder.Name.Length > ShortenedLength)
                {
                    // make it of desired length
                    ShortenedName = web.GetShortenedName(folder.Name, ShortenedLength);
                }


                switch (ifolder.FolderMoveStatus)
                {
                case 0:
                    folderState = (UserMoveStatus != null && UserMoveStatus == "NOTELIGIBLE")? GetString("NOTELIGIBLE") : GetString("INITIALIZING");
                    break;

                case 1:
                    folderState = GetString("TRANSFERING");
                    break;

                case 2:
                    folderState = GetString("COMPLETED");
                    break;
                }


                dr     = dt.NewRow();
                dr[0]  = true;
                dr[1]  = folder.ID;
                dr[2]  = folder.OwnerID;
                dr[3]  = (folder.MemberCount > 1) ? true : false;
                dr[4]  = !ifolder.Enabled;
                dr[5]  = (encrypted) ? true : false;
                dr[6]  = (folder.Name.Length > ShortenedLength) ? ShortenedName : folder.Name;
                dr[7]  = folder.OwnerFullName;
                dr[8]  = reachable;
                dr[9]  = folder.Name;
                dr[10] = folder.Size.ToString();
                dr[11] = folderState;

                dt.Rows.Add(dr);
                reachable = true;
            }

            // If the page size is not full, finish it with empty entries.
            for (int i = dt.Rows.Count; i < iFolderList.PageSize; ++i)
            {
                dr    = dt.NewRow();
                dr[0] = false;
                dr[1] = String.Empty;
                dr[2] = String.Empty;
                dr[3] = false;
                dr[4] = false;
                dr[5] = false;
                dr[6] = String.Empty;
                dr[7] = String.Empty;
                dr[8] = false;
                dr[9] = String.Empty;
                //		dr[ 10 ] = String.Empty ;  //TODO: verify
                dr[11] = String.Empty;

                dt.Rows.Add(dr);
            }

            // Remember the total number of users.
            TotaliFolders = list.Total;
            web.Url       = currentServerURL;

            // Build the data view from the table.
            return(new DataView(dt));
        }
Example #23
0
        /// <summary>
        /// Page Load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Page_Load(object sender, System.EventArgs e)
        {
            // query
            ifolderID = Request.QueryString.Get("iFolder");

            // connection
            web = (iFolderWeb)Session["Connection"];

            // localization
            rm = (ResourceManager)Application["RM"];

            if (!IsPostBack)
            {
                /*string PassPhrase = Session["SessionPassPhrase"] as string;
                 * ifolderID = Request.QueryString.Get("iFolder");
                 * iFolder ifolder = web.GetiFolder(ifolderID);
                 * string EncryptionAlgorithm = ifolder.EncryptionAlgorithm;
                 * SearchPattern.Enabled = true;
                 * if(PassPhrase == null && EncryptionAlgorithm == "")
                 * {
                 *      // it means , this is not an encrypted ifolder
                 *      // enable the search text box
                 *      SearchPattern.Enabled = true;
                 * }
                 * else if(PassPhrase != null)
                 * {
                 *      // user is in current session , so enable it
                 *      SearchPattern.Enabled = true;
                 * }
                 * else if(PassPhrase == null && web.IsPassPhraseSet())
                 * {
                 *      SearchPattern.Enabled = false;
                 * }*/

                // query
                SearchPattern.Text = Request.QueryString.Get("Pattern");

                // data
                BindData();

                // strings
                HomeLink.Text = GetString("HOME");

                bool    encrypted           = false;
                iFolder folder              = web.GetiFolder(ifolderID);
                string  EncryptionAlgorithm = folder.EncryptionAlgorithm;
                if (!(EncryptionAlgorithm == null || (EncryptionAlgorithm == String.Empty)))
                {
                    // It is an encrypted ifolder
                    encrypted = true;
                }

                bool shared = (folder.MemberCount > 1) ? true : false;

                iFolderImageUrl.ImageUrl = encrypted ? "images/encrypt_ilock2_16.gif" : (shared ? "images/ifolder_user_16.gif" : "images/ifolder.png");

                // links
                iFolderLink.NavigateUrl = iFolderImageLink.NavigateUrl =
                    "Browse.aspx?iFolder=" + ifolderID;
            }
        }
Example #24
0
        /// <summary>
        /// Gets the iFolder display name
        /// </summary>
        /// <returns>The display name of the current iFolder</returns>
        protected string GetiFolderName()
        {
            iFolder ifolder = web.GetiFolder(iFolderID);

            return((ifolder != null) ? ifolder.Name : String.Empty);
        }
Example #25
0
        /// <summary>
        /// Bind the Data to the Page.
        /// </summary>
        private void BindMemberData()
        {
            // member
            DataTable memberTable = new DataTable();

            memberTable.Columns.Add("ID");
            memberTable.Columns.Add("Name");
            memberTable.Columns.Add("UserName");
            memberTable.Columns.Add("Rights");
            memberTable.Columns.Add("Enabled", typeof(bool));
            memberTable.Columns.Add("iFolderID");

            try
            {
                // ifolder
                iFolder ifolder = web.GetiFolder(ifolderID);
                string  ownerID = ifolder.OwnerID;
                bool    flag    = false;

                // rights
                Actions.Visible               = (ifolder.MemberRights == Rights.Admin);
                ActionsOwner.Visible          = ifolder.IsOwner;
                MemberData.Columns[1].Visible = Actions.Visible;

                // member
                iFolderUserSet members = web.GetMembers(ifolderID, MemberPagging.Index, MemberPagging.PageSize);
                MemberPagging.Count = members.Items.Length;
                MemberPagging.Total = members.Total;
                string accessID = (Session["User"] as iFolderUser).ID;
                foreach (iFolderUser member in members.Items)
                {
                    if (member.ID == accessID)
                    {
                        flag = true;
                        break;
                    }
                }

                foreach (iFolderUser member in members.Items)
                {
                    DataRow row = memberTable.NewRow();

                    row["ID"]        = member.ID;
                    row["Name"]      = (member.FullName == "") ? member.UserName : member.FullName;
                    row["UserName"]  = member.UserName;
                    row["Rights"]    = member.IsOwner ? GetString("OWNER") : WebUtility.FormatRights(member.MemberRights, rm);
                    row["Enabled"]   = IsCheckBoxEnabled(member, accessID, ownerID, flag);
                    row["iFolderID"] = ifolderID;

                    memberTable.Rows.Add(row);
                }
            }
            catch (SoapException ex)
            {
                if (!HandleException(ex))
                {
                    throw;
                }
            }

            // bind
            MemberData.DataSource = memberTable;
            MemberData.DataBind();
        }
Example #26
0
        /// <summary>
        /// Creates a list of iFolders where the user is a member.
        /// </summary>
        /// <returns>A DataView object containing the iFolder list.</returns>
        private DataView CreateiFolderList()
        {
            DataTable dt = new DataTable();
            DataRow   dr;
            iFolder   ifolder = null;

            dt.Columns.Add(new DataColumn("VisibleField", typeof(bool)));
            dt.Columns.Add(new DataColumn("IDField", typeof(string)));
            dt.Columns.Add(new DataColumn("OwnerIDField", typeof(string)));
            dt.Columns.Add(new DataColumn("SharedField", typeof(bool)));
            dt.Columns.Add(new DataColumn("DisabledField", typeof(bool)));
            dt.Columns.Add(new DataColumn("EncryptedField", typeof(bool)));
            dt.Columns.Add(new DataColumn("NameField", typeof(string)));
            dt.Columns.Add(new DataColumn("OwnerNameField", typeof(string)));
            dt.Columns.Add(new DataColumn("MemberCountField", typeof(string)));
            dt.Columns.Add(new DataColumn("LastModifiedField", typeof(string)));
            dt.Columns.Add(new DataColumn("SizeField", typeof(string)));
            dt.Columns.Add(new DataColumn("ReachableField", typeof(bool)));
            dt.Columns.Add(new DataColumn("FullNameField", typeof(string)));
            dt.Columns.Add(new DataColumn("PreferenceField", typeof(int)));

            // Get the iFolder list for this user.

            iFolderSet list;

            switch (ActiveiFolderTab)
            {
            case ListDisplayType.Orphaned:
                list = web.GetOrphanediFolders(iFolderSearch.SearchOperation,
                                               (iFolderSearch.SearchName == String.Empty) ? "*" : iFolderSearch.SearchName,
                                               CurrentiFolderOffset,
                                               iFolderList.PageSize);
                DeleteButton.Visible = true;
                break;

            case ListDisplayType.All:
            default:
                list = web.GetiFoldersByName(iFolderSearch.SearchOperation,
                                             (iFolderSearch.SearchName == String.Empty) ? "*" : iFolderSearch.SearchName,
                                             CurrentiFolderOffset, iFolderList.PageSize);
                DeleteButton.Visible = true;
                break;
            }


            foreach (iFolder folder in list.Items)
            {
                bool encrypted = false;
                try
                {
                    string     ifolderLocation = web.GetiFolderLocation(folder.ID);
                    UriBuilder remoteurl       = new UriBuilder(ifolderLocation);
                    remoteurl.Path = (new Uri(web.Url)).PathAndQuery;
                    web.Url        = remoteurl.Uri.ToString();
                }
                catch
                {
                    //on exception skip
                    continue;
                }

                try
                {
                    ifolder = web.GetiFolder(folder.ID);
                }
                catch
                {
                    web.Url   = currentServerURL;
                    reachable = false;
                    ifolder   = web.GetiFolder(folder.ID);
                }
                string EncryptionAlgorithm = ifolder.EncryptionAlgorithm;
                if (!(EncryptionAlgorithm == null || (EncryptionAlgorithm == String.Empty)))
                {
                    // It is an encrypted ifolder
                    encrypted = true;
                }

                String ShortenedName   = null;
                int    ShortenedLength = 30;
                if (folder.Name.Length > ShortenedLength)
                {
                    // make it of desired length
                    ShortenedName = web.GetShortenedName(folder.Name, ShortenedLength);
                }

                dr     = dt.NewRow();
                dr[0]  = true;
                dr[1]  = folder.ID;
                dr[2]  = folder.OwnerID;
                dr[3]  = (folder.MemberCount > 1) ? true : false;
                dr[4]  = !ifolder.Enabled;
                dr[5]  = (encrypted) ? true : false;
                dr[6]  = (folder.Name.Length > ShortenedLength) ? ShortenedName : folder.Name;
                dr[7]  = folder.OwnerFullName;
                dr[8]  = folder.MemberCount.ToString();
                dr[9]  = Utils.ToDateTimeString("d", folder.LastModified);
                dr[11] = reachable;
                dr[12] = folder.Name;
                dr[13] = folder.Preference;

                dt.Rows.Add(dr);
                reachable = true;
            }

            // If the page size is not full, finish it with empty entries.
            for (int i = dt.Rows.Count; i < iFolderList.PageSize; ++i)
            {
                dr     = dt.NewRow();
                dr[0]  = false;
                dr[1]  = String.Empty;
                dr[2]  = String.Empty;
                dr[3]  = false;
                dr[4]  = false;
                dr[5]  = false;
                dr[6]  = String.Empty;
                dr[7]  = String.Empty;
                dr[8]  = String.Empty;
                dr[9]  = String.Empty;
                dr[10] = String.Empty;
                dr[11] = false;
                dr[12] = String.Empty;
                dr[13] = 0;

                dt.Rows.Add(dr);
            }

            // Remember the total number of users.
            TotaliFolders = list.Total;
            web.Url       = currentServerURL;

            // Build the data view from the table.
//			TopNav.ShowInfo(String.Format("URL: {0}", web.Url));
            return(new DataView(dt));
        }
Example #27
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);
        }
Example #28
0
        /// <summary>
        /// Bind the Data to the Page.
        /// </summary>
        private void BindData()
        {
            // table
            DataTable ifolderTable = new DataTable();

            ifolderTable.Columns.Add("ID");
            ifolderTable.Columns.Add("Image");
            ifolderTable.Columns.Add("Name");
            ifolderTable.Columns.Add("iFolderFullName");
            ifolderTable.Columns.Add("LastModified");
            ifolderTable.Columns.Add("Description");
            ifolderTable.Columns.Add("Rights");
            ifolderTable.Columns.Add("Size");
            ifolderTable.Columns.Add("OwnerFullName");
            ifolderTable.Columns.Add(new DataColumn("EnabledField", typeof(bool)));

            // category
            iFolderCategory category = HomeContext.Category;
            MemberRole      role     = MemberRole.Any;
            DateTime        after    = DateTime.MinValue;

            switch (category)
            {
            case iFolderCategory.Recent:
                after = DateTime.Now.AddDays(-30);
                break;

            case iFolderCategory.Owned:
                role = MemberRole.Owner;
                break;

            case iFolderCategory.Shared:
                role = MemberRole.Shared;
                break;

            case iFolderCategory.All:
            default:
                break;
            }

            try
            {
                // data
                string     escPattern = Regex.Escape(HomeContext.Pattern).Replace("\\*", ".*").Replace("\\?", ".");
                iFolderSet ifolders   = web.GetiFoldersBySearch(role, after, SearchOperation.Contains,
                                                                escPattern, iFolderPagging.Index, iFolderPagging.PageSize);
                iFolderPagging.Count = ifolders.Items.Length;
                iFolderPagging.Total = ifolders.Total;

                string name, ImageUrl;
                bool   pattern = (HomeContext.Pattern != null) && (HomeContext.Pattern.Length > 0);

                foreach (iFolder ifolder in ifolders.Items)
                {
                    bool encrypted = false;
                    try{
                        string     ifolderLocation = web.GetiFolderLocation(ifolder.ID);
                        UriBuilder remoteurl       = new UriBuilder(ifolderLocation);
                        remoteurl.Path = (new Uri(web.Url)).PathAndQuery;
                        web.Url        = remoteurl.Uri.ToString();
                    }catch
                    {
                        continue;
                    }
                    iFolder folder = null;
                    try{
                        folder = web.GetiFolder(ifolder.ID);
                    }
                    catch (Exception e)
                    {
                        string type = e.GetType().Name;
                        if (type != null && type == "MemberDoesNotExistException")
                        {
                            /// If we get member does not exist exception in the first call itself, no need to make a GetiFolder call to current server.
                            continue;
                        }
                        web.Url = currentServerURL;
                        try
                        {
                            folder = web.GetiFolder(ifolder.ID);
                        }
                        catch
                        {
                            /// If we are unable to get the iFolder information for the current entry, skip this and go to next entry...
                            folder = null;
                        }
                    }
                    /// By any chance if we are not able to get the iFolder information, proceed fetch the details of next entry.
                    if (folder == null)
                    {
                        continue;
                    }
                    string EncryptionAlgorithm = folder.EncryptionAlgorithm;
                    if (!(EncryptionAlgorithm == null || (EncryptionAlgorithm == String.Empty)))
                    {
                        // It is an encrypted ifolder
                        encrypted = true;
                    }

                    bool shared = (ifolder.MemberCount > 1) ? true : false;

                    bool enabled = (folder.Enabled) ? true : false;

                    ImageUrl = (!enabled)? "ifolder_16-gray.gif" : ((encrypted) ? "encrypt_ilock2_16.gif" : (shared ? "ifolder_user_16.gif" : "ifolder.png"));

                    DataRow row = ifolderTable.NewRow();

                    // selected name
                    if (pattern)
                    {
                        name = Regex.Replace(ifolder.Name, String.Format("({0})", escPattern),
                                             "<span class='highlight'>${1}</span>", RegexOptions.IgnoreCase);
                    }
                    else
                    {
                        name = ifolder.Name;
                    }

                    string ShortenedName   = null;
                    int    ShortenedLength = 70;
                    if (!pattern && name.Length > ShortenedLength)
                    {
                        // make it of desired length
                        ShortenedName = web.GetShortenedName(name, ShortenedLength);
                    }
                    row["ID"]              = ifolder.ID;
                    row["Image"]           = ImageUrl;
                    row["Name"]            = (!pattern && (name.Length > ShortenedLength)) ? ShortenedName : name;
                    row["iFolderFullName"] = name;
                    row["LastModified"]    = WebUtility.FormatDate(ifolder.LastModified, rm);
                    row["Description"]     = ifolder.Description;
                    row["Rights"]          = WebUtility.FormatRights(ifolder.MemberRights, rm);
                    row["Size"]            = WebUtility.FormatSize(ifolder.Size, rm);
                    row["OwnerFullName"]   = (ifolder.OwnerFullName == "")? ifolder.OwnerUserName : ifolder.OwnerFullName;
                    row["EnabledField"]    = enabled;

                    ifolderTable.Rows.Add(row);
                }
            }
            catch (SoapException ex)
            {
                if (!HandleException(ex))
                {
                    throw;
                }
            }

            // view
            DataView ifolderView = new DataView(ifolderTable);

            ifolderView.Sort = "Name";

            // data grid
            iFolderData.DataKeyField = "ID";
            iFolderData.DataSource   = ifolderView;
            iFolderData.DataBind();

            // Pass this page information to create the help link
            Head.AddHelpLink(GetString("IFOLDERS"));

            string PasswordChanged = Request.QueryString.Get("PasswordChanged");

            if (PasswordChanged != null && PasswordChanged == "true")
            {
                Message.Info = GetString("PASSWORDCHANGESUCCESS");
                return;
            }
        }
Example #29
0
        /// <summary>
        /// Gets the Sharing policy for the current iFolder.
        /// </summary>
        /// <param name="policy">User policy object</param>
        public void GetSharingPolicy(iFolderPolicy policy, string PolicyID)
        {
            // compare system policy, and owner policy also to decide
            //to get owner ID
            iFolder      ifolder       = web.GetiFolder(PolicyID);
            string       OwnerID       = ifolder.OwnerID;
            SystemPolicy systemPolicy  = web.GetSystemPolicy();
            UserPolicy   userPolicy    = web.GetUserPolicy(OwnerID, null);
            int          iFolderStatus = policy.SharingStatus;
            int          UserStatus    = userPolicy.SharingStatus;
            int          SystemStatus  = systemPolicy.SharingStatus;
            int          GroupStatus   = web.GetGroupSharingPolicy(OwnerID);
            /// the function will return who has higher priority : system or user or iFolder.
            int DerivedStatus = DeriveStatus(SystemStatus, GroupStatus, UserStatus, iFolderStatus);

            /// If policy was modified on iFolder level, then show it.

            Session["ValueChanged"] = "false";
            if (iFolderStatus == 0)
            {
                SharingOn.Checked          = true;
                enforcedSharing.Enabled    = true;
                disablePastSharing.Enabled = false;
                if (UserStatus != 0)
                {
                    if ((UserStatus & (int)Share.Sharing) == (int)Share.Sharing || UserStatus == 0)
                    {
                        SharingOn.Checked          = true;
                        disablePastSharing.Enabled = false;
                    }
                    else
                    {
                        SharingOn.Checked          = false;
                        disablePastSharing.Enabled = true;
                    }
                }
                else if (GroupStatus != 0)
                {
                    if ((GroupStatus & (int)Share.Sharing) == (int)Share.Sharing || GroupStatus == 0)
                    {
                        SharingOn.Checked          = true;
                        disablePastSharing.Enabled = false;
                    }
                    else
                    {
                        SharingOn.Checked          = false;
                        disablePastSharing.Enabled = true;
                    }
                }
                else
                {
                    if ((SystemStatus & (int)Share.Sharing) == (int)Share.Sharing || SystemStatus == 0)
                    {
                        SharingOn.Checked          = true;
                        disablePastSharing.Enabled = false;
                    }
                    else
                    {
                        SharingOn.Checked          = false;
                        disablePastSharing.Enabled = true;
                    }
                }
            }
            else
            {
                if ((iFolderStatus & (int)Share.Sharing) == (int)Share.Sharing)
                {
                    SharingOn.Checked          = true;
                    enforcedSharing.Enabled    = true;
                    disablePastSharing.Enabled = false;
                    if ((iFolderStatus & (int)Share.EnforcedSharing) == (int)Share.EnforcedSharing)
                    {
                        //disableSharingOn.Checked = true;
                        SharingOn.Enabled = false;
                        //enforcedDisableSharing.Enabled = true;
                        enforcedSharing.Checked = true;
                    }
                }
                else if ((iFolderStatus & (int)Share.DisableSharing) == (int)Share.DisableSharing)
                {
                    SharingOn.Checked          = false;
                    enforcedSharing.Enabled    = true;
                    disablePastSharing.Enabled = true;
                    if ((iFolderStatus & (int)Share.EnforcedSharing) == (int)Share.EnforcedSharing)
                    {
                        SharingOn.Enabled = false;
                        //enforcedDisableSharing.Enabled = true;
                        enforcedSharing.Checked = true;
                    }
                }
            }
            // Either there was no iFolder level policy, or user level has enforced its policy.
            if (DerivedStatus == (int)HigherPriority.User)
            {
                /// There was not any iFolder level policy but user level policy is there so show that.
                if (UserStatus == (int)Share.Sharing || UserStatus == 0)
                {
                    SharingOn.Checked          = true;
                    enforcedSharing.Enabled    = true;
                    disablePastSharing.Enabled = false;
                }
                else
                {
                    if ((UserStatus & (int)Share.Sharing) == (int)Share.Sharing)
                    {
                        SharingOn.Checked          = true;
                        enforcedSharing.Enabled    = true;
                        disablePastSharing.Enabled = false;
                        if ((UserStatus & (int)Share.EnforcedSharing) == (int)Share.EnforcedSharing)
                        {
                            //disableSharingOn.Checked = true;
                            //enforcedDisableSharing.Checked = true;
                            //system has higher priority , so disable the check boxes
                            SharingOn.Enabled = enforcedSharing.Enabled = false;
                        }
                    }
                    else if ((UserStatus & (int)Share.DisableSharing) == (int)Share.DisableSharing)
                    {
                        SharingOn.Checked          = false;
                        enforcedSharing.Enabled    = true;
                        disablePastSharing.Enabled = true;
                        if ((UserStatus & (int)Share.EnforcedSharing) == (int)Share.EnforcedSharing)
                        {
                            //disableSharingOn.Checked = true;
                            //enforcedDisableSharing.Checked = true;
                            //system has higher priority , so disable the check boxes
                            SharingOn.Enabled = enforcedSharing.Enabled = false;
                        }
                    }
                }
            }

            // Either there was no iFolder level policy, or Group level has enforced its policy.
            if (DerivedStatus == (int)HigherPriority.Group)
            {
                /// There was not any iFolder level policy but group level policy is there so show that.
                if (GroupStatus == (int)Share.Sharing || UserStatus == 0)
                {
                    SharingOn.Checked          = true;
                    enforcedSharing.Enabled    = true;
                    disablePastSharing.Enabled = false;
                }
                else
                {
                    if ((GroupStatus & (int)Share.Sharing) == (int)Share.Sharing)
                    {
                        SharingOn.Checked          = true;
                        enforcedSharing.Enabled    = true;
                        disablePastSharing.Enabled = false;
                        if ((GroupStatus & (int)Share.EnforcedSharing) == (int)Share.EnforcedSharing)
                        {
                            //disableSharingOn.Checked = true;
                            //enforcedDisableSharing.Checked = true;
                            //Group has higher priority , so disable the check boxes
                            SharingOn.Enabled = enforcedSharing.Enabled = false;
                        }
                    }
                    else if ((GroupStatus & (int)Share.DisableSharing) == (int)Share.DisableSharing)
                    {
                        SharingOn.Checked          = false;
                        enforcedSharing.Enabled    = true;
                        disablePastSharing.Enabled = true;
                        if ((GroupStatus & (int)Share.EnforcedSharing) == (int)Share.EnforcedSharing)
                        {
                            //disableSharingOn.Checked = true;
                            //enforcedDisableSharing.Checked = true;
                            //group has higher priority , so disable the check boxes
                            SharingOn.Enabled = enforcedSharing.Enabled = false;
                        }
                    }
                }
            }

            if (DerivedStatus == (int)HigherPriority.System)
            {
                /// There was not any iFolder level policy but system level policy is there so show that.
                if (SystemStatus == (int)Share.Sharing || SystemStatus == 0)
                {
                    SharingOn.Checked          = true;
                    enforcedSharing.Enabled    = true;
                    disablePastSharing.Enabled = false;
                }
                else
                {
                    if ((SystemStatus & (int)Share.Sharing) == (int)Share.Sharing)
                    {
                        SharingOn.Checked          = true;
                        enforcedSharing.Enabled    = true;
                        disablePastSharing.Enabled = false;
                        if ((SystemStatus & (int)Share.EnforcedSharing) == (int)Share.EnforcedSharing)
                        {
                            //disableSharingOn.Checked = true;
                            //enforcedDisableSharing.Checked = true;
                            //system has higher priority , so disable the check boxes
                            SharingOn.Enabled = enforcedSharing.Enabled = false;
                        }
                    }
                    else if ((SystemStatus & (int)Share.DisableSharing) == (int)Share.DisableSharing)
                    {
                        SharingOn.Checked          = false;
                        enforcedSharing.Enabled    = true;
                        disablePastSharing.Enabled = true;
                        if ((SystemStatus & (int)Share.EnforcedSharing) == (int)Share.EnforcedSharing)
                        {
                            //disableSharingOn.Checked = true;
                            //enforcedDisableSharing.Checked = true;
                            //system has higher priority , so disable the check boxes
                            SharingOn.Enabled = enforcedSharing.Enabled = false;
                        }
                    }
                }
            }

            // There is no requirement of enforce check box on iFolder level, so make it invisible
            enforcedSharing.Visible = false;
        }
Example #30
0
        /// <summary>
        /// Creates a list of iFolders where the user is a member.
        /// </summary>
        /// <returns>A DataView object containing the iFolder list.</returns>
        private DataView CreateiFolderList()
        {
            if (ErrorMsg != null)
            {
                TopNav.ShowError(ErrorMsg);
            }

            DataTable dt = new DataTable();
            DataRow   dr;

            dt.Columns.Add(new DataColumn("VisibleField", typeof(bool)));
            dt.Columns.Add(new DataColumn("IDField", typeof(string)));
            dt.Columns.Add(new DataColumn("OwnerIDField", typeof(string)));
            dt.Columns.Add(new DataColumn("SharedField", typeof(bool)));
            dt.Columns.Add(new DataColumn("DisabledField", typeof(bool)));
            dt.Columns.Add(new DataColumn("EncryptedField", typeof(bool)));
            dt.Columns.Add(new DataColumn("NameField", typeof(string)));
            dt.Columns.Add(new DataColumn("OwnerNameField", typeof(string)));
            dt.Columns.Add(new DataColumn("ReachableField", typeof(bool)));
            dt.Columns.Add(new DataColumn("FullNameField", typeof(string)));
            dt.Columns.Add(new DataColumn("PreferenceField", typeof(int)));

            // Get the iFolder list for this user.
            iFolderSet list;

            switch (ActiveiFolderTab)
            {
            case ListDisplayType.Owned:
                list = web.GetiFoldersByMember(UserID, MemberRole.Owner, CurrentiFolderOffset, iFolderList.PageSize);
                break;

            case ListDisplayType.Shared:
                list = web.GetiFoldersByMember(UserID, MemberRole.Shared, CurrentiFolderOffset, iFolderList.PageSize);
                break;

            case ListDisplayType.All:
            default:
                list = web.GetiFoldersByMember(UserID, MemberRole.Any, CurrentiFolderOffset, iFolderList.PageSize);
                break;
            }
            iFolder ifolder = null;

            foreach (iFolder folder in list.Items)
            {
                bool encrypted = false;
                try
                {
                    string     ifolderLocation = web.GetiFolderLocation(folder.ID);
                    UriBuilder remoteurl       = new UriBuilder(ifolderLocation);
                    remoteurl.Path = (new Uri(web.Url)).PathAndQuery;
                    web.Url        = remoteurl.Uri.ToString();
                }
                catch
                {
                    //skip exceptions
                    continue;
                }

                try
                {
                    ifolder = web.GetiFolder(folder.ID);
                }
                catch
                {
                    web.Url   = currentServerURL;
                    ifolder   = web.GetiFolder(folder.ID);
                    reachable = false;
                }
                string EncryptionAlgorithm = ifolder.EncryptionAlgorithm;
                if (!(EncryptionAlgorithm == null || (EncryptionAlgorithm == String.Empty)))
                {
                    // It is an encrypted ifolder
                    encrypted = true;
                }
                string ShortenedName   = null;
                int    ShortenedLength = 40;
                if (folder.Name.Length > ShortenedLength)
                {
                    // make it of desired length
                    ShortenedName = web.GetShortenedName(folder.Name, ShortenedLength);
                }


                dr     = dt.NewRow();
                dr[0]  = true;
                dr[1]  = folder.ID;
                dr[2]  = folder.OwnerID;
                dr[3]  = (folder.MemberCount > 1) ? true : false;
                dr[4]  = !ifolder.Enabled;
                dr[5]  = (encrypted) ? true : false;
                dr[6]  = (folder.Name.Length > ShortenedLength) ? ShortenedName : folder.Name;
                dr[7]  = folder.OwnerFullName;
                dr[8]  = reachable;
                dr[9]  = folder.Name;
                dr[10] = folder.Preference;

                dt.Rows.Add(dr);
                reachable = true;
            }

            // If the page size is not full, finish it with empty entries.
            for (int i = dt.Rows.Count; i < iFolderList.PageSize; ++i)
            {
                dr     = dt.NewRow();
                dr[0]  = false;
                dr[1]  = String.Empty;
                dr[2]  = String.Empty;
                dr[3]  = false;
                dr[4]  = false;
                dr[5]  = false;
                dr[6]  = String.Empty;
                dr[7]  = String.Empty;
                dr[8]  = false;
                dr[9]  = String.Empty;
                dr[10] = 0;

                dt.Rows.Add(dr);
            }

            // Remember the total number of users.
            TotaliFolders = list.Total;
            web.Url       = currentServerURL;

            // Build the data view from the table.
            return(new DataView(dt));
        }