Search in sources :

Example 1 with CMSEnvelopedData

use of com.github.zhenwei.pkix.cms.CMSEnvelopedData in project LinLong-Java by zhenwei1108.

the class PKIArchiveControl method getEnvelopedData.

/**
 * Return the enveloped data structure contained in this control.
 *
 * @return a CMSEnvelopedData object.
 */
public CMSEnvelopedData getEnvelopedData() throws CRMFException {
    try {
        EncryptedKey encKey = EncryptedKey.getInstance(pkiArchiveOptions.getValue());
        EnvelopedData data = EnvelopedData.getInstance(encKey.getValue());
        return new CMSEnvelopedData(new ContentInfo(CMSObjectIdentifiers.envelopedData, data));
    } catch (CMSException e) {
        throw new CRMFException("CMS parsing error: " + e.getMessage(), e.getCause());
    } catch (Exception e) {
        throw new CRMFException("CRMF parsing error: " + e.getMessage(), e);
    }
}
Also used : CMSEnvelopedData(com.github.zhenwei.pkix.cms.CMSEnvelopedData) EncryptedKey(com.github.zhenwei.pkix.util.asn1.crmf.EncryptedKey) ContentInfo(com.github.zhenwei.pkix.util.asn1.cms.ContentInfo) CMSEnvelopedData(com.github.zhenwei.pkix.cms.CMSEnvelopedData) EnvelopedData(com.github.zhenwei.pkix.util.asn1.cms.EnvelopedData) CMSException(com.github.zhenwei.pkix.cms.CMSException) CMSException(com.github.zhenwei.pkix.cms.CMSException)

Example 2 with CMSEnvelopedData

use of com.github.zhenwei.pkix.cms.CMSEnvelopedData in project LinLong-Java by zhenwei1108.

the class PKIArchiveControlBuilder method build.

/**
 * Build the PKIArchiveControl using the passed in encryptor to encrypt its contents.
 *
 * @param contentEncryptor a suitable content encryptor.
 * @return a PKIArchiveControl object.
 * @throws CMSException in the event the build fails.
 */
public PKIArchiveControl build(OutputEncryptor contentEncryptor) throws CMSException {
    CMSEnvelopedData envContent = envGen.generate(keyContent, contentEncryptor);
    EnvelopedData envD = EnvelopedData.getInstance(envContent.toASN1Structure().getContent());
    return new PKIArchiveControl(new PKIArchiveOptions(new EncryptedKey(envD)));
}
Also used : CMSEnvelopedData(com.github.zhenwei.pkix.cms.CMSEnvelopedData) EncryptedKey(com.github.zhenwei.pkix.util.asn1.crmf.EncryptedKey) PKIArchiveOptions(com.github.zhenwei.pkix.util.asn1.crmf.PKIArchiveOptions) CMSEnvelopedData(com.github.zhenwei.pkix.cms.CMSEnvelopedData) EnvelopedData(com.github.zhenwei.pkix.util.asn1.cms.EnvelopedData)

Aggregations

CMSEnvelopedData (com.github.zhenwei.pkix.cms.CMSEnvelopedData)2 EnvelopedData (com.github.zhenwei.pkix.util.asn1.cms.EnvelopedData)2 EncryptedKey (com.github.zhenwei.pkix.util.asn1.crmf.EncryptedKey)2 CMSException (com.github.zhenwei.pkix.cms.CMSException)1 ContentInfo (com.github.zhenwei.pkix.util.asn1.cms.ContentInfo)1 PKIArchiveOptions (com.github.zhenwei.pkix.util.asn1.crmf.PKIArchiveOptions)1