|
7 | 7 | import jakarta.mail.util.ByteArrayDataSource; |
8 | 8 | import org.jetbrains.annotations.NotNull; |
9 | 9 | import org.jetbrains.annotations.Nullable; |
| 10 | +import org.simplejavamail.api.email.config.DkimConfig; |
10 | 11 | import org.simplejavamail.api.internal.clisupport.model.Cli; |
11 | 12 | import org.simplejavamail.api.internal.clisupport.model.CliBuilderApiType; |
12 | 13 | import org.simplejavamail.api.mailer.config.Pkcs12Config; |
13 | 14 |
|
14 | | -import java.io.ByteArrayInputStream; |
15 | 15 | import java.io.File; |
16 | 16 | import java.io.InputStream; |
17 | 17 | import java.net.URL; |
|
20 | 20 | import java.util.Date; |
21 | 21 | import java.util.List; |
22 | 22 | import java.util.Map; |
| 23 | +import java.util.Set; |
23 | 24 | import java.util.regex.Pattern; |
24 | 25 |
|
25 | 26 | import static java.util.regex.Pattern.compile; |
26 | 27 |
|
27 | | - |
28 | 28 | /** |
29 | 29 | * Fluent interface Builder for populating {@link Email} instances. An instance of this builder can only be obtained through one of the builder |
30 | 30 | * starters on {@link EmailStartingBuilder}. |
|
37 | 37 | public interface EmailPopulatingBuilder { |
38 | 38 |
|
39 | 39 | /** |
40 | | - * Regular Expression to find all {@code <img src="...">} entries in an HTML document.It needs to cater for various things, like more whitespaces including newlines on any place, HTML is not case |
41 | | - * sensitive and there can be arbitrary text between "IMG" and "SRC" like IDs and other things. |
| 40 | + * Regular Expression to find all {@code <img src="...">} entries in an HTML document.It needs to cater for various things, like more whitespaces including newlines on any |
| 41 | + * place, HTML is not case-sensitive and there can be arbitrary text between "IMG" and "SRC" like IDs and other things. |
42 | 42 | */ |
43 | 43 | Pattern IMG_SRC_PATTERN = compile("(?<imageTagStart><[Ii][Mm][Gg]\\s*[^>]*?\\s+[Ss][Rr][Cc]\\s*=\\s*[\"'])(?<src>[^\"']+?)(?<imageSrcEnd>[\"'])"); |
44 | 44 |
|
@@ -1137,55 +1137,34 @@ public interface EmailPopulatingBuilder { |
1137 | 1137 | * Delegates to {@link #withAttachment(String, DataSource)} for each attachment. |
1138 | 1138 | */ |
1139 | 1139 | EmailPopulatingBuilder withAttachments(@NotNull List<AttachmentResource> attachments); |
1140 | | - |
1141 | | - /** |
1142 | | - * Delegates to {@link #signWithDomainKey(InputStream, String, String)} with a {@link ByteArrayInputStream} wrapped around the prodived {@code |
1143 | | - * dkimPrivateKey} data. |
1144 | | - * <p> |
1145 | | - * <strong>Note:</strong> this only works in combination with the {@value org.simplejavamail.internal.modules.DKIMModule#NAME}. |
1146 | | - */ |
1147 | | - @Cli.ExcludeApi(reason = "delegated method is an identical api from CLI point of view") |
1148 | | - @SuppressWarnings("unused") |
1149 | | - EmailPopulatingBuilder signWithDomainKey(@NotNull byte[] dkimPrivateKey, @NotNull String signingDomain, @NotNull String dkimSelector); |
1150 | | - |
1151 | | - /** |
1152 | | - * Delegates to {@link #signWithDomainKey(InputStream, String, String)} with a {@link ByteArrayInputStream} wrapped around the prodived {@code |
1153 | | - * dkimPrivateKey} string converted to UTF_8 byte array. |
1154 | | - * <p> |
1155 | | - * <strong>Note:</strong> this only works in combination with the {@value org.simplejavamail.internal.modules.DKIMModule#NAME}. |
1156 | | - */ |
1157 | | - @Cli.ExcludeApi(reason = "delegated method is an identical api from CLI point of view") |
1158 | | - @SuppressWarnings("unused") |
1159 | | - EmailPopulatingBuilder signWithDomainKey(@NotNull String dkimPrivateKey, @NotNull String signingDomain, @NotNull String dkimSelector); |
1160 | | - |
| 1140 | + |
1161 | 1141 | /** |
1162 | 1142 | * Primes this email for signing with a DKIM domain key. Actual signing is done when sending using a <code>Mailer</code>. |
1163 | 1143 | * <p> |
1164 | 1144 | * <strong>Note:</strong> this only works in combination with the {@value org.simplejavamail.internal.modules.DKIMModule#NAME}. |
1165 | 1145 | * |
1166 | | - * @param dkimPrivateKeyInputStream De key content used to sign for the sending party. |
1167 | | - * @param signingDomain The domain being authorized to send. |
1168 | | - * @param dkimSelector Additional domain specifier. |
| 1146 | + * @param dkimPrivateKey De key content used to sign for the sending party. |
| 1147 | + * @param signingDomain The domain being authorized to send. |
| 1148 | + * @param dkimSelector Additional domain specifier. |
| 1149 | + * @param excludedHeadersFromDkimDefaultSigningList Allows you to exclude headers being signed, as might be the case when another mail transfer agent. For example, Amazon SES doesn't want Message-ID and Date Headers to be signed as they have internal mechanisms to handle these headers. |
1169 | 1150 | * |
1170 | 1151 | * @see <a href="https://postmarkapp.com/guides/dkim">more on DKIM 1</a> |
1171 | 1152 | * @see <a href="https://github.com/markenwerk/java-utils-mail-dkim">more on DKIM 2</a> |
1172 | 1153 | * @see <a href="http://www.gettingemaildelivered.com/dkim-explained-how-to-set-up-and-use-domainkeys-identified-mail-effectively">more on DKIM 3</a> |
1173 | 1154 | * @see <a href="https://en.wikipedia.org/wiki/DomainKeys_Identified_Mail">more on DKIM 4</a> |
1174 | 1155 | * @see <a href="https://github.com/bbottema/dkim-verify">List of explanations all tags in a <em>DKIM-Signature</em> header</a> |
1175 | | - * @see #signWithDomainKey(byte[], String, String) |
1176 | | - * @see #signWithDomainKey(String, String, String) |
1177 | | - * @see #signWithDomainKey(File, String, String) |
| 1156 | + * @see #signWithDomainKey(DkimConfig) |
1178 | 1157 | */ |
1179 | | - EmailPopulatingBuilder signWithDomainKey(@NotNull InputStream dkimPrivateKeyInputStream, @NotNull String signingDomain, @NotNull String dkimSelector); |
1180 | | - |
| 1158 | + @SuppressWarnings("unused") |
| 1159 | + EmailPopulatingBuilder signWithDomainKey(@NotNull byte[] dkimPrivateKey, @NotNull String signingDomain, @NotNull String dkimSelector, @Nullable Set<String> excludedHeadersFromDkimDefaultSigningList); |
| 1160 | + |
1181 | 1161 | /** |
1182 | | - * As {@link #signWithDomainKey(InputStream, String, String)}, but with a File reference that is later read as {@code InputStream}. |
1183 | | - * <p> |
1184 | | - * <strong>Note:</strong> this only works in combination with the {@value org.simplejavamail.internal.modules.DKIMModule#NAME}. |
| 1162 | + * @see #signWithDomainKey(byte[], String, String, Set) |
1185 | 1163 | */ |
1186 | 1164 | @Cli.ExcludeApi(reason = "delegated method is an identical api from CLI point of view") |
1187 | | - EmailPopulatingBuilder signWithDomainKey(@NotNull File dkimPrivateKeyFile, @NotNull String signingDomain, @NotNull String dkimSelector); |
1188 | | - |
| 1165 | + @SuppressWarnings("unused") |
| 1166 | + EmailPopulatingBuilder signWithDomainKey(@NotNull DkimConfig dkimConfig); |
| 1167 | + |
1189 | 1168 | /** |
1190 | 1169 | * Signs this email with an <a href="https://tools.ietf.org/html/rfc5751">S/MIME</a> signature, so the receiving client |
1191 | 1170 | * can verify whether the email content was tampered with. |
@@ -1633,26 +1612,11 @@ public interface EmailPopulatingBuilder { |
1633 | 1612 | Map<String, Collection<String>> getHeaders(); |
1634 | 1613 |
|
1635 | 1614 | /** |
1636 | | - * @see #signWithDomainKey(InputStream, String, String) |
1637 | | - * @see #signWithDomainKey(byte[], String, String) |
1638 | | - * @see #signWithDomainKey(File, String, String) |
1639 | | - */ |
1640 | | - @Nullable |
1641 | | - byte[] getDkimPrivateKeyData(); |
1642 | | - |
1643 | | - /** |
1644 | | - * @see #signWithDomainKey(InputStream, String, String) |
1645 | | - * @see #signWithDomainKey(File, String, String) |
1646 | | - */ |
1647 | | - @Nullable |
1648 | | - String getDkimSigningDomain(); |
1649 | | - |
1650 | | - /** |
1651 | | - * @see #signWithDomainKey(InputStream, String, String) |
1652 | | - * @see #signWithDomainKey(File, String, String) |
| 1615 | + * @see #signWithDomainKey(DkimConfig) |
| 1616 | + * @see #signWithDomainKey(byte[], String, String, Set) |
1653 | 1617 | */ |
1654 | 1618 | @Nullable |
1655 | | - String getDkimSelector(); |
| 1619 | + DkimConfig getDkimConfig(); |
1656 | 1620 |
|
1657 | 1621 | /** |
1658 | 1622 | * @see #withDispositionNotificationTo() |
|
0 commit comments