Exemple #1
0
        /**
         * @param level Document protecton level
         * @param pwd Document password - clear text
         * @since 2.1.1
         * @author Howard Shank ([email protected])
         */
        public bool SetProtection(int level, String pwd)
        {
            bool result = false;

            if (this.protectionHash == null)
            {
                if (!SetProtectionLevel(level))
                {
                    result = false;
                }
                else
                {
                    protectionHash = RtfProtection.GenerateHash(pwd);
                    result         = true;
                }
            }
            else
            {
                if (this.protectionHash.Equals(RtfProtection.GenerateHash(pwd)))
                {
                    if (!SetProtectionLevel(level))
                    {
                        result = false;
                    }
                    else
                    {
                        protectionHash = RtfProtection.GenerateHash(pwd);
                        result         = true;
                    }
                }
            }
            return(result);
        }
Exemple #2
0
        /**
         * @param oldPwd Old password - clear text
         * @param newPwd New password - clear text
         * @return true if password set, false if password not set
         * @since 2.1.1
         * @author Howard Shank ([email protected])
         */
        public bool SetNewPassword(String oldPwd, String newPwd)
        {
            bool result = false;

            if (this.protectionHash.Equals(RtfProtection.GenerateHash(oldPwd)))
            {
                this.protectionHash = RtfProtection.GenerateHash(newPwd);
                result = true;
            }
            return(result);
        }
Exemple #3
0
        /**
         * @param pwd Document password - clear text
         * @return true if document unprotected, false if protection is not removed.
         * @since 2.1.1
         * @author Howard Shank ([email protected])
         */
        public bool UnprotectDocument(String pwd)
        {
            bool result = false;

            if (this.protectionHash.Equals(RtfProtection.GenerateHash(pwd)))
            {
                this.protectionLevel = RtfProtection.LEVEL_NONE;
                this.protectionHash  = null;
                result = true;
            }
            return(result);
        }