PKIHeaderBuilder (Bouncy Castle Library 1.85 API Specification)
Date: 2026-07-12

org.bouncycastle.asn1.cmp

## Class PKIHeaderBuilder

- java.lang.Object
- - org.bouncycastle.asn1.cmp.PKIHeaderBuilder

-     public class PKIHeaderBuilder
      extends java.lang.Object

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PKIHeaderBuilder(int pvno, GeneralName sender, GeneralName recipient)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `PKIHeader` | `build()` PKIHeader ::= SEQUENCE { pvno INTEGER { cmp1999(1), cmp2000(2) }, sender GeneralName, -- identifies the sender recipient GeneralName, -- identifies the intended recipient messageTime [0] GeneralizedTime OPTIONAL, -- time of production of this message (used when sender -- believes that the transport will be "suitable"; i.e., -- that the time will still be meaningful upon receipt) protectionAlg [1] AlgorithmIdentifier OPTIONAL, -- algorithm used for calculation of protection bits senderKID [2] KeyIdentifier OPTIONAL, recipKID [3] KeyIdentifier OPTIONAL, -- to identify specific keys used for protection transactionID [4] OCTET STRING OPTIONAL, -- identifies the transaction; i.e., this will be the same in -- corresponding request, response, certConf, and PKIConf -- messages senderNonce [5] OCTET STRING OPTIONAL, recipNonce [6] OCTET STRING OPTIONAL, -- nonces used to provide replay protection, senderNonce -- is inserted by the creator of this message; recipNonce -- is a nonce previously inserted in a related message by -- the intended recipient of this message freeText [7] PKIFreeText OPTIONAL, -- this may be used to indicate context-specific instructions -- (this field is intended for human consumption) generalInfo [8] SEQUENCE SIZE (1..MAX) OF InfoTypeAndValue OPTIONAL -- this may be used to convey context-specific information -- (this field not primarily intended for human consumption) }
    `PKIHeaderBuilder` | `setFreeText(PKIFreeText text)`
    `PKIHeaderBuilder` | `setGeneralInfo(ASN1Sequence seqOfInfoTypeAndValue)`
    `PKIHeaderBuilder` | `setGeneralInfo(InfoTypeAndValue genInfo)`
    `PKIHeaderBuilder` | `setGeneralInfo(InfoTypeAndValue[] genInfos)`
    `PKIHeaderBuilder` | `setMessageTime(ASN1GeneralizedTime time)`
    `PKIHeaderBuilder` | `setProtectionAlg(AlgorithmIdentifier aid)`
    `PKIHeaderBuilder` | `setRecipKID(ASN1OctetString kid)`
    `PKIHeaderBuilder` | `setRecipKID(byte[] kid)`
    `PKIHeaderBuilder` | `setRecipNonce(ASN1OctetString nonce)`
    `PKIHeaderBuilder` | `setRecipNonce(byte[] nonce)`
    `PKIHeaderBuilder` | `setSenderKID(ASN1OctetString kid)`
    `PKIHeaderBuilder` | `setSenderKID(byte[] kid)`
    `PKIHeaderBuilder` | `setSenderNonce(ASN1OctetString nonce)`
    `PKIHeaderBuilder` | `setSenderNonce(byte[] nonce)`
    `PKIHeaderBuilder` | `setTransactionID(ASN1OctetString tid)`
    `PKIHeaderBuilder` | `setTransactionID(byte[] tid)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### PKIHeaderBuilder

          public PKIHeaderBuilder(int pvno,
                                  GeneralName sender,
                                  GeneralName recipient)

  - ### Method Detail

    - #### setMessageTime

          public PKIHeaderBuilder setMessageTime(ASN1GeneralizedTime time)

    - #### setProtectionAlg

          public PKIHeaderBuilder setProtectionAlg(AlgorithmIdentifier aid)

    - #### setSenderKID

          public PKIHeaderBuilder setSenderKID(byte[] kid)

    - #### setSenderKID

          public PKIHeaderBuilder setSenderKID(ASN1OctetString kid)

    - #### setRecipKID

          public PKIHeaderBuilder setRecipKID(byte[] kid)

    - #### setRecipKID

          public PKIHeaderBuilder setRecipKID(ASN1OctetString kid)

    - #### setTransactionID

          public PKIHeaderBuilder setTransactionID(byte[] tid)

    - #### setTransactionID

          public PKIHeaderBuilder setTransactionID(ASN1OctetString tid)

    - #### setSenderNonce

          public PKIHeaderBuilder setSenderNonce(byte[] nonce)

    - #### setSenderNonce

          public PKIHeaderBuilder setSenderNonce(ASN1OctetString nonce)

    - #### setRecipNonce

          public PKIHeaderBuilder setRecipNonce(byte[] nonce)

    - #### setRecipNonce

          public PKIHeaderBuilder setRecipNonce(ASN1OctetString nonce)

    - #### setFreeText

          public PKIHeaderBuilder setFreeText(PKIFreeText text)

    - #### setGeneralInfo

          public PKIHeaderBuilder setGeneralInfo(InfoTypeAndValue genInfo)

    - #### setGeneralInfo

          public PKIHeaderBuilder setGeneralInfo(InfoTypeAndValue[] genInfos)

    - #### setGeneralInfo

          public PKIHeaderBuilder setGeneralInfo(ASN1Sequence seqOfInfoTypeAndValue)

    - #### build

          public PKIHeader build()

            PKIHeader ::= SEQUENCE {
                      pvno                INTEGER     { cmp1999(1), cmp2000(2) },
                      sender              GeneralName,
                      -- identifies the sender
                      recipient           GeneralName,
                      -- identifies the intended recipient
                      messageTime     [0] GeneralizedTime         OPTIONAL,
                      -- time of production of this message (used when sender
                      -- believes that the transport will be "suitable"; i.e.,
                      -- that the time will still be meaningful upon receipt)
                      protectionAlg   [1] AlgorithmIdentifier     OPTIONAL,
                      -- algorithm used for calculation of protection bits
                      senderKID       [2] KeyIdentifier           OPTIONAL,
                      recipKID        [3] KeyIdentifier           OPTIONAL,
                      -- to identify specific keys used for protection
                      transactionID   [4] OCTET STRING            OPTIONAL,
                      -- identifies the transaction; i.e., this will be the same in
                      -- corresponding request, response, certConf, and PKIConf
                      -- messages
                      senderNonce     [5] OCTET STRING            OPTIONAL,
                      recipNonce      [6] OCTET STRING            OPTIONAL,
                      -- nonces used to provide replay protection, senderNonce
                      -- is inserted by the creator of this message; recipNonce
                      -- is a nonce previously inserted in a related message by
                      -- the intended recipient of this message
                      freeText        [7] PKIFreeText             OPTIONAL,
                      -- this may be used to indicate context-specific instructions
                      -- (this field is intended for human consumption)
                      generalInfo     [8] SEQUENCE SIZE (1..MAX) OF
                                           InfoTypeAndValue     OPTIONAL
                      -- this may be used to convey context-specific information
                      -- (this field not primarily intended for human consumption)
           }

      Returns:
        a basic ASN.1 object representation.