use of org.nhindirect.gateway.smtp.james.mailet.NHINDSecurityAndTrustMailet in project nhin-d by DirectProject.
the class NHINDSecurityAndTrustMailet_functionalTest method testProcessOutgoingMessageEndToEnd_tamperedRoutingHeaders_rejectPolicyOn_assertRejected.
public void testProcessOutgoingMessageEndToEnd_tamperedRoutingHeaders_rejectPolicyOn_assertRejected() throws Exception {
new TestPlan() {
protected String getMessageToProcess() throws Exception {
return TestUtils.readMessageResource("PlainOutgoingMessage.txt");
}
@Override
protected Mailet getMailet(String configurationFileName) throws Exception {
Mailet retVal = null;
String configfile = TestUtils.getTestConfigFile(configurationFileName);
Map<String, String> params = new HashMap<String, String>();
if (configurationFileName.startsWith("http"))
params.put("ConfigURL", ConfigServiceRunner.getConfigServiceURL());
else
params.put("ConfigURL", "file://" + configfile);
params.put(SecurityAndTrustMailetOptions.REJECT_ON_ROUTING_TAMPER, "true");
retVal = new NHINDSecurityAndTrustMailet();
MailetConfig mailetConfig = new MockMailetConfig(params, "NHINDSecurityAndTrustMailet");
retVal.init(mailetConfig);
return retVal;
}
protected void performInner() throws Exception {
// encrypt
String originalMessage = getMessageToProcess();
MimeMessage msg = EntitySerializer.Default.deserialize(originalMessage);
// add an MDN request
msg.setHeader(MDNStandard.Headers.DispositionNotificationTo, msg.getHeader(MailStandard.Headers.From, ","));
MockMail theMessage = new MockMail(msg);
Mailet theMailet = getMailet("ValidConfig.xml");
theMailet.service(theMessage);
assertNotNull(theMessage);
assertNotNull(theMessage.getMessage());
msg = theMessage.getMessage();
assertTrue(SMIMEStandard.isEncrypted(msg));
assertEquals(theMessage.getState(), Mail.TRANSPORT);
// decrypt
theMailet = getMailet("ValidConfigStateLine.txt");
theMessage = new MockMail(msg);
final MailAddress validAddress = new MailAddress(msg.getRecipients(RecipientType.TO)[0].toString());
final MailAddress injectedAttackAddress = new MailAddress("externUser2@starugh-stateline.com");
theMessage.setRecipients(Arrays.asList(validAddress, injectedAttackAddress));
theMailet.service(theMessage);
// rejected and ghosted
assertEquals(Mail.GHOST, theMessage.getState());
}
}.perform();
}
Aggregations