Class PKCS12SafeBagBuilder
java.lang.Object
org.bouncycastle.pkcs.PKCS12SafeBagBuilder
- Direct Known Subclasses:
JcaPKCS12SafeBagBuilder
Builder for a
PKCS12SafeBag. Each constructor selects the bag type
(shrouded key, key, cert, CRL or secret); bag attributes such as friendlyName or localKeyId
are layered on with addBagAttribute(ASN1ObjectIdentifier, ASN1Encodable) before build().-
Constructor Summary
ConstructorsConstructorDescriptionPKCS12SafeBagBuilder(org.bouncycastle.asn1.pkcs.PrivateKeyInfo privateKeyInfo) Build akeyBagcarrying the supplied private key unencrypted.PKCS12SafeBagBuilder(org.bouncycastle.asn1.pkcs.PrivateKeyInfo privateKeyInfo, OutputEncryptor encryptor) Build apkcs8ShroudedKeyBagby encrypting the supplied private key.PKCS12SafeBagBuilder(org.bouncycastle.asn1.x509.Certificate certificate) Build acertBagholding an X.509 certificate (low-level ASN.1 form).PKCS12SafeBagBuilder(org.bouncycastle.asn1.x509.CertificateList crl) Build acrlBagholding an X.509 CRL (low-level ASN.1 form).PKCS12SafeBagBuilder(X509CertificateHolder certificate) Build acertBagholding an X.509 certificate.Build acrlBagholding an X.509 CRL.PKCS12SafeBagBuilder(PKCS12SecretBag secretBag) Build asecretBagcarrying an arbitrary secret value. -
Method Summary
Modifier and TypeMethodDescriptionaddBagAttribute(org.bouncycastle.asn1.ASN1ObjectIdentifier attrType, org.bouncycastle.asn1.ASN1Encodable attrValue) Add a bag attribute (e.g. friendlyName or localKeyId) to the bag being built.build()Assemble the SafeBag and return it.
-
Constructor Details
-
PKCS12SafeBagBuilder
public PKCS12SafeBagBuilder(org.bouncycastle.asn1.pkcs.PrivateKeyInfo privateKeyInfo, OutputEncryptor encryptor) Build apkcs8ShroudedKeyBagby encrypting the supplied private key.- Parameters:
privateKeyInfo- the private key to wrap.encryptor- the password-based output encryptor used to protect the key.
-
PKCS12SafeBagBuilder
public PKCS12SafeBagBuilder(org.bouncycastle.asn1.pkcs.PrivateKeyInfo privateKeyInfo) Build akeyBagcarrying the supplied private key unencrypted.- Parameters:
privateKeyInfo- the private key payload.
-
PKCS12SafeBagBuilder
Build acertBagholding an X.509 certificate.- Parameters:
certificate- the certificate to wrap.- Throws:
IOException- if the certificate cannot be encoded.
-
PKCS12SafeBagBuilder
Build acrlBagholding an X.509 CRL.- Parameters:
crl- the CRL to wrap.- Throws:
IOException- if the CRL cannot be encoded.
-
PKCS12SafeBagBuilder
Build acertBagholding an X.509 certificate (low-level ASN.1 form).- Parameters:
certificate- the certificate to wrap.- Throws:
IOException- if the certificate cannot be encoded.
-
PKCS12SafeBagBuilder
Build acrlBagholding an X.509 CRL (low-level ASN.1 form).- Parameters:
crl- the CRL to wrap.- Throws:
IOException- if the CRL cannot be encoded.
-
PKCS12SafeBagBuilder
Build asecretBagcarrying an arbitrary secret value.- Parameters:
secretBag- the secret bag payload to wrap.
-
-
Method Details
-
addBagAttribute
public PKCS12SafeBagBuilder addBagAttribute(org.bouncycastle.asn1.ASN1ObjectIdentifier attrType, org.bouncycastle.asn1.ASN1Encodable attrValue) Add a bag attribute (e.g. friendlyName or localKeyId) to the bag being built.- Parameters:
attrType- the attribute OID.attrValue- the attribute value.- Returns:
- this builder.
-
build
Assemble the SafeBag and return it.- Returns:
- the resulting
PKCS12SafeBag.
-