iaik.smime
Class signed_content

java.lang.Object
  extended by iaik.smime.signed_content
All Implemented Interfaces:
javax.activation.DataContentHandler

public class signed_content
extends java.lang.Object
implements javax.activation.DataContentHandler

This class implements a data content handler for the S/MIME types application/(x-)pkcs7-signature and multipart/signed.

Within the JavaBeans Activation Framework (JAF) data content handlers are used for writing certain data objects to streams, and parsing objects back from streams. Generally, applications do not immediately call the methods of a data content handler. Rather they use the access mechanisms provided by the corresponding DataHandler. The data handler itself internally will look for a proper data content handler supporting a the requested S/MIME type.

The JAF uses a RFC 1524 mailcap file for defining Java classes as content handlers for specific mime types. In particular, this signed_content class acts as a content handler for the two S/MIME types application/x-pkcs7-signature and multipart/signed, indicated by the following lines to be set in the corresponding mailcap file:

 multipart/signed;;                             x-java-content-handler=iaik.smime.signed_content
 application/x-pkcs7-signature;;        x-java-content-handler=iaik.smime.signed_content
 
Note that the IAIK-S/MIME distribution includes a ready-to-use mailcap file to be copied in the lib directory of your JDK (/lib)!

More information about the JavaBeans Activation Framework may be obtained from http://www.oracle.com/technetwork/java/javase/downloads/index-135046.html.


Constructor Summary
signed_content()
          Default constructor.
 
Method Summary
 java.lang.Object getContent(javax.activation.DataSource dataSource)
          Returns an object representing the data which is encapsulated by the supplied dataSource.
 java.lang.Object getTransferData(java.awt.datatransfer.DataFlavor dataFlavor, javax.activation.DataSource dataSource)
          Returns an object representing the data to be transferred.
 java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
          Returns the DataFlavors indicating the flavors the data can be provided in.
 void writeTo(java.lang.Object o, java.lang.String mimeType, java.io.OutputStream os)
          Writes the supplied object to the given output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

signed_content

public signed_content()
Default constructor.

Method Detail

getTransferDataFlavors

public java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
Returns the DataFlavors indicating the flavors the data can be provided in.

Specified by:
getTransferDataFlavors in interface javax.activation.DataContentHandler
Returns:
the DataFlavors indicating the flavors the data can be provided in

getTransferData

public java.lang.Object getTransferData(java.awt.datatransfer.DataFlavor dataFlavor,
                                        javax.activation.DataSource dataSource)
                                 throws java.io.IOException
Returns an object representing the data to be transferred.

Specified by:
getTransferData in interface javax.activation.DataContentHandler
Parameters:
dataFlavor - the DataFlavor indicating the requested type
dataSource - the DataSource supplying the encapsulated data
Returns:
a SignedContent object for the supplied data, or null if the specified dataFlavor has the wrong format
Throws:
java.io.IOException - if an error occurs when parsing the data

getContent

public java.lang.Object getContent(javax.activation.DataSource dataSource)
                            throws java.io.IOException
Returns an object representing the data which is encapsulated by the supplied dataSource.

Specified by:
getContent in interface javax.activation.DataContentHandler
Parameters:
dataSource - the data source supplying the encapsulated data
Returns:
a SignedContent object representing the supplied data
Throws:
java.io.IOException - if an error occurs when parsing the data

writeTo

public void writeTo(java.lang.Object o,
                    java.lang.String mimeType,
                    java.io.OutputStream os)
             throws java.io.IOException
Writes the supplied object to the given output stream.

This method only is able to handle objects supplied as instances of JMailSMimeSigned or SignedContent. If the given object does not satisfy this criterion, an IOException is thrown.

Specified by:
writeTo in interface javax.activation.DataContentHandler
Parameters:
o - the object (an instance of JMailSMimeSigned or SignedContent) to be written to the stream
mimeType - the mimeType; not used here
os - the output stream to which to write the data
Throws:
java.io.IOException - if the supplied object is not an instance of SignedContent or JMailSMimeSigned, or an error occurs while writing to the stream

This Javadoc may contain text parts from text parts from IETF Internet Standard specifications (see copyright note).

IAIK-CMS 6.0, (c) 2002 IAIK, (c) 2003, 2023 SIC