Top Description Fields Constructors Methods
org.bouncycastle.cert.cmp

public Class ProtectedPKIMessageBuilder

extends Object
Class Inheritance
Imports
java.io.IOException, .OutputStream, java.util.ArrayList, .Date, .List, org.bouncycastle.asn1.ASN1EncodableVector, .ASN1Encoding, .ASN1GeneralizedTime, .DERBitString, .DERSequence, org.bouncycastle.asn1.cmp.CMPCertificate, .InfoTypeAndValue, .PKIBody, .PKIFreeText, .PKIHeader, .PKIHeaderBuilder, .PKIMessage, org.bouncycastle.asn1.x509.AlgorithmIdentifier, .GeneralName, org.bouncycastle.cert.X509CertificateHolder, org.bouncycastle.operator.ContentSigner, .MacCalculator

Builder for creating a protected PKI message.

Field Summary

Modifier and TypeField and Description
private PKIBody
private List<E>
private List<E>
private PKIHeaderBuilder

Constructor Summary

AccessConstructor and Description
public
ProtectedPKIMessageBuilder(GeneralName
message sender.
sender
,
GeneralName
intended recipient.
recipient
)

Commence a message with the header version CMP_2000.

public
ProtectedPKIMessageBuilder(int
the version CMP_1999 or CMP_2000.
pvno
,
GeneralName
message sender.
sender
,
GeneralName
intended recipient.
recipient
)

Commence a message with a specific header type.

Method Summary

Modifier and TypeMethod and Description
public ProtectedPKIMessageBuilder

Returns:

the current builder instance.
addCMPCertificate
(X509CertificateHolder
the extra certificate to add.
extraCert
)

Add an "extra certificate" to the message.

public ProtectedPKIMessageBuilder

Returns:

the current builder instance.
addGeneralInfo
(InfoTypeAndValue
the generalInfo data to be added.
genInfo
)

Add a generalInfo data record to the header of the new message.

public ProtectedPKIMessage

Returns:

the resulting protected PKI message.
build
(MacCalculator
MAC calculator.
macCalculator
)

Build a protected PKI message which has MAC based integrity protection.

public ProtectedPKIMessage

Returns:

the resulting protected PKI message.
build
(ContentSigner
the ContentSigner to be used to calculate the signature.
signer
)

Build a protected PKI message which has MAC based integrity protection.

private byte[]
calculateMac(MacCalculator macCalculator, PKIHeader header, PKIBody body)

private byte[]
private void
finaliseHeader(AlgorithmIdentifier algorithmIdentifier)

private ProtectedPKIMessage
public ProtectedPKIMessageBuilder

Returns:

the current builder instance.
setBody
(PKIBody
the message body.
body
)

Set the body for the new message

public ProtectedPKIMessageBuilder

Returns:

the current builder instance.
setFreeText
(PKIFreeText
the contents of the human readable message,
freeText
)

Include a human-readable message in the new message.

public ProtectedPKIMessageBuilder

Returns:

the current builder instance.
setMessageTime
(Date
the message creation time.
time
)

Set the creation time for the new message.

public ProtectedPKIMessageBuilder

Returns:

the current builder instance.
setRecipKID
(byte[]
a key identifier.
kid
)

Set the recipient key identifier for the key to be used to verify the new message.

public ProtectedPKIMessageBuilder

Returns:

the current builder instance.
setRecipNonce
(byte[]
a NONCE, typically copied from the sender nonce of the previous message.
nonce
)

Set the recipient nonce field on the new message.

public ProtectedPKIMessageBuilder

Returns:

the current builder instance.
setSenderKID
(byte[]
a key identifier.
kid
)

Set the sender key identifier for the key used to protect the new message.

public ProtectedPKIMessageBuilder

Returns:

the current builder instance.
setSenderNonce
(byte[]
a NONCE, typically 128 bits of random data.
nonce
)

Set the sender nonce field on the new message.

public ProtectedPKIMessageBuilder

Returns:

the current builder instance.
setTransactionID
(byte[]
the transaction ID.
tid
)

Set the identifier for the transaction the new message will belong to.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bodyback to summary
private PKIBody body
extraCertsback to summary
private List<E> extraCerts
generalInfosback to summary
private List<E> generalInfos
hdrBuilderback to summary
private PKIHeaderBuilder hdrBuilder

Constructor Detail

ProtectedPKIMessageBuilderback to summary
public ProtectedPKIMessageBuilder(GeneralName sender, GeneralName recipient)

Commence a message with the header version CMP_2000.

Parameters
sender:GeneralName

message sender.

recipient:GeneralName

intended recipient.

ProtectedPKIMessageBuilderback to summary
public ProtectedPKIMessageBuilder(int pvno, GeneralName sender, GeneralName recipient)

Commence a message with a specific header type.

Parameters
pvno:int

the version CMP_1999 or CMP_2000.

sender:GeneralName

message sender.

recipient:GeneralName

intended recipient.

Method Detail

addCMPCertificateback to summary
public ProtectedPKIMessageBuilder addCMPCertificate(X509CertificateHolder extraCert)

Add an "extra certificate" to the message.

Parameters
extraCert:X509CertificateHolder

the extra certificate to add.

Returns:ProtectedPKIMessageBuilder

the current builder instance.

addGeneralInfoback to summary
public ProtectedPKIMessageBuilder addGeneralInfo(InfoTypeAndValue genInfo)

Add a generalInfo data record to the header of the new message.

Parameters
genInfo:InfoTypeAndValue

the generalInfo data to be added.

Returns:ProtectedPKIMessageBuilder

the current builder instance.

buildback to summary
public ProtectedPKIMessage build(MacCalculator macCalculator) throws CMPException

Build a protected PKI message which has MAC based integrity protection.

Parameters
macCalculator:MacCalculator

MAC calculator.

Returns:ProtectedPKIMessage

the resulting protected PKI message.

Exceptions
CMPException:
if the protection MAC cannot be calculated.
buildback to summary
public ProtectedPKIMessage build(ContentSigner signer) throws CMPException

Build a protected PKI message which has MAC based integrity protection.

Parameters
signer:ContentSigner

the ContentSigner to be used to calculate the signature.

Returns:ProtectedPKIMessage

the resulting protected PKI message.

Exceptions
CMPException:
if the protection signature cannot be calculated.
calculateMacback to summary
private byte[] calculateMac(MacCalculator macCalculator, PKIHeader header, PKIBody body) throws IOException
calculateSignatureback to summary
private byte[] calculateSignature(ContentSigner signer, PKIHeader header, PKIBody body) throws IOException
finaliseHeaderback to summary
private void finaliseHeader(AlgorithmIdentifier algorithmIdentifier)
finaliseMessageback to summary
private ProtectedPKIMessage finaliseMessage(PKIHeader header, DERBitString protection)
setBodyback to summary
public ProtectedPKIMessageBuilder setBody(PKIBody body)

Set the body for the new message

Parameters
body:PKIBody

the message body.

Returns:ProtectedPKIMessageBuilder

the current builder instance.

setFreeTextback to summary
public ProtectedPKIMessageBuilder setFreeText(PKIFreeText freeText)

Include a human-readable message in the new message.

Parameters
freeText:PKIFreeText

the contents of the human readable message,

Returns:ProtectedPKIMessageBuilder

the current builder instance.

setMessageTimeback to summary
public ProtectedPKIMessageBuilder setMessageTime(Date time)

Set the creation time for the new message.

Parameters
time:Date

the message creation time.

Returns:ProtectedPKIMessageBuilder

the current builder instance.

setRecipKIDback to summary
public ProtectedPKIMessageBuilder setRecipKID(byte[] kid)

Set the recipient key identifier for the key to be used to verify the new message.

Parameters
kid:byte[]

a key identifier.

Returns:ProtectedPKIMessageBuilder

the current builder instance.

setRecipNonceback to summary
public ProtectedPKIMessageBuilder setRecipNonce(byte[] nonce)

Set the recipient nonce field on the new message.

Parameters
nonce:byte[]

a NONCE, typically copied from the sender nonce of the previous message.

Returns:ProtectedPKIMessageBuilder

the current builder instance.

setSenderKIDback to summary
public ProtectedPKIMessageBuilder setSenderKID(byte[] kid)

Set the sender key identifier for the key used to protect the new message.

Parameters
kid:byte[]

a key identifier.

Returns:ProtectedPKIMessageBuilder

the current builder instance.

setSenderNonceback to summary
public ProtectedPKIMessageBuilder setSenderNonce(byte[] nonce)

Set the sender nonce field on the new message.

Parameters
nonce:byte[]

a NONCE, typically 128 bits of random data.

Returns:ProtectedPKIMessageBuilder

the current builder instance.

setTransactionIDback to summary
public ProtectedPKIMessageBuilder setTransactionID(byte[] tid)

Set the identifier for the transaction the new message will belong to.

Parameters
tid:byte[]

the transaction ID.

Returns:ProtectedPKIMessageBuilder

the current builder instance.