iaik.smime
Class DefaultCanonicalizer

java.lang.Object
  extended by iaik.smime.DefaultCanonicalizer
All Implemented Interfaces:
Canonicalizer

public class DefaultCanonicalizer
extends java.lang.Object
implements Canonicalizer

The default canonicalizer.

This class implements the Canonicalizer interface for ensuring that <CR> and <LF> always occurs together as <CR><LF> except when binary content transfer encoding is used. An application having or wishing to use a more specific canonicalization scheme may implement the Canonicalizer interface and register its new Canonicalizer by calling the static setCanonicalizer method of the SMimeParameters class. Note that for outging messages the Canonicalizer only is visited when modelling body parts and multiparts by classes SMimeBodyPart and SMimeMultipart classes or when supplying a text message by means of method setText for a multipart/signed SignedContent object. When parsing an ingoing message the canonicalizer only is utilized for the contents part of a multipart/signed message.

This class implements the canonicalizeOutputStream method by only returning a CanonicalizeOutputStream doing the canonicalization for non-binary entities and the canonicalizeInputStream method by returning a CanonicalizeInputStream:

 public OutputStream canonicalizeOutputStream(OutputStream os, String contentType, String contentTransferEncoding) {
   if ((contentTransferEncoding == null) || (contentTransferEncoding.indexOf("binary") == -1)) {
      return new CanonicalizeOutputStream(os);
   } else { //do not canonicalize binary data
      return os;
   }
 }

 public InputStream canonicalizeInputStream(LineInputStream is, String boundary) {
   return new CanonicalizeInputStream(is, boundary);
 }

 

See Also:
Canonicalizer

Constructor Summary
DefaultCanonicalizer()
          Empty default constructor.
 
Method Summary
 java.io.InputStream canonicalizeInputStream(LineInputStream is, java.lang.String boundary)
          Wraps an canonicalizing input stream around the given input stream
 java.io.OutputStream canonicalizeOutputStream(java.io.OutputStream os, java.lang.String contentType, java.lang.String contentTransferEncoding)
          Wraps an canonicalizing output stream around the given output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultCanonicalizer

public DefaultCanonicalizer()
Empty default constructor.

Method Detail

canonicalizeOutputStream

public java.io.OutputStream canonicalizeOutputStream(java.io.OutputStream os,
                                                     java.lang.String contentType,
                                                     java.lang.String contentTransferEncoding)
Wraps an canonicalizing output stream around the given output stream.

Specified by:
canonicalizeOutputStream in interface Canonicalizer
Parameters:
os - the (buffered) output stream where the MIME body part shall be written.
contentType - the MIME content type of the body part to be written
contentTransferEncoding - the content transfer encoding of the body part to be written.
Returns:
the CanonicalizeOutputStream
Throws:
java.io.IOException - if an error has to be thrown when setting the canonicalizing wrapping stream

canonicalizeInputStream

public java.io.InputStream canonicalizeInputStream(LineInputStream is,
                                                   java.lang.String boundary)
Wraps an canonicalizing input stream around the given input stream

Specified by:
canonicalizeInputStream in interface Canonicalizer
Parameters:
is - the input stream representing the MIME entity to be canonicalized
boundary - the boundary line indicating the end of the MIME entity
Returns:
the CanonicalizeInputStream
Throws:
java.io.IOException - if an error has to be thrown when setting the canonicalizing wrapping 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