Example usage for org.bouncycastle.asn1.cms CMSObjectIdentifiers encryptedData

List of usage examples for org.bouncycastle.asn1.cms CMSObjectIdentifiers encryptedData

Introduction

In this page you can find the example usage for org.bouncycastle.asn1.cms CMSObjectIdentifiers encryptedData.

Prototype

ASN1ObjectIdentifier encryptedData

To view the source code for org.bouncycastle.asn1.cms CMSObjectIdentifiers encryptedData.

Click Source Link

Document

PKCS#7: 1.2.840.113549.1.7.6

Usage

From source file:mitm.common.security.cms.CMSContentTypeClassifier.java

License:Open Source License

/**
 * Returns the CMS content type of the provided sequence.
 * // w  w  w  .  j  ava  2s  .co  m
 * See RFC3852 for content types
 * 
 * @param sequenceParser
 * @return
 */
public static CMSContentType getContentType(ASN1SequenceParser sequenceParser) {
    CMSContentType contentType = CMSContentType.UNKNOWN;

    try {
        ContentInfoParser contentInfoParser = new ContentInfoParser(sequenceParser);

        DERObjectIdentifier derContentType = contentInfoParser.getContentType();

        if (CMSObjectIdentifiers.data.equals(derContentType)) {
            contentType = CMSContentType.DATA;
        } else if (CMSObjectIdentifiers.signedData.equals(derContentType)) {
            contentType = CMSContentType.SIGNEDDATA;
        } else if (CMSObjectIdentifiers.envelopedData.equals(derContentType)) {
            contentType = CMSContentType.ENVELOPEDDATA;
        } else if (CMSObjectIdentifiers.signedAndEnvelopedData.equals(derContentType)) {
            contentType = CMSContentType.SIGNEDANDENVELOPEDDATA;
        } else if (CMSObjectIdentifiers.digestedData.equals(derContentType)) {
            contentType = CMSContentType.DIGESTEDDATA;
        } else if (CMSObjectIdentifiers.encryptedData.equals(derContentType)) {
            contentType = CMSContentType.ENCRYPTEDDATA;
        } else if (CMSObjectIdentifiers.compressedData.equals(derContentType)) {
            contentType = CMSContentType.COMPRESSEDDATA;
        }
    } catch (IOException e) {
        logger.error("IOException retrieving CMS content type", e);
    }
    return contentType;
}