/// <summary> /// Get publications file. /// </summary> /// <returns>publications file</returns> public IPublicationsFile GetPublicationsFile() { if (_publicationsFileLoadTime > DateTime.Now.AddHours(-1) && _publicationsFile != null) { return(_publicationsFile); } _publicationsFile = _ksiService.GetPublicationsFile(); if (_publicationsFile == null) { throw new KsiException("Invalid publications file: null."); } _publicationsFileLoadTime = DateTime.Now; return(_publicationsFile); }
/// <summary> /// Verify given KSI signature. /// At first the signature is verified against given document hash and publications file. Publications file is downloaded using given KSI service. /// If suitable publication is not found in publications file then the KSI signature is extended. /// If extending is not yet possible then key based verification is done. /// </summary> /// <param name="ksiSignature">KSI signature to be verified.</param> /// <param name="documentHash">Document hash</param> /// <param name="ksiService">KSI services for downloading publications file and extending KSI signature if needed.</param> /// <returns>verification result</returns> public VerificationResult Verify(IKsiSignature ksiSignature, DataHash documentHash, IKsiService ksiService) { if (ksiSignature == null) { throw new ArgumentNullException(nameof(ksiSignature)); } if (ksiService == null) { throw new ArgumentNullException(nameof(ksiService)); } return(base.Verify(new VerificationContext() { Signature = ksiSignature, DocumentHash = documentHash, PublicationsFile = ksiService.GetPublicationsFile(), KsiService = ksiService, IsExtendingAllowed = true })); }