Path: redb-route/redb.Route.As2/Mdn/As2Disposition.cs
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.As2/Mdn/As2Disposition.cs
----
namespace redb.Route.As2.Mdn;
///
/// The disposition modifiers of RFC 4130 §7.4.3 a receiver reports when it did not process a message. The MDN carries
/// the code and a fixed text with a reference; what went wrong in detail stays in our log (the partner learns the
/// class of the failure, not our internals).
///
internal static class As2Disposition
{
/// The sender is not the agreed partner: identifiers or signature do not match the agreement.
public const string AuthenticationFailed = "authentication-failed";
/// The message could not be decrypted with our key.
public const string DecryptionFailed = "decryption-failed";
/// The compressed payload could not be decompressed.
public const string DecompressionFailed = "decompression-failed";
/// The message is signed or encrypted less than the agreement requires.
public const string InsufficientMessageSecurity = "insufficient-message-security";
/// Anything else: a malformed message, or the route failed to process it.
public const string UnexpectedProcessingError = "unexpected-processing-error";
///
/// The sender requires a signed-receipt protocol other than pkcs7-signature: a failed/Failure
/// disposition (RFC 4130 §7.5.3), the message is not processed.
///
public const string UnsupportedFormat = "unsupported format";
///
/// The sender requires MIC algorithms of which none is usable here: a failed/Failure disposition
/// (RFC 4130 §7.5.3), the message is not processed.
///
public const string UnsupportedMicAlgorithms = "unsupported MIC-algorithms";
///
/// Whether is reported as failed/Failure: modifier (no MDN as asked could be
/// generated) rather than processed/error: modifier.
///
public static bool IsFailure(string modifier) => modifier is UnsupportedFormat or UnsupportedMicAlgorithms;
/// The text of the MDN's human-readable part for a failure .
public static string Describe(string modifier) => modifier switch
{
AuthenticationFailed => "The AS2 message could not be authenticated as coming from the agreed partner.",
DecryptionFailed => "The AS2 message could not be decrypted.",
DecompressionFailed => "The AS2 message could not be decompressed.",
InsufficientMessageSecurity => "The AS2 message is not signed or encrypted as the agreement requires.",
UnsupportedFormat => "The AS2 message requires a signed-receipt protocol this receiver does not support; it was not processed.",
UnsupportedMicAlgorithms => "The AS2 message requires MIC algorithms this receiver does not support; it was not processed.",
_ => "The AS2 message could not be processed.",
};
}
/// A received message was not processed, for the reason names (RFC 4130 §7.4.3).
internal sealed class As2DispositionException : Exception
{
public As2DispositionException(string modifier, string detail, Exception? inner = null)
: base(detail, inner) => Modifier = modifier;
/// One of the codes.
public string Modifier { get; }
}