SignerBaseCreateSignatureSession Method (CreateSessionRequest) |
Namespace: ASDSoft.WebSigner.Server
protected abstract Task<SignatureSession> CreateSignatureSession( CreateSessionRequest request )
Obtain data or hash for signing one or more content.
Create instance of implementation ContentBase for each signing content.
Create instance of SignatureRequest for each signing content.
Create instance of SignatureSession with list of SignatureRequest.
protected override async Task<SignatureSession> CreateSignatureSession(CreateSessionRequest request) { if (request == CreateSessionRequest.Login) return CreateLoginSignatureSession(); switch (request.Category.ToLower()) { case "doc": Document[] documents = await new DocumentRepository().GetDocumentsAsync(request.Identification); return this.CreateSignatureSession(documents.Select(document => d.CreateSignatureRequestFromDocument(document)).ToArray()); default: throw new ArgumentException($"Unknown category {request.Category}.", nameof(request.Category)); } } private SignatureRequest CreateSignatureRequestFromDocument(Document document) { byte[] documentHash = document.ComputeHash(HashAlgorithmName.SHA256); DocumentLinkContent documentLinkContent = new DocumentLinkContent(document.Id, document.Name, documentHash, SignatureType.Hash); return new SignatureRequest(documentLinkContent, HashAlgorithmName.SHA256); }