Exemplo n.º 1
0
        public string Protect(string filePath, string ownerEmail, string listOfRights)
        {
            string adListOfRights = Encoding.UTF8.GetString(Convert.FromBase64String(listOfRights));

            string file = Encoding.UTF8.GetString(Convert.FromBase64String(filePath));

            //return file + "/" + ownerEmail + "/" + adListOfRights;

            Collection <UserRights> userRights = new Collection <UserRights>();

            if (!protector.IsEncrypted(file))
            {
                userRights = UserRightsHelper.ConvertRightsStringToCollection(adListOfRights);

                //return userRights.Count.ToString();

                if (userRights.Count > 0)
                {
                    protector.EncryptFile(ownerEmail, userRights, file);

                    return("File has been protected with list of rights.");
                }
                else
                {
                    return("Kindly pass a valid rights string.");
                }
            }
            else
            {
                return("File is already Protected.");
            }
        }
Exemplo n.º 2
0
        public static UserRightsHelper ConvertStringtoRights(string rights)
        {
            UserRightsHelper userRights = new UserRightsHelper();

            string[] rightsArray = rights.Split(':');

            userRights.AddRights(rightsArray[0], rightsArray[1]);

            return(userRights);
        }
Exemplo n.º 3
0
        public static string ConvertRightsToString(UserRightsHelper rights)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(rights.EmailAddress);
            sb.Append(":");
            sb.Append(rights.RightsList);

            return(sb.ToString());
        }