certmanager/lib Library API Documentation

StructuringInfoWrapper Class Reference
[Signing and Encrypting Actions]

This class provides C++ access to the StructuringInfo helper struct that is specified in cryptplug.h to hold information returned by signing and by encrypting functions. More...

#include <cryptplugwrapper.h>

Collaboration diagram for StructuringInfoWrapper:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 StructuringInfoWrapper (CryptPlugWrapper *wrapper)
void reset ()

Public Attributes

CryptPlug::StructuringInfo data

Detailed Description

This class provides C++ access to the StructuringInfo helper struct that is specified in cryptplug.h to hold information returned by signing and by encrypting functions.

Use this information to compose a MIME object containing signed and/or encrypted content (or to build a text frame around your flat non-MIME message body, resp.)

Note:
This class is different from the respective cryptplug.h class because this one takes care for freeing the char** members' memory automatically. You must not call the free function for any of it's members - just ignore the advise given in the cryptplug.h documentation!
If value returned in makeMimeObject is TRUE the text strings returned in contentTypeMain and contentDispMain and contentTEncMain (and, if required, content[..]Version and bodyTextVersion and content[..]Sig) should be used to compose a respective MIME object.
If FALSE the texts returned in flatTextPrefix and flatTextSeparator and flatTextPostfix are to be used instead.
Always either the content[..] and bodyTextVersion parameters or the flatText[..] parameters are holding valid data - never both of them may be used simultaneously as plugins will just ignore the parameters not matching their makeMimeObject setting.

When creating your MIME object please observe these common rules:

If makeMultiMime returns FALSE the contentTypeMain returned must not be altered but used to specify a single part mime object holding the code bloc, e.g. this is used for 'enveloped-data' single part MIME objects. In this case you should ignore both the content[..]Version and content[..]Code parameters.

If makeMultiMime returns TRUE also the following rules apply:

If value returned in makeMimeObject is FALSE the text strings returned in flatTextPrefix and flatTextPostfix should be used to build a frame around the cleartext and the code bloc holding the signature (or - in case of encrypting - the encoded data bloc, resp.).
If includeCleartext is TRUE this frame should also include the cleartext as first bloc, this bloc should be divided from the code bloc by the contents of flatTextSeparator - typically this is used for signing but not when encrypting.
If includeCleartext is FALSE you should ignore both the cleartext and the flatTextSeparator parameter.

How to use StructuringInfoWrapper data in your program:

    char* ciphertext;
    StructuringInfoWrapper structInf;

    if( ! signMessage( cleartext, &ciphertext, certificate,
                      structInf ) ) {

        myErrorDialog( "Error: could not sign the message!" );

    } else {
      if( structInf.data.makeMimeObject ) {

        // Build the main MIME object.
        // This is done by
        // using the header values returned in
        // structInf.data.contentTypeMain and in
        // structInf.data.contentDispMain and in
        // structInf.data.contentTEncMain.
        ..

        if( ! structInf.data.makeMultiMime ) {

          // Build the main MIME object's body.
          // This is done by
          // using the code bloc returned in
          // ciphertext.
          ..

        } else {

          // Build the encapsulated MIME parts.
          if( structInf.data.includeCleartext ) {

            // Build a MIME part holding the cleartext.
            // This is done by
            // using the original cleartext's headers and by
            // taking it's original body text.
            ..

          }
          if(    structInf.data.contentTypeVersion
              && 0 < strlen( structInf.data.contentTypeVersion ) ) {

            // Build a MIME part holding the version information.
            // This is done by
            // using the header values returned in
            // structInf.data.contentTypeVersion and
            // structInf.data.contentDispVersion and
            // structInf.data.contentTEncVersion and by
            // taking the body contents returned in
            // structInf.data.bodyTextVersion.
            ..

          }
          if(    structInf.data.contentTypeCode
              && 0 < strlen( structInf.data.contentTypeCode ) ) {

            // Build a MIME part holding the code information.
            // This is done by
            // using the header values returned in
            // structInf.data.contentTypeCode and
            // structInf.data.contentDispCode and
            // structInf.data.contentTEncCode and by
            // taking the body contents returned in
            // ciphertext.
            ..

          } else {

            // Plugin error!
            myErrorDialog( "Error: Cryptography plugin returned a main"
                          "Content-Type=Multipart/.. but did not "
                          "specify the code bloc's Content-Type header."
                          "\nYou may report this bug:"
                          "\n" + cryptplug.bugURL() );
          }
        }
      } else  {

        // Build a plain message body
        // based on the values returned in structInf.
        // Note: We do _not_ insert line breaks between the parts since
        //       it is the plugin job to provide us with ready-to-use
        //       texts containing all necessary line breaks.
        strcpy( myMessageBody, structInf.data.plainTextPrefix );
        if( structInf.data.includeCleartext ) {
          strcat( myMessageBody, cleartext );
          strcat( myMessageBody, structInf.data.plainTextSeparator );
        }
        strcat( myMessageBody, *ciphertext );
        strcat( myMessageBody, structInf.data.plainTextPostfix );
      }

      // free the memory that was allocated
      // for the ciphertext
      free( ciphertext );
    }

See also:
signMessage, encryptMessage, encryptAndSignMessage

Definition at line 436 of file cryptplugwrapper.h.


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for certmanager/lib Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Dec 21 14:23:06 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003