|
| 1 | +package org.bouncycastle.cert.crmf; |
| 2 | + |
| 3 | +import org.bouncycastle.asn1.ASN1Encodable; |
| 4 | +import org.bouncycastle.asn1.ASN1ObjectIdentifier; |
| 5 | +import org.bouncycastle.asn1.crmf.CRMFObjectIdentifiers; |
| 6 | +import org.bouncycastle.asn1.crmf.PKIPublicationInfo; |
| 7 | +import org.bouncycastle.asn1.crmf.SinglePubInfo; |
| 8 | + |
| 9 | +/** |
| 10 | + * Carrier for a publication information control, saying whether and where the CA should publish |
| 11 | + * the certificate it issues - RFC 4211 sec. 6.3. |
| 12 | + */ |
| 13 | +public class PKIPublicationInfoControl |
| 14 | + implements Control |
| 15 | +{ |
| 16 | + private static final ASN1ObjectIdentifier type = CRMFObjectIdentifiers.id_regCtrl_pkiPublicationInfo; |
| 17 | + |
| 18 | + private final PKIPublicationInfo publicationInfo; |
| 19 | + |
| 20 | + /** |
| 21 | + * Basic constructor - build from the publication information to use. |
| 22 | + * |
| 23 | + * @param publicationInfo the publication information for the certificate. |
| 24 | + */ |
| 25 | + public PKIPublicationInfoControl(PKIPublicationInfo publicationInfo) |
| 26 | + { |
| 27 | + this.publicationInfo = publicationInfo; |
| 28 | + } |
| 29 | + |
| 30 | + /** |
| 31 | + * Basic constructor - build from the locations the certificate is to be published at, |
| 32 | + * which asks for publication (pleasePublish). A null or empty array asks for publication |
| 33 | + * without saying where ("dontCare"); use {@link #dontPublish()} to ask for none. |
| 34 | + * |
| 35 | + * @param pubInfos the locations to publish the certificate at. |
| 36 | + */ |
| 37 | + public PKIPublicationInfoControl(SinglePubInfo[] pubInfos) |
| 38 | + { |
| 39 | + this(new PKIPublicationInfo(pubInfos == null || pubInfos.length == 0 ? null : pubInfos)); |
| 40 | + } |
| 41 | + |
| 42 | + /** |
| 43 | + * Return a control asking the CA not to publish the certificate. |
| 44 | + * |
| 45 | + * @return a control carrying the dontPublish action. |
| 46 | + */ |
| 47 | + public static PKIPublicationInfoControl dontPublish() |
| 48 | + { |
| 49 | + return new PKIPublicationInfoControl(new PKIPublicationInfo(PKIPublicationInfo.dontPublish)); |
| 50 | + } |
| 51 | + |
| 52 | + /** |
| 53 | + * Return the type of this control. |
| 54 | + * |
| 55 | + * @return CRMFObjectIdentifiers.id_regCtrl_pkiPublicationInfo |
| 56 | + */ |
| 57 | + public ASN1ObjectIdentifier getType() |
| 58 | + { |
| 59 | + return type; |
| 60 | + } |
| 61 | + |
| 62 | + /** |
| 63 | + * Return the publication information associated with this control. |
| 64 | + * |
| 65 | + * @return a PKIPublicationInfo structure. |
| 66 | + */ |
| 67 | + public ASN1Encodable getValue() |
| 68 | + { |
| 69 | + return publicationInfo; |
| 70 | + } |
| 71 | + |
| 72 | + /** |
| 73 | + * Return the publication information associated with this control. |
| 74 | + * |
| 75 | + * @return a PKIPublicationInfo structure. |
| 76 | + */ |
| 77 | + public PKIPublicationInfo getPublicationInfo() |
| 78 | + { |
| 79 | + return publicationInfo; |
| 80 | + } |
| 81 | +} |
0 commit comments