@Test void matchShouldReturnRecipientsWhenRulesMatchesAQuotedPrintableSender() throws Exception { Dlp dlp = new Dlp( asRulesLoaderFor( JAMES_APACHE_ORG_DOMAIN, DlpDomainRules.builder() .senderRule(Id.of("id1"), Pattern.compile("Benoît")) .build())); MimeMessageBuilder meaninglessText = MimeMessageBuilder .mimeMessageBuilder() .addFrom("=?ISO-8859-1?Q?Beno=EEt_TELLIER?=") .setSubject("=?ISO-8859-1?Q?I_just_bought_a_pon=E9?=") .setText("Meaningless text"); FakeMail mail = FakeMail .builder() .name("name") .sender(OTHER_AT_JAMES) .recipient(RECIPIENT2) .mimeMessage(meaninglessText) .build(); assertThat(dlp.match(mail)).containsOnly(RECIPIENT2); }
@Override public Collection<MailAddress> match(Mail mail) { Optional<DLPConfigurationItem.Id> firstMatchingRuleId = findFirstMatchingRule(mail); if (firstMatchingRuleId.isPresent()) { DLPConfigurationItem.Id ruleId = firstMatchingRuleId.get(); setRuleIdAsMailAttribute(mail, ruleId); return mail.getRecipients(); } return ImmutableList.of(); }
Dlp extends GenericMatcher { @Override public Collection<MailAddress> match(Mail mail) { Optional<DLPConfigurationItem.Id> firstMatchingRuleId = findFirstMatchingRule(mail); if (firstMatchingRuleId.isPresent()) { DLPConfigurationItem.Id ruleId = firstMatchingRuleId.get(); setRuleIdAsMailAttribute(mail, ruleId); return mail.getRecipients(); } return ImmutableList.of(); } }
Dlp extends GenericMatcher { @Override public Collection<MailAddress> match(Mail mail) { Optional<DLPConfigurationItem.Id> firstMatchingRuleId = findFirstMatchingRule(mail); if (firstMatchingRuleId.isPresent()) { DLPConfigurationItem.Id ruleId = firstMatchingRuleId.get(); setRuleIdAsMailAttribute(mail, ruleId); return mail.getRecipients(); } return ImmutableList.of(); } @VisibleForTesting  Dlp(DlpRulesLoader rulesLoader); @Inject  Dlp(DLPConfigurationStore configurationStore); }
Dlp extends GenericMatcher { @Override public Collection<MailAddress> match(Mail mail) { Optional<DLPConfigurationItem.Id> firstMatchingRuleId = findFirstMatchingRule(mail); if (firstMatchingRuleId.isPresent()) { DLPConfigurationItem.Id ruleId = firstMatchingRuleId.get(); setRuleIdAsMailAttribute(mail, ruleId); return mail.getRecipients(); } return ImmutableList.of(); } @VisibleForTesting  Dlp(DlpRulesLoader rulesLoader); @Inject  Dlp(DLPConfigurationStore configurationStore); @Override Collection<MailAddress> match(Mail mail); @Override String getMatcherInfo(); }
Dlp extends GenericMatcher { @Override public Collection<MailAddress> match(Mail mail) { Optional<DLPConfigurationItem.Id> firstMatchingRuleId = findFirstMatchingRule(mail); if (firstMatchingRuleId.isPresent()) { DLPConfigurationItem.Id ruleId = firstMatchingRuleId.get(); setRuleIdAsMailAttribute(mail, ruleId); return mail.getRecipients(); } return ImmutableList.of(); } @VisibleForTesting  Dlp(DlpRulesLoader rulesLoader); @Inject  Dlp(DLPConfigurationStore configurationStore); @Override Collection<MailAddress> match(Mail mail); @Override String getMatcherInfo();  }