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;
}
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);
}
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;
}
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;
}
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;
}
Aggregations