@Test void matchShouldReturnRecipientsWhenEncodedTextMatchesContentRule() throws Exception { Dlp dlp = new Dlp( asRulesLoaderFor( JAMES_APACHE_ORG_DOMAIN, DlpDomainRules.builder() .contentRule(Id.of("match content"), Pattern.compile("poné")) .build())); FakeMail mail = FakeMail .builder() .name("name") .sender(OTHER_AT_JAMES) .recipient(RECIPIENT1) .mimeMessage(MimeMessageBuilder .mimeMessageBuilder() .setSubject("you know what ?") .setSender(RECIPIENT1.asString()) .setText("I bought a poné", "text/plain; charset=" + StandardCharsets.ISO_8859_1.name())) .build(); assertThat(dlp.match(mail)).containsOnly(RECIPIENT1); }
@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();  }