/// <summary> /// Returns the IPDFSecurePasswordProvider for this element /// </summary> /// <returns></returns> internal IPDFSecurePasswordProvider GetPasswordProvider() { if (null == _provider) { string typename = this.ProviderType; if (string.IsNullOrEmpty(typename)) { _provider = new Scryber.Secure.Configuration.ConfigPasswordProvider(this); } else { _provider = GetPasswordProviderFromName(typename); } } return(_provider); }
/// <summary> /// Returns true if there is any configured password security for the document based on the path, and sets the provider to the configured value. /// </summary> /// <param name="fullpath">The full path of the PDF document template that is being generated.</param> /// <param name="provider">Set to the configured password provider, if there is one.</param> /// <returns>false if no provider was found, otherwise true.</returns> public bool TryGetProviderForPath(string fullpath, out IPDFSecurePasswordProvider provider) { provider = null; PasswordPathElementCollection passes = this.Passwords; if (null == passes || passes.Count == 0) { return(false); } else { foreach (PasswordPathElement ele in passes) { if (ele.IsMatch(fullpath)) { provider = ele.GetPasswordProvider(); return(null != provider); } } //no matches - this is not an error condition. return(false); } }
public IPDFSecurePasswordProvider GetPasswordProvider(string defaultOwner) { if (null == _provider) { if (string.IsNullOrEmpty(this.ProviderType) == false) { var type = Type.GetType(this.ProviderType, true); var prov = Activator.CreateInstance(type, this); if (prov is IPDFSecurePasswordProvider) { _provider = (IPDFSecurePasswordProvider)prov; } else { throw new InvalidCastException("Could not convert match pattern " + this.MatchPattern + " provider to an IPDFSecurePasswordProvider"); } } else { _provider = new SecurityOptionsPasswordProvider(this); } } return(_provider); }