use of javax.mail.internet.InternetHeaders in project raml-module-builder by folio-org.
the class DemoRamlRestTest method checkClientCode.
/**
* @param context
*/
private void checkClientCode(TestContext context) {
Async async = context.async(1);
log.info("checkClientCode test");
try {
MimeMultipart mmp = new MimeMultipart();
BodyPart bp = new MimeBodyPart(new InternetHeaders(), IOUtils.toByteArray(getClass().getClassLoader().getResourceAsStream("job.json")));
bp.setDisposition("form-data");
bp.setFileName("abc.raml");
BodyPart bp2 = new MimeBodyPart(new InternetHeaders(), IOUtils.toByteArray(getClass().getClassLoader().getResourceAsStream("job.json")));
bp2.setDisposition("form-data");
bp2.setFileName("abcd.raml");
log.debug("--- bp content --- " + bp.getContent());
mmp.addBodyPart(bp);
mmp.addBodyPart(bp2);
AdminClient aClient = new AdminClient("localhost", port, "abc", "abc", false);
aClient.postUploadmultipart(PersistMethod.SAVE, null, "abc", mmp, reply -> {
if (reply.statusCode() != 200) {
context.fail();
}
log.debug("checkClientCode statusCode 1 " + reply.statusCode());
String key;
try {
SecretKey sk = AES.generateSecretKey();
key = AES.convertSecretKeyToString(sk);
final String expected = AES.encryptPasswordAsBase64("abc", sk);
aClient.postGetPassword(key, reply2 -> {
reply2.bodyHandler(bodyHandler -> {
if (!expected.equals(bodyHandler.toString())) {
context.fail("expected : " + expected + " got " + bodyHandler.toString());
} else {
log.info("received expected password: " + expected);
aClient.getModuleStats(r -> {
r.bodyHandler(br -> {
log.info("received: " + br.toString());
});
async.countDown();
});
}
});
});
} catch (Exception e) {
log.error(e.getMessage(), e);
}
});
} catch (Exception e) {
log.error(e.getMessage(), e);
context.fail();
}
}
use of javax.mail.internet.InternetHeaders in project raml-module-builder by folio-org.
the class FileUploadsUtil method split.
private static MimeMultipart split(byte[] pattern, byte[] input, int sizeLimit) {
MimeMultipart mmp = new MimeMultipart();
int start = 0;
int pos = Bytes.indexOf(input, pattern);
int size = input.length;
int entryCount = 0;
ByteBuffer buffer = ByteBuffer.wrap(input);
while (pos != -1 && start < size) {
int end = pos + pattern.length;
if (entryCount != 0) {
// dont add the boundary itself - which is what you have in the first iteration
buffer.position(start);
// not a copy but points to the buffer
// used for the indexOf functionality to keep checking
// further on in the buffer - current pos -> end of buffer
byte[] tmpBuffer = buffer.slice().array();
// set limit - now that limit is set re-slice to only get the needed
// area -
buffer.limit(end);
try {
MimeBodyPart mbp = new MimeBodyPart(new InternetHeaders(), buffer.slice().array());
mmp.addBodyPart(mbp);
} catch (MessagingException e) {
log.error(e.getMessage(), e);
}
pos = Bytes.indexOf(tmpBuffer, pattern);
}
entryCount++;
start = end;
}
return mmp;
}
use of javax.mail.internet.InternetHeaders in project legacy-webos by JayCanuck.
the class ControlFile method addControlFile.
/**
* Add the control file to the tar file.
*/
private void addControlFile(TarOutputStream tar, PackageInfo info, PackageTarFile dataTar) throws IOException {
// setup the RFC822 formatted header used for package metadata.
final InternetHeaders headers = info.getControlHeaders();
final StringBuilder controlFile = new StringBuilder();
@SuppressWarnings("unchecked") final Enumeration<String> en = headers.getAllHeaderLines();
while (en.hasMoreElements()) {
controlFile.append(en.nextElement()).append('\n');
}
final TarEntry entry = standardEntry(CONTROL_FILE, UnixStandardPermissions.STANDARD_FILE_MODE, controlFile.length());
tar.putNextEntry(entry);
IOUtils.write(controlFile.toString(), tar);
tar.closeEntry();
}
use of javax.mail.internet.InternetHeaders in project logging-log4j2 by apache.
the class SmtpManager method getHeaders.
protected InternetHeaders getHeaders(final String contentType, final String encoding) {
final InternetHeaders headers = new InternetHeaders();
headers.setHeader("Content-Type", contentType + "; charset=UTF-8");
headers.setHeader("Content-Transfer-Encoding", encoding);
return headers;
}
use of javax.mail.internet.InternetHeaders in project nhin-d by DirectProject.
the class ReliableDispatchedNotificationProducer_produceTest method testCreateAckWithNoText.
public void testCreateAckWithNoText() throws Exception {
final MimeMessage msg = new MimeMessage(null, IOUtils.toInputStream(TestUtils.readMessageResource("PlainOutgoingMessage.txt")));
final NHINDAddressCollection recipients = getMailRecipients(msg);
final NotificationProducer prod = new ReliableDispatchedNotificationProducer(new NotificationSettings(true, "Local Direct Delivery Agent", ""));
final Collection<NotificationMessage> notifications = prod.produce(new Message(msg), recipients.toInternetAddressCollection());
assertNotNull(notifications);
for (NotificationMessage noteMsg : notifications) {
// assert that we removed the notification option from the headers as part of the fix of
// version 1.5.1
assertNull(noteMsg.getHeader(MDNStandard.Headers.DispositionNotificationOptions, ","));
final InternetHeaders headers = Notification.getNotificationFieldsAsHeaders(noteMsg);
assertEquals("", headers.getHeader(MDNStandard.DispositionOption_TimelyAndReliable, ","));
}
}
Aggregations