﻿<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt"
	exclude-result-prefixes="msxsl extensions" xmlns:extensions="http://mailgateway.netatwork.de/processcard">
	<xsl:output method="html" indent="yes" media-type="text/html" omit-xml-declaration="yes" encoding="utf-8" />
	<xsl:template match="ValidationReport">
		<html>
			<head>
				<title>Validation report</title>
				<style type="text/css">
					* {
					margin: 0;
					padding: 0;
					}

					img {
					border: 0;
					}

					html, body {
					color: #383738;
					background: #ffffff;
					font-family: Calibri, Arial, Verdana;
					font-size: 16px;
					text-decoration: none;
					font-weight: normal;
					line-height: 18px;
					}

					table.frame {
					width: 100%;
					border-spacing: 0;
					border: 1px solid #d2d6d9;
					border-collapse: collapse;
					}

					table.frame td#right {
					text-align: right;
					padding: 10px;
					}

					td#left, td#right {
					background: #d2d6d9;
					}

					table td#content {
					border-top: 10px solid #00137F;
					}

					#content {
					padding: 10px 40px 20px 40px;
					}

					h1, h2, h3, h4, h5 {
					color: #00137F;
					font-weight: bold;
					}

					h1 {
					font-size: 1.5em;
					margin-top: 4pt;
					margin-bottom: 0pt;
					font-weight: bold;
					}

					h2 {
					font-size: 1.4em;
					margin-top: 8pt;
					margin-bottom: 0pt;
					font-weight: bold;
					}

					h3 {
					font-size: 1.3em;
					margin-top: 8pt;
					margin-bottom: 0pt;
					font-weight: bold;
					}

					h4 {
					font-size: 1.2em;
					margin-top: 6pt;
					margin-bottom: 0pt;
					font-weight: bold;
					}

					h5 {
					font-size: 1.1em;
					font-weight: bold;
					margin-top: 6pt;
					margin-bottom: 0pt;
					}

					p {
					padding: 0px 0 8px 0;
					}


					td {
					vertical-align: top;
					padding-right: 8pt;
					}

					th {
					vertical-align: top;
					text-align: left;
					font-style: normal;
					font-weight: normal;
					white-space: nowrap;
					padding-right: 24pt;
					}

					.error {
					font-weight: bold;
					color: #FF0000;
					}

					th.indented {
					padding-left: 1em;
					}

					th, td {
					padding-bottom: 2pt;
					}

					td.ProperCapitalization {
					text-transform: capitalize;
					}
				</style>
			</head>
			<body>
				<table>
					<tr>
						<th colspan="2">
							<h2>
								1. Validation summary
							</h2>
						</th>
					</tr>
					<tr>
						<th>
							Subject
						</th>
						<td colspan="2">
							<xsl:value-of select="Subject" />
						</td>
					</tr>
					<tr>
						<th>
							Message-Id
						</th>
						<td colspan="2">
							<xsl:value-of select="MessageId" />
						</td>
					</tr>
					<tr>
						<th>
							Transport system
						</th>
						<td>
							<xsl:choose>
								<xsl:when test="MessageType = 'LegallyCompliant'">
									<xsl:text>De-Mail</xsl:text>
								</xsl:when>
								<xsl:when test="MessageType = 'WebPortal'">
									<xsl:text>Web Portal</xsl:text>
								</xsl:when>
								<xsl:otherwise>
									<xsl:choose>
										<xsl:when test="TransportSecurity/Protocol = 'None'">
											<xsl:text>Internet (unsecured)</xsl:text>
										</xsl:when>
										<xsl:otherwise>
											<xsl:text>Internet (secured)</xsl:text>
										</xsl:otherwise>
									</xsl:choose>
								</xsl:otherwise>
							</xsl:choose>
						</td>
					</tr>
					<tr>
						<th>
							Result of the signature validation
						</th>
						<td colspan="2">
							<xsl:choose>
								<xsl:when test="count(SignatureValidations/*) &gt; 0 and WasValidationSuccessful = 'true'">
									<span class="Success">Success</span>
								</xsl:when>
								<xsl:when test="count(SignatureValidations/*) = 0">
									<xsl:text>The mail is not digitally signed</xsl:text>
								</xsl:when>
								<xsl:otherwise>
									<span class="Error">Failed</span>
								</xsl:otherwise>
							</xsl:choose>
						</td>
					</tr>
					<tr>
						<th>
							Validation time
						</th>
						<td colspan="2">
							<xsl:value-of select="extensions:FormatDateTime(ValidationTime, 'MM/dd/yyyy hh:mm:ss tt')" />
						</td>
					</tr>
					<tr>
						<th>
							Validated by
						</th>
						<td colspan="2">
							<xsl:value-of select="ValidatedBy" />
						</td>
					</tr>
					<tr>
						<th colspan="2">
							<h2>
								2. Detailed validation report
							</h2>
						</th>
					</tr>
					<tr>
						<th colspan="2">
							<h3>
								2.1 Transport security
							</h3>
						</th>
					</tr>
					<xsl:choose>
						<xsl:when test="MessageType = 'WebPortal'">
							<tr>
								<th colspan="2">The mail was transferred securely via the Web Portal.</th>
							</tr>
						</xsl:when>
						<xsl:when test="TransportSecurity/Protocol = 'None'">
							<tr>
								<td colspan="2">The mail was received via an unencrypted connection.</td>
							</tr>
						</xsl:when>
						<xsl:otherwise>
							<tr>
								<td>Protocol</td>
								<td>
									<xsl:choose>
										<xsl:when test="TransportSecurity/Protocol = 'SSL2'">SSL 2.0</xsl:when>
										<xsl:when test="TransportSecurity/Protocol = 'SSL3'">SSL 3.0</xsl:when>
										<xsl:when test="TransportSecurity/Protocol = 'Tls'">TLS 1.0</xsl:when>
										<xsl:when test="TransportSecurity/Protocol = 'Tls11'">TLS 1.1</xsl:when>
										<xsl:when test="TransportSecurity/Protocol = 'Tls12'">TLS 1.2</xsl:when>
									</xsl:choose>
								</td>
							</tr>
							<tr>
								<td>Cipher algorithm</td>
								<td>
									<xsl:choose>
										<xsl:when test="TransportSecurity/Cipher/@Algorithm = 'Des'">DES</xsl:when>
										<xsl:when test="TransportSecurity/Cipher/@Algorithm = 'Rc2'">RC2</xsl:when>
										<xsl:when test="TransportSecurity/Cipher/@Algorithm = 'TripleDes'">Triple DES</xsl:when>
										<xsl:when test="TransportSecurity/Cipher/@Algorithm = 'Aes128'">AES-CBC (128 Bit)</xsl:when>
										<xsl:when test="TransportSecurity/Cipher/@Algorithm = 'Aes192'">AES-CBC (192 Bit)</xsl:when>
										<xsl:when test="TransportSecurity/Cipher/@Algorithm = 'Aes256'">AES-CBC (256 Bit)</xsl:when>
										<xsl:when test="TransportSecurity/Cipher/@Algorithm = 'Aes128Gcm'">AES-GCM (128 Bit)</xsl:when>
										<xsl:when test="TransportSecurity/Cipher/@Algorithm = 'Aes256Gcm'">AES-GCM (256 Bit)</xsl:when>
										<xsl:when test="TransportSecurity/Cipher/@Algorithm = 'Des'">DES</xsl:when>
										<xsl:when test="TransportSecurity/Cipher/@Algorithm = 'Rc4'">RC4</xsl:when>
									</xsl:choose>
								</td>
							</tr>
							<tr>
								<td>Hash algorithm</td>
								<td>
									<xsl:choose>
										<xsl:when test="TransportSecurity/Hash/@Algorithm = 'Sha1'">SHA-1</xsl:when>
										<xsl:when test="TransportSecurity/Hash/@Algorithm = 'Sha256'">SHA-256</xsl:when>
										<xsl:when test="TransportSecurity/Hash/@Algorithm = 'Sha384'">SHA-384</xsl:when>
										<xsl:when test="TransportSecurity/Hash/@Algorithm = 'Sha512'">SHA-512</xsl:when>
										<xsl:when test="TransportSecurity/Hash/@Algorithm = 'Md5'">MD5</xsl:when>
									</xsl:choose>
								</td>
							</tr>
							<tr>
								<td>Key exchange algorithm</td>
								<td>
									<xsl:choose>
										<xsl:when test="TransportSecurity/KeyExchange/@Algorithm = 'RsaSign'">RSA public-key signature</xsl:when>
										<xsl:when test="TransportSecurity/KeyExchange/@Algorithm = 'RsaKeyX'">RSA public-key exchange</xsl:when>
										<xsl:when test="TransportSecurity/KeyExchange/@Algorithm = 'DiffieHellman'">Diffie Hellman ephemeral key exchange</xsl:when>
										<xsl:when test="TransportSecurity/KeyExchange/@Algorithm = 'DiffieHellmanEllipticKey'">
											Diffie Hellman ephemeral key exchange with elliptic curve P-<xsl:value-of select="TransportSecurity/KeyExchange/@Strength"/>
										</xsl:when>
									</xsl:choose>
								</td>
							</tr>
							<xsl:choose>
								<xsl:when test="TransportSecurity/ClientCertificate/Signer != ''">
									<tr>
										<th colspan="2">Identity of the server sending the message</th>
									</tr>
									<tr>
										<th class="indented">Subject</th>
										<td>
											<xsl:value-of select="TransportSecurity/ClientCertificate/Signer" />
										</td>
									</tr>
									<tr>
										<th class="indented">Issued by</th>
										<td>
											<xsl:value-of select="TransportSecurity/ClientCertificate/Issuer" />
										</td>
									</tr>
									<tr>
										<th class="indented">Validity</th>
										<td>
											<xsl:text>From&#160;</xsl:text>
											<xsl:value-of select="extensions:FormatDateTime(TransportSecurity/ClientCertificate/ValidFrom, 'MM/dd/yyyy hh:mm:ss tt')" />
											<xsl:text>&#160;to&#160;</xsl:text>
											<xsl:value-of select="extensions:FormatDateTime(TransportSecurity/ClientCertificate/ValidTo, 'MM/dd/yyyy hh:mm:ss tt')" />
										</td>
									</tr>
									<tr>
										<th class="indented">Serial number</th>
										<td>
											<xsl:value-of select="TransportSecurity/ClientCertificate/CertificateSerialNumber" />
										</td>
									</tr>
								</xsl:when>
								<xsl:otherwise>
									<tr>
										<th>Identity of the server sending the message</th>
										<th>The client did not provide a client certificate</th>
									</tr>
								</xsl:otherwise>
							</xsl:choose>
						</xsl:otherwise>
					</xsl:choose>
					<tr>
						<th colspan="2">
							<h3>
								2.2 Validation result
							</h3>
						</th>
					</tr>
					<xsl:choose>
						<xsl:when test="count(SignatureValidations/*) &gt; 0">
							<xsl:apply-templates select="SignatureValidations/*" />
							<tr>
								<td colspan="2">
									<h4>Validation steps performed</h4>
								</td>
							</tr>
							<tr>
								<th>
									Integrity check
								</th>
								<td>
									<span class="success">Performed</span>
								</td>
							</tr>
							<tr>
								<th>
									Certificate chain validation
								</th>
								<td>
									<span class="success">Performed</span>
								</td>
							</tr>
							<tr>
								<th>
									Revocation check
								</th>
								<td>
									<span class="success">Performed</span>
								</td>
							</tr>
						</xsl:when>
						<xsl:otherwise>
							<tr>
								<th colspan="2">No detailed results are available because the mail is not digitally signed.</th>
							</tr>
						</xsl:otherwise>
					</xsl:choose>

					<tr>
						<th colspan="2">
							<h3>
								2.3 Decryption result
							</h3>
						</th>
					</tr>
					<xsl:choose>
						<xsl:when test="count(ContentDecryptions/*) &gt; 0">
							<xsl:apply-templates select="ContentDecryptions/*" />
						</xsl:when>
						<xsl:when test="MessageType = 'LegallyCompliant'">
							<tr>
								<th colspan="2">The mail was transferred securely via the De-Mail system.</th>
							</tr>
						</xsl:when>
						<xsl:when test="MessageType = 'WebPortal'">
							<tr>
								<th colspan="2">The mail was transferred securely via the Web Portal.</th>
							</tr>
						</xsl:when>
						<xsl:otherwise>
							<tr>
								<th colspan="2">The mail was transmitted unencrypted.</th>
							</tr>
						</xsl:otherwise>
					</xsl:choose>

					<tr>
						<th colspan="2">
							<h3>
								2.4 De-Mail
							</h3>
						</th>
					</tr>
					<xsl:choose>
						<xsl:when test="count(DeMail/*) &gt; 0">
							<xsl:apply-templates select="DeMail/*" />
						</xsl:when>
						<xsl:otherwise>
							<tr>
								<th colspan="2">The mail was not sent through the De-Mail network.</th>
							</tr>
						</xsl:otherwise>
					</xsl:choose>
				</table>
			</body>
		</html>
	</xsl:template>
	<xsl:template match="PgpSignatureValidation">
		<tr>
			<th>
				<h4>
					<xsl:text>2.2.</xsl:text>
					<xsl:value-of select="position()"/>
					<xsl:text>&#160;PGP signature</xsl:text>
				</h4>
			</th>
		</tr>
		<tr>
			<th>
				Validation result
			</th>
			<td colspan="2">
				<xsl:choose>
					<xsl:when test="IsMessageUnaltered = 'true'">
						<span class="success">Success</span>
						<br />
						<xsl:text>The content of this message has not been altered after it was signed.</xsl:text>
					</xsl:when>
					<xsl:otherwise>
						<span class="error">Failed</span>
						<br />
						<xsl:text>The content of this message has possibly been altered.</xsl:text>
					</xsl:otherwise>
				</xsl:choose>
			</td>
		</tr>
		<tr>
			<th>
				<h4>
					Signatures
				</h4>
			</th>
		</tr>
		<xsl:apply-templates select="Signers" />
	</xsl:template>
	<xsl:template match="SMimeSignatureValidation">
		<tr>
			<th>
				<h4>
					<xsl:text>2.2.</xsl:text>
					<xsl:value-of select="position()"/>
					<xsl:text>&#160;S/MIME signature</xsl:text>
				</h4>
			</th>
		</tr>
		<tr>
			<th>
				Validation result
			</th>
			<td colspan="2">
				<xsl:choose>
					<xsl:when test="IsMessageUnaltered = 'true'">
						<span class="success">Success</span>
						<br />
						<xsl:text>The content of this message has not been altered after it was signed.</xsl:text>
					</xsl:when>
					<xsl:otherwise>
						<span class="error">Failed</span>
						<br />
						<xsl:text>The content of this message has possibly been altered.</xsl:text>
					</xsl:otherwise>
				</xsl:choose>
			</td>
		</tr>
		<tr>
			<th>
				<h4>
					Signing persons
				</h4>
			</th>
		</tr>
		<xsl:apply-templates select="Signers" />
	</xsl:template>
	<xsl:template match="PgpSigner[ValidationResult != 'SignatureKeyMissing']">
		<tr>
			<th colspan="2">
				<h5>
					<xsl:value-of select="Identity" />
				</h5>
			</th>
		</tr>
		<tr>
			<th>
				Signature status
			</th>
			<td colspan="2">
				<xsl:apply-templates select="ValidationResult" mode="PGP" />
			</td>
		</tr>
		<tr>
			<th>
				Creation date
			</th>
			<td colspan="2">
				<xsl:value-of select="extensions:FormatDateTime(CreationDate, 'MM/dd/yyyy hh:mm:ss tt')" />
			</td>
		</tr>
		<tr>
			<th>
				Expiration date
			</th>
			<td colspan="2">
				<xsl:choose>
					<xsl:when test="ExpirationDate/text() != ''">
						<xsl:value-of select="extensions:FormatDateTime(ExpirationDate, 'MM/dd/yyyy hh:mm:ss tt')" />
					</xsl:when>
					<xsl:otherwise>
						<xsl:text>Never</xsl:text>
					</xsl:otherwise>
				</xsl:choose>
			</td>
		</tr>
		<tr>
			<th>
				Hash algorithm
			</th>
			<td colspan="2">
				<xsl:apply-templates select="HashAlgorithm" />
			</td>
		</tr>
	</xsl:template>
	<xsl:template match="PgpSigner[ValidationResult = 'SignatureKeyMissing']">
		<tr>
			<th colspan="2">
				<h5>
					Unknown signer
				</h5>
			</th>
		</tr>
		<tr>
			<td colspan="2">
				<xsl:text>The PGP key of this signer could not be found. As a result, this signature validation is inconclusive. The missing key has the id </xsl:text>
				<xsl:value-of select="KeyId"/>
				<xsl:text>. Please contact the sender of the message and request this PGP key.</xsl:text>
			</td>
		</tr>
	</xsl:template>
	<xsl:template match="ValidationResult" mode="PGP">
		<xsl:choose>
			<xsl:when test="text() = 'Valid'">
				<span class="success">The signature is valid.</span>
			</xsl:when>
			<xsl:when test="text() = 'Invalid'">
				<span class="error">The signature is invalid.</span>
			</xsl:when>
			<xsl:when test="text() = 'UnkownSignatureAlgorithm'">
				<span class="error">The signature algorithm is unknown.</span>
			</xsl:when>
		</xsl:choose>
	</xsl:template>
	<xsl:template match="HashAlgorithm">
		<xsl:choose>
			<xsl:when test="text() = 'MD5'">
				<xsl:text>MD5</xsl:text>
			</xsl:when>
			<xsl:when test="text() = 'Sha1'">
				<xsl:text>SHA-1</xsl:text>
			</xsl:when>
			<xsl:when test="text() = 'Sha256'">
				<xsl:text>SHA-256</xsl:text>
			</xsl:when>
			<xsl:when test="text() = 'Sha384'">
				<xsl:text>SHA-384</xsl:text>
			</xsl:when>
			<xsl:when test="text() = 'Sha512'">
				<xsl:text>SHA-512</xsl:text>
			</xsl:when>
			<xsl:when test="text() = 'RipeMD160'">
				<xsl:text>RIPE-MD 160bit</xsl:text>
			</xsl:when>
			<xsl:when test="text() = 'Sha224'">
				<xsl:text>SHA-224</xsl:text>
			</xsl:when>
		</xsl:choose>
	</xsl:template>

	<xsl:template match="SignatureSigner">
		<tr>
			<th colspan="2">
				<h5>
					<xsl:value-of select="Signer" />
				</h5>
			</th>
		</tr>
		<tr>
			<th>Certificate status</th>
			<td colspan="2">
				<xsl:choose>
					<xsl:when test="CertificateStatus/Status[1]/text() = 'NoError'">
						<span class="success">Valid</span>
						<br />
						<xsl:text>The certificate has been successfully validated.</xsl:text>
					</xsl:when>
					<xsl:otherwise>
						<span class="error">Invalid</span>
						<br />
						<xsl:text>The following errors occurred during the validation of the certificate:</xsl:text>
						<xsl:for-each select="CertificateStatus/Status">
							<li>
								<xsl:choose>
									<xsl:when test="text() = 'NotTimeValid'">The certificate is expired or not yet valid.</xsl:when>
									<xsl:when test="text() = 'NotTimeNested'">The validity period of the certificate and its root certificate are not nested.</xsl:when>
									<xsl:when test="text() = 'Revoked'">One of the certificates in the chain has been revoked.</xsl:when>
									<xsl:when test="text() = 'NotSignatureValid'">One of the certificates in the chain has an invalid signature.</xsl:when>
									<xsl:when test="text() = 'NotValidForUsage'">The key usage is not valid with the certificate.</xsl:when>
									<xsl:when test="text() = 'UntrustedRoot'">The certificate chain is invalid because the root certificate is not trusted.</xsl:when>
									<xsl:when test="text() = 'RevocationStatusUnknown'">The revocation status of the certificate can not be determined. This can be due to the fact that the certificate revocation list (CRL) is unavailable or not reachable.</xsl:when>
									<xsl:when test="text() = 'Cyclic'">The certificate chain could not be built because of a cyclic dependency.</xsl:when>
									<xsl:when test="text() = 'InvalidExtension'">The certificate chain is invalid because one of the certificates has an invalid extension.</xsl:when>
									<xsl:when test="text() = 'InvalidPolicyConstraints'">The certificate chain is invalid due to an invalid policy constraint.</xsl:when>
									<xsl:when test="text() = 'InvalidBasicConstraints'">The certificate chain is invalid due to an invalid basic constraints.</xsl:when>
									<xsl:when test="text() = 'InvalidNameConstraints'">The certificate chain is invalid due to an invalid name constraint.</xsl:when>
									<xsl:when test="text() = 'HasNotSupportedNameConstraint'">The certificate does not have a supported name constant or has a name constant that is unsupported.</xsl:when>
									<xsl:when test="text() = 'HasNotDefinedNameConstraint'">The certificate has an undefined name constant.</xsl:when>
									<xsl:when test="text() = 'HasNotPermittedNameConstraint'">The certificate has an impermissible name constraint.</xsl:when>
									<xsl:when test="text() = 'HasExcludedNameConstraint'">The certificate chain is invalid because a certificate has excluded a name constraint.</xsl:when>
									<xsl:when test="text() = 'PartialChain'">The certificate chain could not be built up to a root certificate.</xsl:when>
									<xsl:when test="text() = 'CtlNotTimeValid'">The certificate trust list (CTL) is not valid because of an invalid time value, such as one that indicates that the CTL has expired.</xsl:when>
									<xsl:when test="text() = 'CtlNotSignatureValid'">The certificate trust list (CTL) contains an invalid signature.</xsl:when>
									<xsl:when test="text() = 'CtlNotValidForUsage'">The certificate trust list (CTL) is not valid for this use.</xsl:when>
									<xsl:when test="text() = 'OfflineRevocation'">The online certificate revocation list (CRL) the certificate chain relies on is currently offline</xsl:when>
									<xsl:when test="text() = 'NoIssuanceChainPolicy'">There is no certificate policy extension in the certificate. This error would occur if a group policy has specified that all certificates must have a certificate policy.</xsl:when>
								</xsl:choose>
							</li>
						</xsl:for-each>
					</xsl:otherwise>
				</xsl:choose>
			</td>
		</tr>
		<tr>
			<th>
				Signer mail address
			</th>
			<td colspan="2">
				<xsl:value-of select="SignerMailAddress" />
			</td>
		</tr>
		<tr>
			<th>
				Certificate issuer
			</th>
			<td colspan="2">
				<xsl:value-of select="Issuer" />
			</td>
		</tr>
		<tr>
			<th>
				Signature time
			</th>
			<td colspan="2">
				<xsl:value-of select="extensions:FormatDateTime(SignatureTime, 'MM/dd/yyyy hh:mm:ss tt')" />
			</td>
		</tr>
		<tr>
			<th>
				Signature algorithm
			</th>
			<td colspan="2">
				<xsl:value-of select="MessageIntegrityCheckAlgorithm" />
			</td>
		</tr>
		<tr>
			<th>
				Signature type
			</th>
			<td colspan="2">
				<xsl:choose>
					<xsl:when test="SignatureType = 'Originator'">
						<xsl:text>Personal signature</xsl:text>
					</xsl:when>
					<xsl:when test="SignatureType = 'DomainSig'">
						<xsl:text>Domain signature</xsl:text>
					</xsl:when>
					<xsl:when test="SignatureType = 'Reviewer'">
						<xsl:text>Reviewer signature</xsl:text>
					</xsl:when>
					<xsl:otherwise>
						<xsl:text>Unknown (</xsl:text>
						<xsl:value-of select="SignatureType" />
						<xsl:text>)</xsl:text>
					</xsl:otherwise>
				</xsl:choose>
			</td>
		</tr>
		<tr>
			<th>
				Certificate serial number
			</th>
			<td colspan="2">
				<xsl:value-of select="CertificateSerialNumber" />
			</td>
		</tr>
		<tr>
			<th>
				Certificate validity
			</th>
			<td colspan="2">
				<xsl:text>From&#160;</xsl:text>
				<xsl:value-of select="extensions:FormatDateTime(ValidFrom, 'MM/dd/yyyy hh:mm:ss tt')" />
				<xsl:text>&#160;to&#160;</xsl:text>
				<xsl:value-of select="extensions:FormatDateTime(ValidTo, 'MM/dd/yyyy hh:mm:ss tt')" />
			</td>
		</tr>
	</xsl:template>
	<xsl:template match="SMimeDecryption">
		<tr>
			<th>
				<h4>
					<xsl:text>2.3.</xsl:text>
					<xsl:value-of select="position()"/>
					<xsl:text>&#160;S/MIME decryption</xsl:text>
				</h4>
			</th>
		</tr>
		<tr>
			<th>
				Encryption algorithm
			</th>
			<td colspan="2">
				<xsl:choose>
					<xsl:when test="EncryptionAlgorithm = 'Des'">
						<xsl:text>DES</xsl:text>
					</xsl:when>
					<xsl:when test="EncryptionAlgorithm = 'TripleDes'">
						<xsl:text>Triple DES</xsl:text>
					</xsl:when>
					<xsl:when test="EncryptionAlgorithm = 'RC2_40'">
						<xsl:text>RC-2</xsl:text>
					</xsl:when>
					<xsl:when test="EncryptionAlgorithm = 'RC2_64'">
						<xsl:text>RC-2</xsl:text>
					</xsl:when>
					<xsl:when test="EncryptionAlgorithm = 'RC2_128'">
						<xsl:text>RC-2</xsl:text>
					</xsl:when>
					<xsl:when test="EncryptionAlgorithm = 'Aes128'">
						<xsl:text>AES-CBC</xsl:text>
					</xsl:when>
					<xsl:when test="EncryptionAlgorithm = 'Aes192'">
						<xsl:text>AES-CBC</xsl:text>
					</xsl:when>
					<xsl:when test="EncryptionAlgorithm = 'Aes256'">
						<xsl:text>AES-CBC</xsl:text>
					</xsl:when>
					<xsl:when test="EncryptionAlgorithm = 'Aes128Gcm'">
						<xsl:text>AES-GCM</xsl:text>
					</xsl:when>
					<xsl:when test="EncryptionAlgorithm = 'Aes256Gcm'">
						<xsl:text>AES-GCM</xsl:text>
					</xsl:when>
				</xsl:choose>
			</td>
		</tr>
		<tr>
			<th>
				Key length
			</th>
			<td colspan="2">
				<xsl:choose>
					<xsl:when test="EncryptionAlgorithm = 'Des'">
						<xsl:value-of select="KeyLength"/>
						<xsl:text>&#160;Bit</xsl:text>
					</xsl:when>
					<xsl:when test="EncryptionAlgorithm = 'TripleDes'">
						<xsl:text>168 Bit</xsl:text>
					</xsl:when>
					<xsl:when test="EncryptionAlgorithm = 'RC2_40'">
						<xsl:text>40 Bit</xsl:text>
					</xsl:when>
					<xsl:when test="EncryptionAlgorithm = 'RC2_64'">
						<xsl:text>64 Bit</xsl:text>
					</xsl:when>
					<xsl:when test="EncryptionAlgorithm = 'RC2_128'">
						<xsl:text>128 Bit</xsl:text>
					</xsl:when>
					<xsl:when test="EncryptionAlgorithm = 'Aes128'">
						<xsl:text>128 Bit</xsl:text>
					</xsl:when>
					<xsl:when test="EncryptionAlgorithm = 'Aes192'">
						<xsl:text>192 Bit</xsl:text>
					</xsl:when>
					<xsl:when test="EncryptionAlgorithm = 'Aes256'">
						<xsl:text>256 Bit</xsl:text>
					</xsl:when>
					<xsl:when test="EncryptionAlgorithm = 'Aes128Gcm'">
						<xsl:text>128 Bit</xsl:text>
					</xsl:when>
					<xsl:when test="EncryptionAlgorithm = 'Aes256Gcm'">
						<xsl:text>256 Bit</xsl:text>
					</xsl:when>
				</xsl:choose>
			</td>
		</tr>
	</xsl:template>
	<xsl:template match="PgpDecryption">
		<tr>
			<th>
				<h4>
					<xsl:text>2.3.</xsl:text>
					<xsl:value-of select="position()"/>
					<xsl:text>&#160;PGP decryption</xsl:text>
				</h4>
			</th>
		</tr>
		<tr>
			<th>
				Encryption algorithm
			</th>
			<td colspan="2">
				<xsl:choose>
					<xsl:when test="EncryptionAlgorithm = 'Des'">
						<xsl:text>DES</xsl:text>
					</xsl:when>
					<xsl:when test="EncryptionAlgorithm = 'TripleDes'">
						<xsl:text>Triple DES</xsl:text>
					</xsl:when>
					<xsl:when test="EncryptionAlgorithm = 'RC2_40'">
						<xsl:text>RC-2</xsl:text>
					</xsl:when>
					<xsl:when test="EncryptionAlgorithm = 'RC2_64'">
						<xsl:text>RC-2</xsl:text>
					</xsl:when>
					<xsl:when test="EncryptionAlgorithm = 'RC2_128'">
						<xsl:text>RC-2</xsl:text>
					</xsl:when>
					<xsl:when test="EncryptionAlgorithm = 'Aes128'">
						<xsl:text>AES</xsl:text>
					</xsl:when>
					<xsl:when test="EncryptionAlgorithm = 'Aes192'">
						<xsl:text>AES</xsl:text>
					</xsl:when>
					<xsl:when test="EncryptionAlgorithm = 'Aes256'">
						<xsl:text>AES</xsl:text>
					</xsl:when>
					<xsl:when test="EncryptionAlgorithm = 'Blowfish'">
						<xsl:text>Blowfish</xsl:text>
					</xsl:when>
					<xsl:when test="EncryptionAlgorithm = 'Idea'">
						<xsl:text>Idea</xsl:text>
					</xsl:when>
					<xsl:when test="EncryptionAlgorithm = 'Twofish256'">
						<xsl:text>Twofish256</xsl:text>
					</xsl:when>
					<xsl:when test="EncryptionAlgorithm = 'Cast5'">
						<xsl:text>AES</xsl:text>
					</xsl:when>
				</xsl:choose>
			</td>
		</tr>
		<tr>
			<th>
				Key length
			</th>
			<td colspan="2">
				<xsl:choose>
					<xsl:when test="EncryptionAlgorithm = 'Des'">
						<xsl:value-of select="KeyLength"/>
						<xsl:text>&#160;Bit</xsl:text>
					</xsl:when>
					<xsl:when test="EncryptionAlgorithm = 'TripleDes'">
						<xsl:text>168 Bit</xsl:text>
					</xsl:when>
					<xsl:when test="EncryptionAlgorithm = 'RC2_40'">
						<xsl:text>40 Bit</xsl:text>
					</xsl:when>
					<xsl:when test="EncryptionAlgorithm = 'RC2_64'">
						<xsl:text>64 Bit</xsl:text>
					</xsl:when>
					<xsl:when test="EncryptionAlgorithm = 'RC2_128'">
						<xsl:text>128 Bit</xsl:text>
					</xsl:when>
					<xsl:when test="EncryptionAlgorithm = 'Aes128'">
						<xsl:text>128 Bit</xsl:text>
					</xsl:when>
					<xsl:when test="EncryptionAlgorithm = 'Aes192'">
						<xsl:text>192 Bit</xsl:text>
					</xsl:when>
					<xsl:when test="EncryptionAlgorithm = 'Aes256'">
						<xsl:text>256 Bit</xsl:text>
					</xsl:when>
					<xsl:when test="EncryptionAlgorithm = 'Blowfish'">
						<xsl:text>128 Bit</xsl:text>
					</xsl:when>
					<xsl:when test="EncryptionAlgorithm = 'Idea'">
						<xsl:text>128 Bit</xsl:text>
					</xsl:when>
					<xsl:when test="EncryptionAlgorithm = 'Twofish256'">
						<xsl:text>256 Bit</xsl:text>
					</xsl:when>
					<xsl:when test="EncryptionAlgorithm = 'Cast5'">
						<xsl:text>128 Bit</xsl:text>
					</xsl:when>
				</xsl:choose>
			</td>
		</tr>
	</xsl:template>
	<xsl:template match="MalwareInformation">
		<xsl:call-template name="DeMailHeader">
			<xsl:with-param name="Heading" select="'DeMail malware message'" />
		</xsl:call-template>
		<tr>
			<td>Type:</td>
			<td>
				<xsl:choose>
					<xsl:when test="Notification">
						<xsl:text>Notification</xsl:text>
					</xsl:when>
					<xsl:otherwise>
						<xsl:text>Acknowledgement</xsl:text>
					</xsl:otherwise>
				</xsl:choose>
			</td>
		</tr>
		<xsl:call-template name="DeMailStandardInfos" />
	</xsl:template>
	<xsl:template match="IdentificationMessage">
		<xsl:call-template name="DeMailHeader">
			<xsl:with-param name="Heading" select="'DeMail identification message'" />
		</xsl:call-template>
		<xsl:call-template name="DeMailStandardInfos" />
		<xsl:call-template name="DeMailDeliveryOptions" />
	</xsl:template>
	<xsl:template name="DeMailDeliveryOptions">
		<tr>
			<th>Applied delivery options</th>
			<td>
				<xsl:call-template name="FormatList">
					<xsl:with-param name="Nodes" select="IsPrivate[text()='true'] | IsAuthoritative[text()='true']"	 />
				</xsl:call-template>
			</td>
		</tr>
	</xsl:template>
	<xsl:template match="Notification">
		<xsl:call-template name="DeMailHeader">
			<xsl:with-param name="Heading" select="'Notification'" />
		</xsl:call-template>
		<xsl:call-template name="DeMailStandardInfos" />
	</xsl:template>
	<xsl:template match="DeMail/ConfirmationMessage">
		<xsl:call-template name="DeMailHeader">
			<xsl:with-param name="Heading" select="'Confirmation message'" />
		</xsl:call-template>
		<xsl:call-template name="DeMailStandardInfos" />
		<xsl:call-template name="DeMailDeliveryOptions" />
	</xsl:template>

	<xsl:template match="DeMail/InboundMessage">
		<xsl:call-template name="DeMailHeader">
			<xsl:with-param name="Heading" select="'Standard message'" />
		</xsl:call-template>
		<xsl:call-template name="DeMailStandardInfos" />
		<xsl:call-template name="DeMailDeliveryOptions" />
		<tr>
			<th>Requested confirmations</th>
			<td>
				<xsl:call-template name="FormatList">
					<xsl:with-param name="Nodes" select="IsConfirmationOfDispatchRequested[text()='true'] | IsConfirmationOfReceiptRequested[text()='true'] | IsConfirmationOfRetrieveRequested[text()='true']"	 />
				</xsl:call-template>
			</td>
		</tr>
	</xsl:template>
	<xsl:template match="IsConfirmationOfDispatchRequested">
		<xsl:text>Dispatch</xsl:text>
	</xsl:template>
	<xsl:template match="IsConfirmationOfReceiptRequested">
		<xsl:text>Receipt</xsl:text>
	</xsl:template>
	<xsl:template match="IsConfirmationOfRetrieveRequested">
		<xsl:text>Retrieve</xsl:text>
	</xsl:template>
	<xsl:template name="DeMailHeader">
		<xsl:param name="Heading" />
		<tr>
			<th>Message type</th>
			<td>
				<xsl:value-of select="$Heading" />
			</td>
		</tr>
	</xsl:template>

	<xsl:template name="DeMailStandardInfos">
		<tr>
			<th>Sender</th>
			<td colspan="1">
				<xsl:value-of select="Sender"/>
			</td>

		</tr>
		<tr>
			<th>Intended recipients</th>
			<td colspan="1">
				<xsl:apply-templates select="ChosenRecipients"/>
			</td>

		</tr>
		<tr>
			<th>Actual recipients</th>
			<td colspan="1">
				<xsl:apply-templates select="ActualRecipients"/>
			</td>

		</tr>
		<tr>
			<th>Authentication level</th>
			<td colspan="1">
				<xsl:choose>
					<xsl:when test="AuthenticationLevel = 'High'">High</xsl:when>
					<xsl:otherwise>Normal</xsl:otherwise>
				</xsl:choose>
			</td>

		</tr>
		<tr>
			<th>Authentication mechanism</th>
			<td colspan="1" class="ProperCapitalization">
				<xsl:choose>
					<xsl:when test="AuthenticationMechanism != ''">
						<xsl:value-of select="AuthenticationMechanism"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:text>Unknown</xsl:text>
					</xsl:otherwise>
				</xsl:choose>
			</td>

		</tr>
		<tr>
			<th>Message Id</th>
			<td colspan="1">
				<xsl:value-of select="MessageId"/>
			</td>

		</tr>
		<tr>
			<th>Originator Provider</th>
			<td colspan="1">
				<xsl:value-of select="OriginatorProvider"/>
			</td>

		</tr>
		<tr>
			<th>Signed by the provider</th>
			<xsl:choose>
				<xsl:when test="SignatureCertificate/*">
					<td>Yes</td>
				</xsl:when>
				<xsl:otherwise>
					<td>No</td>
				</xsl:otherwise>
			</xsl:choose>
		</tr>
		<xsl:if test="SignatureCertificate/*">
			<tr>
				<th class="indented">Subject</th>
				<td>
					<xsl:value-of select="SignatureCertificate/Subject" />
				</td>
			</tr>
			<tr>
				<th class="indented">Issued by</th>
				<td>
					<xsl:value-of select="SignatureCertificate/Issuer" />
				</td>
			</tr>
			<tr>
				<th class="indented">Validity</th>
				<td>
					<xsl:text>From&#160;</xsl:text>
					<xsl:value-of select="extensions:FormatDateTime(SignatureCertificate/ValidFrom, 'MM/dd/yyyy hh:mm:ss tt')" />
					<xsl:text>&#160;to&#160;</xsl:text>
					<xsl:value-of select="extensions:FormatDateTime(SignatureCertificate/ValidTo, 'MM/dd/yyyy hh:mm:ss tt')" />
				</td>
			</tr>
		</xsl:if>
	</xsl:template>
	<xsl:template match="IsPrivate">
		<xsl:text>Private</xsl:text>
	</xsl:template>
	<xsl:template match="IsAuthoritative">
		<xsl:text>Authoritative</xsl:text>
	</xsl:template>
	<xsl:template name="FormatList">
		<xsl:param name="Nodes" />
		<xsl:param name="FallbackText" select="'None'" />
		<xsl:choose>
			<xsl:when test="count($Nodes) &gt; 0">
				<xsl:for-each select="$Nodes">
					<xsl:apply-templates select="." />
					<xsl:if test="position() != last()">,&#160;</xsl:if>
				</xsl:for-each>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="$FallbackText"/>
			</xsl:otherwise>
		</xsl:choose>

	</xsl:template>

	<xsl:template match="ChosenRecipients | ActualRecipients">
		<xsl:if test="count(ToRecipients/Recipient) &gt; 0">
			<tr>
				<th class="indented">To</th>
				<xsl:apply-templates select="ToRecipients" />
			</tr>
		</xsl:if>
		<xsl:if test="count(CCRecipients/Recipient) &gt; 0">
			<tr>
				<th class="indented">CC</th>
				<xsl:apply-templates select="CCRecipients" />
			</tr>
		</xsl:if>
		<xsl:if test="count(BccRecipients/Recipient) &gt; 0">
			<tr>
				<th class="indented">BCC</th>
				<xsl:apply-templates select="BccRecipients" />
			</tr>
		</xsl:if>
	</xsl:template>
	<xsl:template match="ToRecipients | CCRecipients | BccRecipients">
		<td>
			<xsl:for-each select="Recipient">
				<xsl:value-of select="."/>
				<xsl:if test="position() != last()">,&#160;</xsl:if>
			</xsl:for-each>
		</td>
	</xsl:template>
</xsl:stylesheet>
