public static EncryptedKey getInstance(Object o) { if (o instanceof EncryptedKey) { return (EncryptedKey)o; } else if (o instanceof ASN1TaggedObject) { return new EncryptedKey(EnvelopedData.getInstance((ASN1TaggedObject)o, false)); } else if (o instanceof EncryptedValue) { return new EncryptedKey((EncryptedValue)o); } else { return new EncryptedKey(EncryptedValue.getInstance(o)); } }
/** * 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(); }
/** * 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); } } }
private PKIArchiveOptions(ASN1TaggedObject tagged) { switch (tagged.getTagNo()) { case encryptedPrivKey: value = EncryptedKey.getInstance(tagged.getObject()); break; case keyGenParameters: value = ASN1OctetString.getInstance(tagged, false); break; case archiveRemGenPrivKey: value = ASN1Boolean.getInstance(tagged, false); break; default: throw new IllegalArgumentException("unknown tag number: " + tagged.getTagNo()); } }
/** * 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); } } }
private PKIArchiveOptions(ASN1TaggedObject tagged) { switch (tagged.getTagNo()) { case encryptedPrivKey: value = EncryptedKey.getInstance(tagged.getObject()); break; case keyGenParameters: value = ASN1OctetString.getInstance(tagged, false); break; case archiveRemGenPrivKey: value = DERBoolean.getInstance(tagged, false); break; default: throw new IllegalArgumentException("unknown tag number: " + tagged.getTagNo()); } }
/** * 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(); }
public static EncryptedKey getInstance(Object o) { if (o instanceof EncryptedKey) { return (EncryptedKey)o; } else if (o instanceof ASN1TaggedObject) { return new EncryptedKey(EnvelopedData.getInstance((ASN1TaggedObject)o, false)); } else if (o instanceof EncryptedValue) { return new EncryptedKey((EncryptedValue)o); } else { return new EncryptedKey(EncryptedValue.getInstance(o)); } }
/** * 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))); } }
/** * 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))); } }