Esempio n. 1
0
        public IXLWorkbookProtection AllowElement(XLWorkbookProtectionElements element, Boolean allowed = true)
        {
            if (allowed)
            {
                AllowedElements |= element;
            }
            else
            {
                AllowedElements &= ~element;
            }

            return(this);
        }
Esempio n. 2
0
 public IXLWorkbookProtection DisallowElement(XLWorkbookProtectionElements element)
 {
     return(AllowElement(element, allowed: false));
 }
Esempio n. 3
0
 IXLElementProtection <XLWorkbookProtectionElements> IXLElementProtection <XLWorkbookProtectionElements> .DisallowElement(XLWorkbookProtectionElements element) => DisallowElement(element);
Esempio n. 4
0
 IXLElementProtection <XLWorkbookProtectionElements> IXLElementProtection <XLWorkbookProtectionElements> .AllowElement(XLWorkbookProtectionElements element, Boolean allowed) => AllowElement(element, allowed);
Esempio n. 5
0
 public XLWorkbookProtection(Algorithm algorithm, XLWorkbookProtectionElements allowedElements)
 {
     this.Algorithm       = algorithm;
     this.AllowedElements = allowedElements;
 }
Esempio n. 6
0
        public IXLWorkbookProtection Protect(String password, Algorithm algorithm = DefaultProtectionAlgorithm, XLWorkbookProtectionElements allowedElements = XLWorkbookProtectionElements.Windows)
        {
            if (IsProtected)
            {
                throw new InvalidOperationException("The workbook structure is already protected");
            }
            else
            {
                IsProtected = true;

                password = password ?? "";

                this.Algorithm         = algorithm;
                this.Base64EncodedSalt = Utils.CryptographicAlgorithms.GenerateNewSalt(this.Algorithm);
                this.PasswordHash      = Utils.CryptographicAlgorithms.GetPasswordHash(this.Algorithm, password, this.Base64EncodedSalt, this.SpinCount);
            }

            this.AllowedElements = allowedElements;

            return(this);
        }