public CMSSignedData encode(final PkiMessage<?> message)
            throws MessageEncodingException {
        LOGGER.debug("Encoding pkiMessage");
        LOGGER.debug("Encoding message: {}", message);

        CMSTypedData content = getContent(message);
        LOGGER.debug(
                "Signing pkiMessage using key belonging to [dn={}; serial={}]",
                signerId.getSubjectDN(), signerId.getSerialNumber());
        try {
            CMSSignedDataGenerator generator = new CMSSignedDataGenerator();
            generator.addSignerInfoGenerator(getSignerInfo(message));
            generator.addCertificates(getCertificates());
            LOGGER.debug("Signing {} content", content);
            CMSSignedData pkiMessage = generator.generate(content, true);
            LOGGER.debug("Finished encoding pkiMessage");

            return pkiMessage;
        } catch (CMSException e) {
            throw new MessageEncodingException(e);
        } catch (Exception e) {
            throw new MessageEncodingException(e);
        }
    }
public CMSSignedData encode ( final PkiMessage < ? > message ) throws MessageEncodingException { LOGGER . debug ( "Encoding pkiMessage" ) ; LOGGER . debug ( "Encoding message: {}" , message ) ; CMSTypedData content = getContent ( message ) ; LOGGER . debug ( "Signing pkiMessage using key belonging to [dn={}; serial={}]" , signerId . getSubjectDN ( ) , signerId . getSerialNumber ( ) ) ; try { CMSSignedDataGenerator generator = new CMSSignedDataGenerator ( ) ; generator . addSignerInfoGenerator ( getSignerInfo ( message ) ) ; generator . addCertificates ( getCertificates ( ) ) ; LOGGER . debug ( "Signing {} content" , content ) ; CMSSignedData pkiMessage = generator . generate ( content , true ) ; LOGGER . debug ( "Finished encoding pkiMessage" ) ; return pkiMessage ; } catch ( CMSException e ) { throw new MessageEncodingException ( e ) ; } catch ( Exception e ) { throw new MessageEncodingException ( e ) ; } }
Encodes the provided <tt>PkiMessage</tt> into a PKCS #7
<tt>signedData</tt>.

@param message
the <tt>PkiMessage</tt> to encode.
@return the encoded <tt>signedData</tt>
@throws MessageEncodingException
if there is a problem encoding the <tt>PkiMessage</tt>