public static PKIArchiveOptions getInstance(Object o) { if (o == null || o instanceof PKIArchiveOptions) { return (PKIArchiveOptions)o; } else if (o instanceof ASN1TaggedObject) { return new PKIArchiveOptions((ASN1TaggedObject)o); } throw new IllegalArgumentException("unknown object: " + o); }
/** * Return the archive control type, one of: encryptedPrivKey,keyGenParameters,or archiveRemGenPrivKey. * * @return the archive control type. */ public int getArchiveType() { return pkiArchiveOptions.getType(); }
/** * 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 a control value of the specified type. * * @param type the type OID for the control value we are checking for. * @return the control value if present, null otherwise. */ public Control getControl(ASN1ObjectIdentifier type) { AttributeTypeAndValue found = findControl(type); if (found != null) { if (found.getType().equals(CRMFObjectIdentifiers.id_regCtrl_pkiArchiveOptions)) { return new PKIArchiveControl(PKIArchiveOptions.getInstance(found.getValue())); } if (found.getType().equals(CRMFObjectIdentifiers.id_regCtrl_regToken)) { return new RegTokenControl(DERUTF8String.getInstance(found.getValue())); } if (found.getType().equals(CRMFObjectIdentifiers.id_regCtrl_authenticator)) { return new AuthenticatorControl(DERUTF8String.getInstance(found.getValue())); } } return null; }
/** * 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 a control value of the specified type. * * @param type the type OID for the control value we are checking for. * @return the control value if present, null otherwise. */ public Control getControl(ASN1ObjectIdentifier type) { AttributeTypeAndValue found = findControl(type); if (found != null) { if (found.getType().equals(CRMFObjectIdentifiers.id_regCtrl_pkiArchiveOptions)) { return new PKIArchiveControl(PKIArchiveOptions.getInstance(found.getValue())); } if (found.getType().equals(CRMFObjectIdentifiers.id_regCtrl_regToken)) { return new RegTokenControl(DERUTF8String.getInstance(found.getValue())); } if (found.getType().equals(CRMFObjectIdentifiers.id_regCtrl_authenticator)) { return new AuthenticatorControl(DERUTF8String.getInstance(found.getValue())); } } return null; }
public static PKIArchiveOptions getInstance(Object o) { if (o == null || o instanceof PKIArchiveOptions) { return (PKIArchiveOptions)o; } else if (o instanceof ASN1TaggedObject) { return new PKIArchiveOptions((ASN1TaggedObject)o); } throw new IllegalArgumentException("unknown object: " + o); }
/** * 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); } } }
/** * Return the archive control type, one of: encryptedPrivKey,keyGenParameters,or archiveRemGenPrivKey. * * @return the archive control type. */ public int getArchiveType() { return pkiArchiveOptions.getType(); }
/** * 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 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); } } }
/** * 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))); } }