Class PKIResponseBuilder

java.lang.Object
org.bouncycastle.cmc.PKIResponseBuilder

public class PKIResponseBuilder extends Object
Builder for a Simple PKI Response (RFC 5272 / RFC 7030 4.2.3 / 4.4.2), delivered as a SimplePKIResponse.

Two shapes are supported, selected automatically at build() time:

  • Full PKI Response (the error case used by EST server-generated errors): a CMS SignedData with no SignerInfos whose encapsulated content is an id-cct-PKIResponse PKIResponse SEQUENCE. Selected when any control attribute, CMS content or other message has been added.
  • Simple PKI Response (the cert-delivery case used by /simpleenroll): a degenerate CMS SignedData with no SignerInfos, no encapsulated content, and the issued certificates in the certificates field. Selected when only certificates have been added.
  • Constructor Details

    • PKIResponseBuilder

      public PKIResponseBuilder()
  • Method Details

    • addControlAttribute

      public PKIResponseBuilder addControlAttribute(org.bouncycastle.asn1.cmc.TaggedAttribute attr)
    • addStatusInfoV2

      public PKIResponseBuilder addStatusInfoV2(org.bouncycastle.asn1.cmc.BodyPartID bodyPartID, org.bouncycastle.asn1.cmc.CMCStatusInfoV2 statusInfo)
      Convenience for the EST server-generated error case: wrap the supplied CMCStatusInfoV2 in a TaggedAttribute keyed by id-cmc-statusInfoV2 and append it to the controlSequence. The supplied bodyPartID identifies the TaggedAttribute itself within the controlSequence (per RFC 5272 sec. 3.2.1); it is structurally distinct from the bodyList entries inside CMCStatusInfoV2, which identify which request body parts the status pertains to.
    • addStatusInfoV2

      public PKIResponseBuilder addStatusInfoV2(org.bouncycastle.asn1.cmc.CMCStatusInfoV2 statusInfo)
      Convenience overload for the simple-error case where the outer TaggedAttribute's bodyPartID can be inherited from the first entry of statusInfo.getBodyList(). Behaves identically to addStatusInfoV2(BodyPartID, CMCStatusInfoV2) when the caller doesn't need an independent identifier for the TaggedAttribute.
      Throws:
      IllegalArgumentException - if statusInfo's bodyList is empty.
    • addCmsContent

      public PKIResponseBuilder addCmsContent(org.bouncycastle.asn1.cmc.TaggedContentInfo cmsContent)
    • addOtherMsg

      public PKIResponseBuilder addOtherMsg(org.bouncycastle.asn1.cmc.OtherMsg otherMsg)
    • addCertificate

      public PKIResponseBuilder addCertificate(X509CertificateHolder cert)
      Add a certificate to deliver in the response. When the builder contains only certificates (no control attributes, no CMS contents, no other messages), build() emits a degenerate SignedData with no encapsulated content and the certificates in the certificates field (the Simple PKI Response shape used by EST /simpleenroll). When other payload has also been added, the certificates are carried alongside the id-cct-PKIResponse encapsulated content.
    • build

      public SimplePKIResponse build() throws CMCException
      Throws:
      CMCException