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);
}
}
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)));
}
Aggregations