org.apache.taglibs.mailer2
Class SignTag

java.lang.Object
  extended byjavax.servlet.jsp.tagext.TagSupport
      extended byjavax.servlet.jsp.tagext.BodyTagSupport
          extended byorg.apache.taglibs.mailer2.PartTag
              extended byorg.apache.taglibs.mailer2.MailTag
                  extended byorg.apache.taglibs.mailer2.SignTag
All Implemented Interfaces:
BodyTag, IterationTag, JspTag, Serializable, Tag
Direct Known Subclasses:
EncryptTag

public class SignTag
extends MailTag

JSP tag mt:sign is used to S/MIME sign a previously stored message.

Version:
2.0
Author:
Jeroen van Vianen
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.apache.taglibs.mailer2.MailTag
FROM, PASSWORD, PORT, SERVER, username, USERNAME, VERSION
 
Fields inherited from class org.apache.taglibs.mailer2.PartTag
log
 
Fields inherited from class javax.servlet.jsp.tagext.BodyTagSupport
bodyContent
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id, pageContext
 
Fields inherited from interface javax.servlet.jsp.tagext.BodyTag
EVAL_BODY_BUFFERED, EVAL_BODY_TAG
 
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAIN
 
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
SignTag()
          Default zero-arg constructor.
 
Method Summary
 int doEndTag()
           
 String getAlias()
          Returns the private key alias.
 String getKeystore()
          Get the keystore attribute.
 MimeMessage getMessage()
          Returns the javax.mail.internet.MimeMessage object to sign.
 String getStorepass()
          Returns the password to open the keystore.
 String getStoretype()
          Returns the type of keystore, e.g.
 KeyStore loadKeystore(String storeType, String keystoreFilename, String storepass)
          Load a keystore file.
 void release()
           
 void setAlias(String alias)
          Sets the alias of the private key to retrieve from the keystore.
 void setKeystore(String keystore)
          Sets the location of the keystore.
 void setMessage(MimeMessage message)
          Sets the message attribute.
 void setStorepass(String storepass)
          Sets the password to open the keystore.
 void setStoretype(String storetype)
          Sets the type of keystore.
protected  MimeMessage signMessage(MimeMessage message, X509Certificate cert, PrivateKey privateKey)
          Returns a signed message.
 
Methods inherited from class org.apache.taglibs.mailer2.MailTag
addRecipient, addReplyTo, doAfterBody, doStartTag, getBcc, getCc, getFrom, getImportance, getMimemessage, getPassword, getPort, getReplyto, getScope, getScopeType, getServer, getSession, getSessionObject, getSubject, getTo, getUsername, getVar, isBackground, setBackground, setBcc, setCc, setFrom, setImportance, setMimemessage, setPassword, setPort, setReplyto, setScope, setServer, setSession, setSubject, setTo, setUsername, setVar
 
Methods inherited from class org.apache.taglibs.mailer2.PartTag
addPart, constructMessage, getBody, getContentType, getEncoding, getHeaders, getParts, getType, setBody, setEncoding, setHeader, setType
 
Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport
doInitBody, getBodyContent, getPreviousOut, setBodyContent
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, resetCustomAttributes, setId, setPageContext, setParent, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.jsp.tagext.Tag
getParent, setPageContext, setParent
 

Constructor Detail

SignTag

public SignTag()
Default zero-arg constructor.

Method Detail

doEndTag

public int doEndTag()
             throws JspException
Specified by:
doEndTag in interface Tag
Overrides:
doEndTag in class MailTag
Throws:
JspException

signMessage

protected MimeMessage signMessage(MimeMessage message,
                                  X509Certificate cert,
                                  PrivateKey privateKey)
                           throws JspException
Returns a signed message.

Parameters:
message - The message to sign
cert - The certificate to use
privateKey - The private key to sign with
Returns:
A signed message
Throws:
JspException

release

public void release()
Specified by:
release in interface Tag
Overrides:
release in class MailTag

loadKeystore

public KeyStore loadKeystore(String storeType,
                             String keystoreFilename,
                             String storepass)
                      throws GeneralSecurityException,
                             IOException
Load a keystore file.

Parameters:
storeType - The type of keystore, e.g. "PKCS12", "JKS", etc.
keystoreFilename - The name of the keystore file
storepass - The password to open the keystore
Returns:
A KeyStore object
Throws:
GeneralSecurityException - if the keystore cannot be read
IOException - if the keystore cannot be found

getAlias

public String getAlias()
Returns the private key alias.

Returns:
The private key alias

setAlias

public void setAlias(String alias)
Sets the alias of the private key to retrieve from the keystore.

Parameters:
alias - The private key alias

getKeystore

public String getKeystore()
Get the keystore attribute.

Returns:
keystore attribute

setKeystore

public void setKeystore(String keystore)
Sets the location of the keystore.

Parameters:
keystore - The location of the keystore

getMessage

public MimeMessage getMessage()
Returns the javax.mail.internet.MimeMessage object to sign.

Returns:
The Message

setMessage

public void setMessage(MimeMessage message)
Sets the message attribute.

Parameters:
message - The Message to send

getStorepass

public String getStorepass()
Returns the password to open the keystore.

Returns:
The password

setStorepass

public void setStorepass(String storepass)
Sets the password to open the keystore.

Parameters:
storepass - The password

getStoretype

public String getStoretype()
Returns the type of keystore, e.g. "PKCS12", or "JKS".

Returns:
The keystore type

setStoretype

public void setStoretype(String storetype)
Sets the type of keystore.

Parameters:
storetype - The type of keystore


Copyright © 2004 Apache Software Foundation, http://jakarta.apache.org/taglibs