Example usage for org.bouncycastle.mail.smime CMSProcessableBodyPartInbound CMSProcessableBodyPartInbound

List of usage examples for org.bouncycastle.mail.smime CMSProcessableBodyPartInbound CMSProcessableBodyPartInbound

Introduction

In this page you can find the example usage for org.bouncycastle.mail.smime CMSProcessableBodyPartInbound CMSProcessableBodyPartInbound.

Prototype

public CMSProcessableBodyPartInbound(BodyPart bodyPart) 

Source Link

Document

Create a processable with the default transfer encoding of 7bit

Usage

From source file:mitm.common.security.smime.SMIMESignedInspectorImpl.java

License:Open Source License

protected CMSSignedDataAdapter getSignedDataAdapter(Part signedPart, boolean useRaw)
        throws MessagingException, CMSException, IOException, SMIMEInspectorException, SMIMEException {
    CMSSignedData signed;/* w  w w. j a v a 2 s . co  m*/

    Object content = signedPart.getContent();

    if (content instanceof MimeMultipart) {
        MimeMultipart multipart = (MimeMultipart) content;

        /* extract the message part and signature part */
        BodyPart[] parts = SMIMEUtils.dissectSigned(multipart);

        if (parts == null) {
            throw new SMIMEInspectorException("Multipart is not valid clear signed.");
        }

        CMSProcessable processable = useRaw ? new WriteRawCMSProcessable(parts[0])
                : new CMSProcessableBodyPartInbound(parts[0]);

        signed = new SMIMEClearSigned(processable, parts[1]);

        unsignedContent = (MimeBodyPart) parts[0];
    } else {
        signed = new SMIMESigned(signedPart);

        unsignedContent = ((SMIMESigned) signed).getContent();
    }

    CMSSignedDataAdapter signedAdapter = CMSAdapterFactory.createAdapter(signed);

    return signedAdapter;
}