IAIK High-Level API
version 1.1

iaik.hlapi
Class SMimeDecrypterVerifier

java.lang.Object
  extended by iaik.hlapi.DecrypterVerifier
      extended by iaik.hlapi.SMimeDecrypterVerifier

public class SMimeDecrypterVerifier
extends DecrypterVerifier

This is a combined class for decrypting and verifying S/MIME messages. It supports encrypted only, signed only and signed and encrypted S/MIME messages.


Constructor Summary
SMimeDecrypterVerifier()
          Create a new object for decryption and/or verification of S/MIME messages.
 
Method Summary
 void dropDecryptionKeys()
          Release all references to any previously set decryption keys.
 String getCharacterSet()
          Get the character encoding (charset parameter) of the content.
 String getContentBoundary()
          Get the boundary string if the content data is a multipart MIME content.
 String getContentType()
          Get the media type and subtype of the content type for the signed MIME entity, e.g. text/plain.
 Map getHeaders()
          Get a reference to the map that contains all headers of the most recently parsed e-mail message.
 String getSender()
          Get the sender of this e-mail message from the header fields, which may be different to the signer of the message.
 Date getSigningTime()
          Get the signing time of this signed e-mail message or null if the message was unsigned or did not contain a signing time.
 String getSubject()
          Get the subject line of this e-mail message.
 InputStream process(InputStream in)
          Decrypt and/or verify the given data.
 void registerDecryptionKey(KeyAndCertificate decryptionKey)
          Register a key to be a decryption key for the associated certificate.
 
Methods inherited from class iaik.hlapi.DecrypterVerifier
process, verify
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SMimeDecrypterVerifier

public SMimeDecrypterVerifier()
Create a new object for decryption and/or verification of S/MIME messages.

Method Detail

registerDecryptionKey

public void registerDecryptionKey(KeyAndCertificate decryptionKey)
                           throws HlApiException
Description copied from class: DecrypterVerifier
Register a key to be a decryption key for the associated certificate. The application may call this method more than once to register multiple decryption keys. The decryption operation will select one of them automatically.

The certificate in the decryptionKey may be null. In this case, the decryption method will try to use this key for decrypting the data. However, it is recommended to provide the certificate that belongs to the private key.

Specified by:
registerDecryptionKey in class DecrypterVerifier
Parameters:
decryptionKey - The decryption key and the certificate.
Throws:
HlApiException - If handling the certificate fails.

dropDecryptionKeys

public void dropDecryptionKeys()
Description copied from class: DecrypterVerifier
Release all references to any previously set decryption keys.

Specified by:
dropDecryptionKeys in class DecrypterVerifier

process

public InputStream process(InputStream in)
                    throws IOException,
                           NoKeyException,
                           HlApiException
Description copied from class: DecrypterVerifier
Decrypt and/or verify the given data.

If the data is encrypted, a suitable decryption keys must have been registered before using DecrypterVerifier.registerDecryptionKey(KeyAndCertificate).

Specified by:
process in class DecrypterVerifier
Parameters:
in - The stream that provides the encrypted and/or signed data.
Returns:
The decrypted/verified content data.
Throws:
IOException - If reading from the given stream fails.
NoKeyException - If there is no suitable key available for decryption.
HlApiException - If decryption or verification fails.

getSigningTime

public Date getSigningTime()
                    throws HlApiException
Get the signing time of this signed e-mail message or null if the message was unsigned or did not contain a signing time.

The signing time is the time inside the signature and may be different to the time the e-mail was sent, i.e. the time in the e-mail headers.

Specified by:
getSigningTime in class DecrypterVerifier
Returns:
The signing time or null if unavailable.
Throws:
HlApiException - If parsing the signing time out of the signature structure fails.

getSender

public String getSender()
Get the sender of this e-mail message from the header fields, which may be different to the signer of the message. The application can get the signer e-mail address using the signer certificate, i.e. the first certificate in the array returned by DecrypterVerifier.verify(CertValidator), and sending it to KeyAndCertificate.getEMailAddress(X509Certificate).

Returns:
The sender string of this e-mail message.

getSubject

public String getSubject()
Get the subject line of this e-mail message.

Returns:
The subject line of this e-mail message.

getHeaders

public Map getHeaders()
Get a reference to the map that contains all headers of the most recently parsed e-mail message. The header name strings are the keys of the table with all upper-case characters, i.e. FROM and not from or From. The value is also always a string. If a header spans multiple lines (folding), the value is unfolded with normalized whitespace, i.e. multiple consecutive whitespace characters are reduced to a single space (0x20). If a header occurs more than once, the multiple values are concatenated with a carriage-return and line-feed between (CRLF, 0xD + 0xA).

Do not modify this table to avoid undesired side effects.

Returns:
A reference to the table that contains all headers.
Postconditions
(result != null)

getContentType

public String getContentType()
Get the media type and subtype of the content type for the signed MIME entity, e.g. text/plain. It excludes any parameters like charset. Use getCharacterSet() instead.

Returns:
The media type string.
Preconditions
(contentType != null)

getCharacterSet

public String getCharacterSet()
Get the character encoding (charset parameter) of the content.

Returns:
The character set name.
Preconditions
(charset != null)

getContentBoundary

public String getContentBoundary()
Get the boundary string if the content data is a multipart MIME content.

Returns:
The boundary string or null, if there was no boundary parameter in the content type.

IAIK High-Level API
version 1.1

Copyright © 2007, IAIK, Graz University of Technology
Copyright © 2007, Stiftung SIC