10using NanoXLSX.Exceptions;
13using NanoXLSX.Registry;
14using NanoXLSX.Registry.Attributes;
22 [NanoXlsxPlugIn(PlugInUUID = PlugInUUID.PasswordReader)]
25 private string passwordHash;
35 public virtual PasswordType
Type {
get;
private set; }
47 get {
return passwordHash; }
48 set { passwordHash = value; }
67 this.Options = readerOptions;
77 if (
Type == PasswordType.WorkbookProtection)
85 if (attribute !=
null)
87 if (
Options.IgnoreNotSupportedPasswordAlgorithms)
89 this.ContemporaryAlgorithmDetected =
true;
93 throw new NotSupportedContentException(
"A not supported, contemporary password algorithm for the worksheet protection was detected. Check possible packages to add support to NanoXLSX, or ignore this error by a reader option");
97 if (
Type == PasswordType.WorkbookProtection)
100 if (attribute !=
null)
102 this.PasswordHash = attribute;
108 if (attribute !=
null)
110 this.PasswordHash = attribute;
138 public virtual void CopyFrom(IPassword passwordInstance)
140 throw new NotImplementedException();
150 throw new NotImplementedException();
159 throw new NotImplementedException();
Static class that contains enums for password handling.
Static class with common util methods, used during reading XLSX files.
static string GetAttribute(XmlNode node, string targetName, string fallbackValue=null)
Gets the XML attribute of the passed XML node by its name.
Class representing a reader for legacy passwords.
virtual string GetPassword()
Gets the password. This method is not supported in a reader and will always return null.
virtual string PasswordHash
Gets or sets the password hash.
virtual void CopyFrom(IPassword passwordInstance)
Not relevant for the reader (inherited from IPassword).
virtual void SetPassword(string plainText)
Not relevant for the reader (inherited from IPassword).
virtual void Init(PasswordType type, ReaderOptions readerOptions)
Initialization method (interface implementation).
virtual bool PasswordIsSet()
Indicates whether a password is set. This can be the case, if a legacy or contemporary password was d...
virtual PasswordType Type
Current target type of the password instance.
virtual void ReadXmlAttributes(XmlNode node)
Reads the attributes of the passed XML node that contains password information.
virtual void UnsetPassword()
Not relevant for the reader (inherited from IPassword).
virtual ReaderOptions Options
Reader options.
virtual bool ContemporaryAlgorithmDetected
Gets whether a contemporary password algorithm was detected (not supported by core functionality).
The reader options define global rules, applied when loading a worksheet. The options are mainly to o...
Interface, used by password readers.