|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.mailet.GenericMailet org.apache.james.transport.mailets.smime.SMIMEAbstractSign
public abstract class SMIMEAbstractSign
Abstract mailet providing common SMIME signature services.
It can be subclassed to make authoring signing mailets simple.
By extending it and overriding one or more of the following methods a new behaviour can
be quickly created without the author having to address any issue other than
the relevant one:
initDebug()
, setDebug(boolean)
and isDebug()
manage the debugging mode.initExplanationText()
, setExplanationText(java.lang.String)
and getExplanationText()
manage the text of
an attachment that will be added to explain the meaning of this server-side signature.initKeyHolder()
, setKeyHolder(org.apache.james.security.KeyHolder)
and getKeyHolder()
manage the KeyHolder
object that will
contain the keys and certificates and will do the crypto work.initPostmasterSigns()
, setPostmasterSigns(boolean)
and isPostmasterSigns()
determines whether messages originated by the Postmaster will be signed or not.initRebuildFrom()
, setRebuildFrom(boolean)
and isRebuildFrom()
determines whether the "From:" header will be rebuilt to neutralize the wrong behaviour of
some MUAs like Microsoft Outlook Express.initSignerName()
, setSignerName(java.lang.String)
and getSignerName()
manage the name
of the signer to be shown in the explanation text.isOkToSign(org.apache.mailet.Mail)
controls whether the mail can be signed or not.getWrapperBodyPart(org.apache.mailet.Mail)
returns the massaged MimeBodyPart
that will be signed, or null if the message has to be signed "as is".Handles the following init parameters:
true
some useful information is logged.
The default is false
.KeyStore
full file name.KeyStore
password.
If given, it is used to check the integrity of the keystore data,
otherwise, if null, the integrity of the keystore is not checked.KeyStore.getKey(java.lang.String, char[])
.
The default is to look for the first and only alias in the keystore;
if zero or more than one is found a KeyStoreException
is thrown.KeyStore
password.
At least one of the passwords must be provided.KeyStore.getDefaultType()
.true
the message will be signed even if the sender is the Postmaster.
The default is false
.true
will modify the "From:" header.
For more info see isRebuildFrom()
.
The default is false
.getReplacedExplanationText(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
):
[signerName]
, [signerAddress]
, [reversePath]
, [headers]
.
It should be included in the signature.
The actual presentation of the text depends on the specific concrete mailet subclass:
see for example SMIMESign
.
The default is to not have any explanation text.
Constructor Summary | |
---|---|
SMIMEAbstractSign()
|
Method Summary | |
---|---|
protected boolean |
fromAddressSameAsReverse(Mail mail)
Utility method that checks if there is at least one address in the "From:" header same as the reverse-path. |
protected abstract java.lang.String[] |
getAllowedInitParameters()
Gets the expected init parameters. |
java.lang.String |
getExplanationText()
Getter for property explanationText. |
protected KeyHolder |
getKeyHolder()
Getter for property keyHolder. |
protected java.lang.String |
getMessageHeaders(javax.mail.internet.MimeMessage message)
Utility method for obtaining a string representation of the Message's headers |
protected java.lang.String |
getReplacedExplanationText(java.lang.String explanationText,
java.lang.String signerName,
java.lang.String signerAddress,
java.lang.String reversePath,
java.lang.String headers)
Prepares the explanation text making substitutions in the explanationText template string. |
java.lang.String |
getSignerName()
Getter for property signerName. |
protected abstract javax.mail.internet.MimeBodyPart |
getWrapperBodyPart(Mail mail)
Creates the MimeBodyPart that will be signed. |
void |
init()
Mailet initialization routine. |
protected void |
initDebug()
Initializer for property debug. |
protected void |
initExplanationText()
Initializer for property explanationText. |
protected void |
initKeyHolder()
Initializer for property keyHolder. |
protected void |
initPostmasterSigns()
Initializer for property postmasterSigns. |
protected void |
initRebuildFrom()
Initializer for property rebuildFrom. |
protected void |
initSignerName()
Initializer for property signerName. |
boolean |
isDebug()
Getter for property debug. |
protected boolean |
isOkToSign(Mail mail)
Checks if the mail can be signed. |
boolean |
isPostmasterSigns()
Getter for property postmasterSigns. |
boolean |
isRebuildFrom()
Getter for property rebuildFrom. |
void |
service(Mail mail)
Service does the hard work, and signs |
void |
setDebug(boolean debug)
Setter for property debug. |
void |
setExplanationText(java.lang.String explanationText)
Setter for property explanationText. |
protected void |
setKeyHolder(KeyHolder keyHolder)
Setter for property keyHolder. |
void |
setPostmasterSigns(boolean postmasterSigns)
Setter for property postmasterSigns. |
void |
setRebuildFrom(boolean rebuildFrom)
Setter for property rebuildFrom. |
void |
setSignerName(java.lang.String signerName)
Setter for property signerName. |
Methods inherited from class org.apache.mailet.GenericMailet |
---|
destroy, getInitParameter, getInitParameter, getInitParameterNames, getMailetConfig, getMailetContext, getMailetInfo, getMailetName, init, log, log |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SMIMEAbstractSign()
Method Detail |
---|
protected abstract java.lang.String[] getAllowedInitParameters()
protected void initDebug()
public boolean isDebug()
public void setDebug(boolean debug)
debug
- New value of property debug.protected void initExplanationText()
public java.lang.String getExplanationText()
public void setExplanationText(java.lang.String explanationText)
explanationText
- New value of property explanationText.protected void initKeyHolder() throws java.lang.Exception
java.lang.Exception
protected KeyHolder getKeyHolder()
protected
instead of public
for security reasons.
protected void setKeyHolder(KeyHolder keyHolder)
protected
instead of public
for security reasons.
keyHolder
- New value of property keyHolder.protected void initPostmasterSigns()
public boolean isPostmasterSigns()
public void setPostmasterSigns(boolean postmasterSigns)
postmasterSigns
- New value of property postmasterSigns.protected void initRebuildFrom() throws javax.mail.MessagingException
javax.mail.MessagingException
public boolean isRebuildFrom()
The modification is as follows:
assuming that the signer mail address in the signer certificate is trusted-server@xxx.com>
and that From: "John Smith"
If the "ReplyTo:" header is missing or empty it will be set to the original "From:" header.
Such modification is necessary to achieve a correct behaviour with some mail clients (e.g. Microsoft Outlook Express).
public void setRebuildFrom(boolean rebuildFrom)
rebuildFrom
- New value of property rebuildFrom.protected void initSignerName()
public java.lang.String getSignerName()
public void setSignerName(java.lang.String signerName)
signerName
- New value of property signerName.public void init() throws javax.mail.MessagingException
init
in class GenericMailet
javax.mail.MessagingException
- if an exception occurs that interrupts the mailet's normal operationpublic void service(Mail mail) throws javax.mail.MessagingException
service
in interface Mailet
service
in class GenericMailet
mail
- the mail to sign
javax.mail.MessagingException
- if a problem arises signing the mailprotected boolean isOkToSign(Mail mail) throws javax.mail.MessagingException
Checks if the mail can be signed.
Rules:
isPostmasterSigns()
returns true
mail
- The mail object to check.
javax.mail.MessagingException
protected abstract javax.mail.internet.MimeBodyPart getWrapperBodyPart(Mail mail) throws javax.mail.MessagingException, java.io.IOException
MimeBodyPart
that will be signed.
For example, may attach a text file explaining the meaning of the signature,
or an XML file containing information that can be checked by other MTAs.
mail
- The mail to massage.
javax.mail.MessagingException
java.io.IOException
protected final boolean fromAddressSameAsReverse(Mail mail)
mail
- The mail to check.
protected final java.lang.String getMessageHeaders(javax.mail.internet.MimeMessage message) throws javax.mail.MessagingException
message
- The message to extract the headers from.
javax.mail.MessagingException
protected final java.lang.String getReplacedExplanationText(java.lang.String explanationText, java.lang.String signerName, java.lang.String signerAddress, java.lang.String reversePath, java.lang.String headers)
explanationText
- The template string for the explanation text.signerName
- The string that will replace the [signerName]
pattern.signerAddress
- The string that will replace the [signerAddress]
pattern.reversePath
- The string that will replace the [reversePath]
pattern.headers
- The string that will replace the [headers]
pattern.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |