private static Xml.NonRepudiationInformation MapNonRepudiationInformation(NonRepudiationInformation model) { MessagePartNRInformation MapPartNRInformation(Reference r) { return(new MessagePartNRInformation { Item = new ReferenceType { URI = r.URI, DigestMethod = new DigestMethodType { Algorithm = r.DigestMethod.Algorithm }, DigestValue = r.DigestValue, Transforms = r.Transforms.Select(t => new TransformType { Algorithm = t.Algorithm }).ToArray() } }); } return(new Xml.NonRepudiationInformation { MessagePartNRInformation = model.MessagePartNRIReferences.Select(MapPartNRInformation).ToArray() }); }
/// <summary> /// Creates a non-repudiation AS4 receipt that references a given <paramref name="includedUserMessage"/>. /// </summary> /// <param name="receiptMessageId"></param> /// <param name="includedUserMessage">The <see cref="Core.UserMessage"/> for which this receipt is created.</param> /// <param name="userMessageSecurityHeader">The security header to retrieve the signed references from to include in the receipt.</param> /// <param name="userMessageSendViaMultiHop"> /// Whether or not the user message was send in a multi-hop fashion or not. /// Setting this on <c>true</c> will result in a receipt with the referencing user message included in a RoutingInput element. /// </param> /// <exception cref="ArgumentNullException">The <paramref name="includedUserMessage"/> should not be <c>null</c>.</exception> public static Receipt CreateFor( string receiptMessageId, UserMessage includedUserMessage, SecurityHeader userMessageSecurityHeader, bool userMessageSendViaMultiHop = false) { if (includedUserMessage == null) { throw new ArgumentNullException(nameof(includedUserMessage)); } if (userMessageSecurityHeader != null) { IEnumerable <CryptoReference> signedReferences = userMessageSecurityHeader.GetReferences(); if (signedReferences.Any()) { var nonRepudiation = new NonRepudiationInformation( signedReferences.Select(Reference.CreateFromReferenceElement)); return(userMessageSendViaMultiHop.ThenMaybe(UserMessageMap.ConvertToRouting(includedUserMessage)) .Select(routing => new Receipt(receiptMessageId, includedUserMessage?.MessageId, nonRepudiation, routing)) .GetOrElse(() => new Receipt(receiptMessageId, includedUserMessage?.MessageId, nonRepudiation, routedUserMessage: null))); } } return(CreateFor(receiptMessageId, includedUserMessage, userMessageSendViaMultiHop)); }
/// <summary> /// Initializes a new instance of the <see cref="Receipt"/> class. /// </summary> /// <param name="messageId">The ebMS message identifier of this message unit.</param> /// <param name="refToMessageId">The reference to an ebMS message identifier of an <see cref="Core.UserMessage"/>.</param> /// <param name="nonRepudiation">The non-repudiation information containing the signed references of the <see name="Core.UserMessage"/>.</param> internal Receipt( string messageId, string refToMessageId, NonRepudiationInformation nonRepudiation) : this(messageId, refToMessageId, nonRepudiation, routedUserMessage : null) { }
/// <summary> /// Initializes a new instance of the <see cref="Receipt"/> class. /// </summary> /// <param name="messageId">The ebMS message identifier of this message unit.</param> /// <param name="refToMessageId">The reference to an ebMS message identifier of an <see cref="Core.UserMessage"/>.</param> /// <param name="nonRepudiation">The non-repudiation information containing the signed references of the <see name="Core.UserMessage"/>.</param> /// <param name="routedUserMessage">The <see cref="Core.UserMessage"/> to include in the receipt in the form of a RoutingInput element.</param> internal Receipt( string messageId, string refToMessageId, NonRepudiationInformation nonRepudiation, RoutingInputUserMessage routedUserMessage) : this(messageId, refToMessageId, DateTimeOffset.Now, nonRepudiation, routedUserMessage) { }
/// <summary> /// Initializes a new instance of the <see cref="Receipt"/> class. /// </summary> /// <param name="messageId">The ebMS message identifier of this message unit.</param> /// <param name="refToMessageId">The reference to an ebMS message identifier of an <see cref="Core.UserMessage"/>.</param> /// <param name="timestamp">The timestamp when this receipt is created.</param> /// <param name="nonRepudiation">The non-repudiation information containing the signed references of the <see name="Core.UserMessage"/>.</param> /// <param name="routedUserMessage">The <see cref="Core.UserMessage"/> to include in the receipt in the form of a RoutingInput element.</param> internal Receipt( string messageId, string refToMessageId, DateTimeOffset timestamp, NonRepudiationInformation nonRepudiation, RoutingInputUserMessage routedUserMessage) : base(messageId, refToMessageId, timestamp, routedUserMessage) { NonRepudiationInformation = nonRepudiation; }