Search in sources :

Example 6 with EContentTransferEncoding

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));
    }
}
Also used : EContentTransferEncoding(com.helger.mail.cte.EContentTransferEncoding) MimeBodyPart(javax.mail.internet.MimeBodyPart) Test(org.junit.Test)

Aggregations

EContentTransferEncoding (com.helger.mail.cte.EContentTransferEncoding)6 MimeBodyPart (javax.mail.internet.MimeBodyPart)4 MIC (com.helger.as2lib.crypto.MIC)2 AS2NoModuleException (com.helger.as2lib.processor.AS2NoModuleException)2 AS2ComponentNotFoundException (com.helger.as2lib.session.AS2ComponentNotFoundException)2 DataHandler (javax.activation.DataHandler)2 AS2Client (com.helger.as2lib.client.AS2Client)1 AS2ClientRequest (com.helger.as2lib.client.AS2ClientRequest)1 AS2ClientResponse (com.helger.as2lib.client.AS2ClientResponse)1 AS2ClientSettings (com.helger.as2lib.client.AS2ClientSettings)1 ECompressionType (com.helger.as2lib.crypto.ECompressionType)1 ECryptoAlgorithmCrypt (com.helger.as2lib.crypto.ECryptoAlgorithmCrypt)1 ECryptoAlgorithmSign (com.helger.as2lib.crypto.ECryptoAlgorithmSign)1 AS2DispositionException (com.helger.as2lib.disposition.AS2DispositionException)1 DispositionOptions (com.helger.as2lib.disposition.DispositionOptions)1 AS2Exception (com.helger.as2lib.exception.AS2Exception)1 WrappedAS2Exception (com.helger.as2lib.exception.WrappedAS2Exception)1 AS2Message (com.helger.as2lib.message.AS2Message)1 IMessageMDN (com.helger.as2lib.message.IMessageMDN)1 AS2InvalidParameterException (com.helger.as2lib.params.AS2InvalidParameterException)1