public class Receipt extends java.lang.Object implements Content
The Enhanced Security Services
for S/MIMEv3 (ESS) (RFC 2634) specifies the Receipt
content type to be set as content of a SignedData
which shall be sent in response to a ReceiptRequest
received:
Receipt ::= SEQUENCE { version ESSVersion, contentType ContentType, signedContentIdentifier ContentIdentifier, originatorSignatureValue OCTET STRING } id-ct-receipt OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-9(9) smime(16) id-ct(1) 1} ESSVersion ::= INTEGER { v1(1) }When receiving a
SignedData
having any
SignerInfo
holding a ReceiptRequest
the recipient first has to check
if all ReceiptRequests contained in any of the SignerInfos are
identical. According to the rules given in
RFC 2634, section 2.3,
the recipient then checks if it is requested to create signed
receipt(s) to be sent to dedicated user(s). If a signed
receipt has to be sent, the recipient performs the following
steps for creating the signed receipt and setting it as
content of a SignedData object ("signedData/Receipt", see
RFC 2634, section 2.4):
creating
a new Receipt you may specify the content type, signed content
identifier and originator signature value immediately:
ObjectID contentType = ...; ContentIdentifier contentIdentifier = ...; byte[] originatorSignatureValue = ...; Receipt Receipt = new Receipt(contentType, contentIdentifier, originatorSignatureValue);Or you may
create
a Receipt from a SignerInfo
letting the constructor get the required information from the SignerInfo
to set the fields of the Receipt as required:
SignerInfo signerInfo = ...; Receipt receipt = new Receipt(signerInfo);
ReceiptRequest
,
ContentIdentifier
,
SignerInfo
,
SignedData
Modifier and Type | Field and Description |
---|---|
static iaik.asn1.ObjectID |
oid
The content type object identifier of the
Receipt structure. |
Constructor and Description |
---|
Receipt()
Empty default constructor.
|
Receipt(iaik.asn1.ASN1Object obj)
Creates an Receipt from its ASN.1 representation.
|
Receipt(java.io.InputStream is)
Creates a Receipt from an input stream supplying the DER encoded Receipt.
|
Receipt(iaik.asn1.ObjectID contentType,
ContentIdentifier signedContentIdentifier,
byte[] originatorSignatureValue)
Creates an Receipt from given content type,
content identifier and originator signature value.
|
Receipt(SignerInfo signerInfo)
Creates an Receipt from the given SignerInfo.
|
Modifier and Type | Method and Description |
---|---|
void |
decode(iaik.asn1.ASN1Object obj)
Decodes the given ASN.1
Receipt object for parsing
the internal structure. |
void |
decode(java.io.InputStream is)
Reads and decodes a DER encoded Receipt from the given input stream.
|
boolean |
equals(java.lang.Object obj)
Compares this
Receipt to the specified object. |
int |
getBlockSize()
Returns -1.
|
iaik.asn1.ObjectID |
getContentType()
Returns the ESS Receipt (id-cd-receipt) content type object identifier.
|
byte[] |
getEncoded()
DER encodes this ESS
Receipt object. |
byte[] |
getOriginatorSignatureValue()
Returns the originator signature value.
|
iaik.asn1.ObjectID |
getReceiptContentType()
Returns the content type.
|
SecurityProvider |
getSecurityProvider()
Returns null since no SecurityProvider is required by this class.
|
ContentIdentifier |
getSignedContentIdentifier()
Returns the signed content identifier.
|
int |
getVersion()
Gets the ESSVersion number.
|
int |
hashCode()
Returns a hashcode for this
Receipt . |
void |
setBlockSize(int blockSize)
Does nothing.
|
void |
setSecurityProvider(SecurityProvider securityProvider)
Does nothing since no SecurityProvider is required by this class.
|
iaik.asn1.ASN1Object |
toASN1Object()
Returns this Receipt as ASN1Object.
|
java.lang.String |
toString()
Returns a string representation of this Receipt.
|
java.lang.String |
toString(boolean detailed)
Returns a string representation of this Receipt.
|
void |
writeTo(java.io.OutputStream os)
Writes this ESS
Receipt object DER encoded to the given output stream. |
public static final iaik.asn1.ObjectID oid
Receipt
structure.
The corresponding OID string is "1.2.840.113549.1.9.16.1.1".public Receipt()
public Receipt(iaik.asn1.ObjectID contentType, ContentIdentifier signedContentIdentifier, byte[] originatorSignatureValue)
contentType
- the content type of the of the SignedData
to be linked tosignedContentIdentifier
- the signed content identifier
of the SignedData to be linked tooriginatorSignatureValue
- the signature value of the
SignedData to be linked topublic Receipt(SignerInfo signerInfo) throws ESSException
This constructor follows the instructions given in RFC 2634, section 2.4, 2:
signerInfo
- the signerInfo from which to create a ReceiptESSException
- if the Receipt cannot be created for some
reason, e.g. no ReceiptRequest is included in the
supplied SignerInfopublic Receipt(java.io.InputStream is) throws java.io.IOException, CMSParsingException
is
- the input stream from where to read the encoded ReceiptCMSParsingException
- if the object cannot be paresdjava.io.IOException
- if an error occurs while reading from the streampublic Receipt(iaik.asn1.ASN1Object obj) throws CMSParsingException
obj
- the Receipt as ASN1ObjectCMSParsingException
- if the object cannot be paresdpublic void setSecurityProvider(SecurityProvider securityProvider)
ContentStream
interface.securityProvider
- the SecurityProvider to be set; ignoredpublic SecurityProvider getSecurityProvider()
ContentStream
interface.public int getVersion()
public int getBlockSize()
Content
interface, but has no meaning here.getBlockSize
in interface ContentStream
public void setBlockSize(int blockSize)
Content
interface., but has no meaning here.setBlockSize
in interface ContentStream
blockSize
- the block size; ignored herepublic iaik.asn1.ObjectID getReceiptContentType()
Attention! The OID returned by this method is the content type as given in the second component of an Receipt object and represents the value of the contentType attribute included in the original signedData signerInfo that includes the receiptRequest:
Receipt ::= SEQUENCE { version ESSVersion, contentType ContentType, signedContentIdentifier ContentIdentifier, originatorSignatureValue OCTET STRING }It has to be distinguished from the content type returned by method
getContentType
which always
returns the id-cd-receipt oid.public ContentIdentifier getSignedContentIdentifier()
public byte[] getOriginatorSignatureValue()
public boolean equals(java.lang.Object obj)
Receipt
to the specified object.equals
in class java.lang.Object
obj
- the object to compare this Receipt
against.true
, if the given object is equal to this
Receipt
,
false
otherwisepublic int hashCode()
Receipt
.hashCode
in class java.lang.Object
Receipt
public void decode(java.io.InputStream is) throws java.io.IOException, CMSParsingException
decode
in interface ContentStream
is
- the input stream from where to read the encoded ReceiptCMSParsingException
- if the object cannot be paresdjava.io.IOException
- if an error occurs while reading from the streampublic void decode(iaik.asn1.ASN1Object obj) throws CMSParsingException
Receipt
object for parsing
the internal structure.decode
in interface Content
obj
- the Receipt as ASN1ObjectCMSParsingException
- if the object cannot be paresdpublic iaik.asn1.ASN1Object toASN1Object()
toASN1Object
in interface ContentStream
public iaik.asn1.ObjectID getContentType()
Attention! This method implements the smae name method of
the Content
interface to always
return the id-ct-receipt oid.
The content type returned by this method has to be distinguished
from the content type returned by method getReceiptContentType()
which returns the content
type as given in the second component of an Receipt object:
Receipt ::= SEQUENCE { version ESSVersion, contentType ContentType, signedContentIdentifier ContentIdentifier, originatorSignatureValue OCTET STRING }
getContentType
in interface ContentStream
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toString(boolean detailed)
toString
in interface ContentStream
detailed
- whether to give detailed informationpublic byte[] getEncoded() throws CMSException
Receipt
object.CMSException
- if an encoding error occurspublic void writeTo(java.io.OutputStream os) throws java.io.IOException
Receipt
object DER encoded to the given output stream.os
- the output stream to which to encode the Receiptjava.io.IOException
- if an error occurs during encoding to the stream