private PendingRequest CreateDownloadRequest(DsspSession session) { return(new PendingRequest() { OptionalInputs = new OptionalInputs() { AdditionalProfile = "urn:oasis:names:tc:dss:1.0:profiles:asynchronousprocessing", ResponseID = session.ServerId, RequestSecurityToken = new RequestSecurityTokenType() { RequestType = "http://docs.oasis-open.org/ws-sx/ws-trust/200512/Cancel", CancelTarget = new CancelTargetType() { SecurityTokenReference = new SecurityTokenReferenceType() { Reference = new ReferenceType() { ValueType = "http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512/sct", URI = session.KeyId } } } } } }); }
private DigitalSignatureServicePortTypeClient CreateDSSPClient(DsspSession session) { var client = new DigitalSignatureServicePortTypeClient(new ScDsspBinding(), Address); client.ChannelFactory.Endpoint.Behaviors.Remove <ClientCredentials>(); client.ChannelFactory.Endpoint.Behaviors.Add(new ScDsspClientCredentials(session.KeyId, session.KeyValue)); return(client); }
/// <summary> /// Downloads the document that was uploaded before and signed via the BROWSER/POST protocol, asynchronously. /// </summary> /// <see cref="DownloadDocument"/> public async Task<Document> DownloadDocumentAsync(DsspSession session) { if (session == null) throw new ArgumentNullException("session"); var client = CreateDSSPClient(session); var downloadRequest = CreateDownloadRequest(session); pendingRequestResponse downloadResponseWrapper = await client.pendingRequestAsync(downloadRequest); return ProcessDownloadResponse(downloadResponseWrapper.SignResponse); }
/// <summary> /// Downloads the document that was uploaded before and signed via the BROWSER/POST protocol. /// </summary> /// <remarks> /// The session is closed when the downloads finishes, it can't be reused afterward and should be removed from the storage. /// </remarks> /// <param name="session">The session linked to the uploaded document</param> /// <returns>The document with signature, including id and mimeType</returns> /// <exception cref="ArgumentException">When the signResponse isn't valid, including its signature</exception> /// <exception cref="InvalidOperationException">When the e-contract service returns an error</exception> public Document DownloadDocument(DsspSession session) { if (session == null) { throw new ArgumentNullException("session"); } var client = CreateDSSPClient(session); var downloadRequest = CreateDownloadRequest(session); SignResponse downloadResponse = client.pendingRequest(downloadRequest); return(ProcessResponseWithSignedDoc(downloadResponse)); }
/// <summary> /// Downloads the document that was uploaded before and signed via the BROWSER/POST protocol, asynchronously. /// </summary> /// <see cref="DownloadDocument(DsspSession)"/> public async Task <Document> DownloadDocumentAsync(DsspSession session) { if (session == null) { throw new ArgumentNullException("session"); } var client = CreateDSSPClient(session); var downloadRequest = CreateDownloadRequest(session); pendingRequestResponse downloadResponseWrapper = await client.pendingRequestAsync(downloadRequest); return(ProcessResponseWithSignedDoc(downloadResponseWrapper.SignResponse)); }
internal static DsspSession NewSession() { var session = new DsspSession(); session.ClientId = "msg-" + Guid.NewGuid().ToString(); return session; }