use of com.helger.mail.cte.EContentTransferEncoding in project as2-lib by phax.
the class BCCryptoHelperTest method testSignWithAllCTEs.
@Test
public void testSignWithAllCTEs() throws Exception {
final MimeBodyPart aPart = new MimeBodyPart();
aPart.setText("Hello world");
for (final EContentTransferEncoding eCTE : EContentTransferEncoding.values()) {
final MimeBodyPart aSigned = AS2Helper.getCryptoHelper().sign(aPart, (X509Certificate) PKE.getCertificate(), PKE.getPrivateKey(), ECryptoAlgorithmSign.DIGEST_SHA_512, true, false, false, eCTE);
assertNotNull(aSigned);
final String[] aContentTypes = aSigned.getHeader(CHttpHeader.CONTENT_TYPE);
assertNotNull(aContentTypes);
assertEquals(1, aContentTypes.length);
final String sContentType = aContentTypes[0];
final String sExpectedStart = "multipart/signed; protocol=\"application/pkcs7-signature\"; micalg=sha-512; \r\n\tboundary=\"----=_Part";
assertTrue(sContentType + " does not start with " + sExpectedStart, sContentType.startsWith(sExpectedStart));
}
}
Aggregations