- java.lang.Object
-
- org.shredzone.acme4j.smime.email.ResponseGenerator
-
public class ResponseGenerator extends Object
A helper for creating an email response to the "challenge" email.According to RFC-8823, the response email must be DKIM signed. This is not done by the response generator, but must be done by the outbound MTA.
- Since:
- 2.12
- See Also:
- RFC 8823
-
-
Constructor Summary
Constructors Constructor Description ResponseGenerator(EmailProcessor processor)
Creates a newResponseGenerator
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description jakarta.mail.Message
generateResponse()
Generates the response email.jakarta.mail.Message
generateResponse(jakarta.mail.Session session)
Generates the response email.ResponseGenerator
withFooter(String footer)
Adds a custom footer to the response mail body.ResponseGenerator
withGenerator(ResponseBodyGenerator generator)
Sets aResponseBodyGenerator
that is used for generating a response body.ResponseGenerator
withHeader(String header)
Adds a custom header to the response mail body.
-
-
-
Constructor Detail
-
ResponseGenerator
public ResponseGenerator(EmailProcessor processor)
Creates a newResponseGenerator
.- Parameters:
processor
-EmailProcessor
of the challenge email.
-
-
Method Detail
-
withHeader
public ResponseGenerator withHeader(@Nullable String header)
Adds a custom header to the response mail body.There is no need to set a header, since the response email is usually not read by humans. If a header is set, it must contain ASCII encoded plain text.
- Parameters:
header
- Header text to be used, ornull
if no header is to be used.- Returns:
- itself
-
withFooter
public ResponseGenerator withFooter(@Nullable String footer)
Adds a custom footer to the response mail body.There is no need to set a footer, since the response email is usually not read by humans. If a footer is set, it must contain ASCII encoded plain text.
- Parameters:
footer
- Footer text to be used, ornull
if no footer is to be used.- Returns:
- itself
-
withGenerator
public ResponseGenerator withGenerator(@Nullable ResponseBodyGenerator generator)
Sets aResponseBodyGenerator
that is used for generating a response body.Use this generator to individually style the email body, for example to use a multipart body. However, be aware that the response mail is evaluated by a machine, and usually not read by humans, so the body should be designed as simple as possible.
The default body generator will just concatenate the header, the armored key authorization body, and the footer.
- Parameters:
generator
-ResponseBodyGenerator
to be used, ornull
to use the default one.- Returns:
- itself
-
generateResponse
public jakarta.mail.Message generateResponse() throws jakarta.mail.MessagingException
Generates the response email.A simple default mail session is used for generation.
- Returns:
- Generated
Message
. - Throws:
jakarta.mail.MessagingException
- Since:
- 2.16
-
generateResponse
public jakarta.mail.Message generateResponse(jakarta.mail.Session session) throws jakarta.mail.MessagingException
Generates the response email.Note that according to RFC-8823, this message must have a valid DKIM or S/MIME signature. This is not done here, but usually performed by the outbound MTA.
- Parameters:
session
-javax.mail
Session
to be used for this mail.- Returns:
- Generated
Message
. - Throws:
jakarta.mail.MessagingException
-
-