/** * 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))); }
/** * Return whether this control contains enveloped data. * * @return true if the control contains enveloped data, false otherwise. */ public boolean isEnvelopedData() { EncryptedKey encKey = EncryptedKey.getInstance(pkiArchiveOptions.getValue()); return !encKey.isEncryptedValue(); }