Search in sources :

Example 1 with ContentType

use of javax.mail.internet.ContentType in project camel by apache.

the class MimeMultipartDataFormat method getContentType.

private ContentType getContentType(Exchange exchange) throws ParseException {
    String contentTypeStr = ExchangeHelper.getContentType(exchange);
    if (contentTypeStr == null) {
        contentTypeStr = DEFAULT_CONTENT_TYPE;
    }
    ContentType contentType = new ContentType(contentTypeStr);
    String contentEncoding = ExchangeHelper.getContentEncoding(exchange);
    // add a charset parameter for text subtypes
    if (contentEncoding != null && contentType.match("text/*")) {
        contentType.setParameter("charset", MimeUtility.mimeCharset(contentEncoding));
    }
    return contentType;
}
Also used : ContentType(javax.mail.internet.ContentType)

Example 2 with ContentType

use of javax.mail.internet.ContentType in project quickstarts by jboss-switchyard.

the class InternalCustomProcessor method process.

@Override
public void process(Exchange exchange) throws Exception {
    String newFileName = "internal-switchyard.jpeg";
    Image input = exchange.getIn().getBody(Image.class);
    if (input == null) {
        throw new RuntimeException("Image for resize not found!");
    }
    ContentType type = new ContentType("image/jpeg");
    exchange.getOut().addAttachment(newFileName, new DataHandler(input, type.getBaseType()));
    exchange.getOut().setBody(newFileName);
}
Also used : ContentType(javax.mail.internet.ContentType) DataHandler(javax.activation.DataHandler) Image(java.awt.Image)

Example 3 with ContentType

use of javax.mail.internet.ContentType in project rest.li by linkedin.

the class MIMETestUtils method createTinyDataSource.

//Now create the javax data sources:
private static final MimeBodyPart createTinyDataSource() {
    try {
        //Tiny body.
        final String body = "1";
        final MimeBodyPart dataPart = new MimeBodyPart();
        final ContentType contentType = new ContentType(TEXT_PLAIN_CONTENT_TYPE);
        dataPart.setContent(body, contentType.getBaseType());
        return dataPart;
    } catch (Exception exception) {
        Assert.fail();
    }
    return null;
}
Also used : ContentType(javax.mail.internet.ContentType) ByteString(com.linkedin.data.ByteString) MimeBodyPart(javax.mail.internet.MimeBodyPart) IOException(java.io.IOException)

Example 4 with ContentType

use of javax.mail.internet.ContentType in project nhin-d by DirectProject.

the class SMIMECryptographerImpl method sign.

/**
     * Signs an entity with the provided certificates.
     * @param message The entity that will be signed.
     * @param signingCertificates The certificates used to sign the message.
     * @return A signed entity that consists of a multipart/signed entity containing the original entity and a message signature. 
     */
public SignedEntity sign(MimeEntity entity, Collection<X509Certificate> signingCertificates) {
    if (entity == null) {
        throw new IllegalArgumentException();
    }
    // Serialize message out as ASCII encoded...
    byte[] messageBytes = EntitySerializer.Default.serializeToBytes(entity);
    MimeMultipart mm = this.createSignatureEntity(messageBytes, signingCertificates);
    SignedEntity retVal = null;
    try {
        retVal = new SignedEntity(new ContentType(mm.getContentType()), mm);
    } catch (ParseException e) {
        throw new MimeException(MimeError.InvalidHeader, e);
    }
    return retVal;
}
Also used : ContentType(javax.mail.internet.ContentType) MimeMultipart(javax.mail.internet.MimeMultipart) MimeException(org.nhindirect.stagent.mail.MimeException) ParseException(javax.mail.internet.ParseException)

Example 5 with ContentType

use of javax.mail.internet.ContentType in project nhin-d by DirectProject.

the class SignedEntity method createContentType.

/**
     * Creates a MIME content type based on the digest algorithm.
     * @param digestAlgorithm The digest algorithm used to generate the message signature.
     * @return a MIME content type based on the digest algorithm.
     */
static ContentType createContentType(DigestAlgorithm digestAlgorithm) {
    ContentType contentType = null;
    try {
        contentType = new ContentType(SMIMEStandard.MultiPartType_Signed);
        contentType.setParameter(SMIMEStandard.MICAlgorithmKey, SMIMEStandard.toString(digestAlgorithm));
    } catch (ParseException e) {
    }
    return contentType;
}
Also used : ContentType(javax.mail.internet.ContentType) ParseException(javax.mail.internet.ParseException)

Aggregations

ContentType (javax.mail.internet.ContentType)40 IOException (java.io.IOException)17 MessagingException (javax.mail.MessagingException)14 MimeBodyPart (javax.mail.internet.MimeBodyPart)14 ByteString (com.linkedin.data.ByteString)10 MimeMessage (javax.mail.internet.MimeMessage)9 MimeMultipart (javax.mail.internet.MimeMultipart)9 InputStream (java.io.InputStream)8 ParseException (javax.mail.internet.ParseException)8 MimePart (javax.mail.internet.MimePart)6 PackageException (com.axway.ats.action.objects.model.PackageException)5 DataHandler (javax.activation.DataHandler)5 BodyPart (javax.mail.BodyPart)5 NoSuchMimePackageException (com.axway.ats.action.objects.model.NoSuchMimePackageException)4 NoSuchMimePartException (com.axway.ats.action.objects.model.NoSuchMimePartException)4 PublicAtsApi (com.axway.ats.common.PublicAtsApi)4 RestRequestBuilder (com.linkedin.r2.message.rest.RestRequestBuilder)3 ZComponent (com.zimbra.common.calendar.ZCalendar.ZComponent)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 URI (java.net.URI)3