|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.rsa.certj.pkcs7.ContentInfo
This class is the superclass for all PKCS #7 content classes.
The following are the supported PKCS #7 content types and their respective Cert-J classes:PKCS #7 Content Type | Cert-J PKCS #7 Class | |||
Data | Data | |||
SignedData | SignedData | |||
EnvelopedData | EnvelopedData | |||
DigestedData | DigestedData | |||
EncryptedData | EncryptedData |
ContentInfo ::= SEQUENCE { contentType OBJECT IDENTIFIER content [0] EXPLICIT ANY DEFINED BY contentType OPTIONAL } |
See Also
Field Summary |
|
static int |
DATA
This flag indicates that the |
static int |
DIGESTED_DATA
This flag indicates that the |
static int |
ENCRYPTED_DATA
This flag indicates that the |
static int |
ENVELOPED_DATA
This flag indicates that the |
static int |
NO_CONTENT
This flag indicates that there is currently no content in this
object, that is, there is no |
static int |
PKCS7_VERSION_NUMBER_0
This indicates that PKCS #7 syntax version is |
static int |
PKCS7_VERSION_NUMBER_1
This indicates that PKCS #7 syntax version is |
static int |
SIGNED_DATA
This flag indicates that the |
Method Summary |
|
int |
bytesRead()
Indicates how many bytes were read during the
calls to |
void |
clearInternalContentBuffer()
Clears the internal working buffer that contains the entire ContentInfo encoding of a newly read and parsed message. |
void |
clearSensitiveData()
Clears any sensitive data. |
clone()
Overrides the default |
|
boolean |
endOfMessage()
Indicates whether the end of the message has been reached. |
getContent()
This method returns a copy of the |
|
int |
getContentInfoDERLen()
Gets the total length of the DER-encoded |
int |
getContentInfoDERLen(int special)
Gets the total length of the DER-encoded |
int |
getContentType()
This method returns the flag indicating the |
getDevice()
Gets the name of the device that actually performed the encrypting or decrypting. |
|
String[] |
getDeviceList()
Gets a list of names of devices that actually performed the individual elements of the encrypting or decrypting. |
static ContentInfo |
getInstance(byte[] oid,
int offset,
int oidLen,
CertJ certJ,
CertPathCtx pathCtx)
Builds the appropriate |
static ContentInfo |
getInstance(int type,
CertJ certJ,
CertPathCtx pathCtx)
Builds the appropriate |
static int |
getMessageType(byte[] data,
int offset,
int len)
Returns the |
static int |
getMessageType(byte[] data,
int offset,
int len,
int special)
Returns the |
int |
getUnprocessedDataLen()
Returns the number of bytes in the internal buffer that contains the unprocessed data. |
boolean |
readFinal()
Finishes the process of decoding the |
boolean |
readInit(byte[] input,
int inOffset,
int maxInputLen)
Begins decoding the |
boolean |
readInit(byte[] input,
int inOffset,
int maxInputLen,
int special)
Begins decoding the |
boolean |
readInit(byte[] input,
int inOffset,
int maxInputLen,
int special,
int maxBufferSize)
Begins decoding the |
int |
readUpdate(byte[] input,
int inOffset,
int maxInputLen)
Continues decoding the given |
void |
setCertJ(CertJ certJ)
Sets the |
void |
setCertPath(CertPathCtx pathCtx)
Sets the |
void |
setDevice(String device)
Sets the name of the device any cryptographic operations should use. |
int |
writeMessage(byte[] output,
int outOffset)
Creates the entire |
int |
writeMessage(byte[] output,
int outOffset,
int special)
Creates the entire |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int DATA
ContentType
is
Data
. This is also the last octet of the OID.public static final int SIGNED_DATA
ContentType
is
SignedData
. This is also the last octet of the OID.public static final int ENVELOPED_DATA
ContentType
is
EnvelopedData
. This is also the last octet of the OID.public static final int DIGESTED_DATA
ContentType
is
DigestedData
. This is also the last octet of the OID.public static final int ENCRYPTED_DATA
ContentType
is
EncryptedData
. This is also the last octet of the OID.public static final int NO_CONTENT
ContentType
.public static final int PKCS7_VERSION_NUMBER_0
0
.public static final int PKCS7_VERSION_NUMBER_1
1
.Method Detail |
public static ContentInfo getInstance(int type, CertJ certJ, CertPathCtx pathCtx) throws PKCS7Exception
ContentInfo
object. The input is one of the fields defined in this class.Parameters
type | The PKCS #7 content type. | ||
certJ | A | ||
pathCtx | A |
Returns
ContentInfo
object, which is
an instance of the appropriate subclass.
Throws
PKCS7Exception
- If the OID is not a
valid PKCS #7 ContentInfo
.public static ContentInfo getInstance(byte[] oid, int offset, int oidLen, CertJ certJ, CertPathCtx pathCtx) throws PKCS7Exception
ContentInfo
object
with the given object identifier. The input is one
of the object identifiers defined in PKCS #7. For more
information about PKCS #7, see the RSA Laboratories Web
site (http://www.rsasecurity.com/rsalabs/pkcs/
).Parameters
oid | The OID of the content type. | ||
offset | The offset into oid where the information actually begins. | ||
oidLen | The length of the OID. | ||
certJ | A | ||
pathCtx | A |
Returns
ContentInfo
object, which is an
instance of the appropriate subclass.
Throws
PKCS7Exception
- If the OID is not a
valid PKCS #7 contentType
.public static int getMessageType(byte[] data, int offset, int len) throws PKCS7Exception
ContentInfo
type, given the PKCS
#7 message or the first part of it that
contains the PKCS #7 message OID. If there is not enough
data, then this method returns -1
and can be
tried again.Parameters
data | A | ||
offset | The offset into | ||
len | The length of the data. |
Returns
Throws
PKCS7Exception
- If the OID is not a valid
PKCS #7 contentType
, or if the BER encoding is invalid.public static int getMessageType(byte[] data, int offset, int len, int special) throws PKCS7Exception
ContentInfo
type, given the PKCS
#7 message or the first part of it that
contains the PKCS #7 message OID. If there is not enough
data, then this method returns -1
and can be
tried again.Parameters
data | A | ||
offset | The offset into | ||
len | The length of the data. | ||
special | Special ASN.1 info, such as |
Returns
Throws
PKCS7Exception
- If the OID is not a valid
PKCS #7 contentType
, or if the BER encoding is invalid.public void setDevice(String device)
CertJ
object.Parameters
device | A
|
public String getDevice()
CertJ
object. If CertJ
object
is also null
, this method returns null
.
Returns
String
specifying the device chosen to perform
the encrypting or decrypting.public String[] getDeviceList()
CertJ
object. If CertJ
object is also null, this method returns
null.
Returns
String
array specifying the devices
chosen to perform the encrypting or decrypting.public int getContentType()
contentType
of the contents of this object. See the list of fields for this class
for more information.
Returns
contentType
of the
contents of this object. If there is no content,
this method returns NO_CONTENT
.public void setCertJ(CertJ certJ)
CertJ
object.Parameters
certJ | A |
public void setCertPath(CertPathCtx pathCtx)
CertPathCtx
object for path validation.Parameters
pathCtx | A |
public ContentInfo getContent()
PKCS7Content
object
and its contents. If there are no contents, this method returns
null
.
Returns
null
.public int getContentInfoDERLen() throws PKCS7Exception
contentInfo
of the PKCS #7 message. This method can
only be called before any writing begins. This
method returns the length of the content of a PKCS #7
message created by calling writeMessage
.
Returns
contentInfo
portion of a message
that contains data of length dataLen.
Throws
PKCS7Exception
- If the object
has already performed some message writing.public int getContentInfoDERLen(int special) throws PKCS7Exception
contentInfo
of the PKCS #7 message. This method can
only be called before any writing begins. This
method returns the length of the content of a PKCS #7
message created by calling writeMessage
.
The ASN.1 definition of contentInfo
is as follows:
ContentInfo ::= SEQUENCE { contentType OBJECT IDENTIFIER content [0] EXPLICIT ANY DEFINED BY contentType OPTIONAL } |
Parameters
special | Any special ASN.1 info, such as |
Returns
int
that contains the total length of
the contentInfo
portion of a message.
Throws
PKCS7Exception
- If the object
has already performed some message writing.public int writeMessage(byte[] output, int outOffset) throws PKCS7Exception
contentInfo
of the PKCS #7 message,
placing the result into output, beginning
at outOffset. The return value is the number of bytes placed
into the output buffer.Parameters
output | The buffer into which this method will place output. | ||
outOffset | The offset into output where the method will begin placing data. |
Returns
Throws
PKCS7Exception
- If the engine cannot execute some of the
required functions. For example, if the message is
EnvelopedData
and the PKCS7EnvelopedData
object has not been set with the recipient's
public key, then this method would throw an exception.public int writeMessage(byte[] output, int outOffset, int special) throws PKCS7Exception
contentInfo
of the PKCS #7 message,
placing the result into output, beginning
at outOffset. The return value is the number of bytes placed
into the output buffer.Parameters
output | The buffer into which this method will place output. | ||
outOffset | The offset into output where the method will begin placing data. | ||
special | Any special ASN.1 info, such as |
Returns
Throws
PKCS7Exception
- If the engine cannot execute some of the
required functions. For example, if the message is
EnvelopedData
and the PKCS7EnvelopedData
object has not been set with the recipient's
public key, then this method would throw an exception.public boolean readInit(byte[] input, int inOffset, int maxInputLen) throws PKCS7Exception
contentInfo
of the given
PKCS #7 message. This method will read the header
information of the ContentInfo
. If the input
data contains all the necessary information, this
method returns true
. If this method needs
more of the message, it returns false
.
Calling the readUpdate
method before the
readInit
method will result in an
exception.
This method creates the necessary content objects and
stores any data beyond the PKCS #7 header information.
endOfMessage
method to
determine whether there is more message to input to this
object. bytesRead
method
to determine how many of the bytes of the input buffer
this object actually read in the calls to
readInit
and readUpdate
.Parameters
input | The content of a PKCS #7 message, or part of it. | ||
inOffset | The offset into input where the input begins. | ||
maxInputLen | The maximum number of bytes of input to examine with this method. |
Returns
boolean
that indicates whether
this method was given enough of the message to read all
the header information.
true
, do not call the
readInit
method again; call the
readUpdate
method instead.
false
,
do not call the readUpdate
method;
call the readInit
method again with a larger part of
the message.
Throws
PKCS7Exception
- If the input is invalid or null
.public boolean readInit(byte[] input, int inOffset, int maxInputLen, int special) throws PKCS7Exception
contentInfo
of the given
PKCS #7 message. This method will read the header
information of the ContentInfo
. If the input
data contains all the necessary information, then this
method returns true
. If this method needs
more of the message, then it returns false
.
Calling the readUpdate
method before the
readInit
method will result in an
exception.
This method creates the necessary content objects and
stores any data beyond the PKCS #7 header information.
endOfMessage
method to
determine whether there is more message text to input to this
object. bytesRead
method
to determine how many of the bytes of the input buffer
this object actually read in the calls to
readInit
and readUpdate
.Parameters
input | The content of a PKCS #7 message, or part of it. | ||
inOffset | The offset into input where the input begins. | ||
maxInputLen | The maximum number of bytes of input to examine with this method. | ||
special | Any special ASN.1 info, such as OPTIONAL. |
Returns
boolean
that indicates whether
this method was given enough of the message to read all
the header information.
true
, do not call the
readInit
method again; call the
readUpdate
method instead.
false
,
do not call the readUpdate
method;
call the readInit
method again with a larger part of
the message.
Throws
PKCS7Exception
- If the input is invalid or null
.public boolean readInit(byte[] input, int inOffset, int maxInputLen, int special, int maxBufferSize) throws PKCS7Exception
contentInfo
of the given
PKCS #7 message. This method will read the header
information of the ContentInfo
. If the input
data contains all the necessary information, then this
method returns true
. If this method needs
more of the message, then it returns false
.
Calling the readUpdate
method before the
readInit
method will result in an
exception.
This method creates the necessary content objects and
stores any data beyond the PKCS #7 header information.
endOfMessage
method to
determine whether there is more message text to input to this
object. bytesRead
method
to determine how many of the bytes of the input buffer
this object actually read in the calls to
readInit
and readUpdate
.Parameters
input | The content of a PKCS #7 message, or part of it. | ||
inOffset | The offset into input where the input begins. | ||
maxInputLen | The maximum number of bytes of input to examine with this method. | ||
special | Any special ASN.1 info, such as OPTIONAL. | ||
maxBufferSize | the total size of the data to decode. The buffer of
this size will be allocated to avoid future incremental increase of the
buffer and copying data into it during the decoding of the data.
This value must be equal or bigger than the size of the data!! If
you don't know the size of the message or it is small, use different
|
Returns
boolean
that indicates whether
this method was given enough of the message to read all
the header information.
true
, do not call the
readInit
method again; call the
readUpdate
method instead.
false
,
do not call the readUpdate
method;
call the readInit
method again with a larger part of
the message.
Throws
PKCS7Exception
- If the input is invalid or null
.public int readUpdate(byte[] input, int inOffset, int maxInputLen) throws PKCS7Exception
contentInfo
of a PKCS #7
message, returning the number of bytes that were read.
This method processes as much data as it can and places the
rest into the internal buffer.
Call getUnprocessedDataLen
to find out the quantity of
data in the internal buffer.Parameters
input | The content of a PKCS #7 message. | ||
inOffset | The offset into input where the data begins. | ||
maxInputLen | The maximum number of bytes of input to examine. |
Returns
Throws
PKCS7Exception
- If the
engine cannot execute some of the
required functions. For example, if the message is
EnvelopedData
, this method will try to decrypt
the session key with the private key. If the private key has
not been loaded yet, or decrypting the envelope does not work,
an exception will be thrown.public boolean readFinal() throws PKCS7Exception
contentInfo
of
this object. This method will verify that all the information was
passed.
If the return value is false
, it means that
either an insufficient amount of data was passed or that the
BER encoding is invalid.
Returns
boolean
indicating whether the user
passed complete and valid BER encoding.
Throws
PKCS7Exception
- If BER encoding is invalid.public int bytesRead()
readInit
and readUpdate
.public boolean endOfMessage()
Returns
boolean
that indicates whether the end of
the message has been reached.public int getUnprocessedDataLen()
Returns
public Object clone() throws CloneNotSupportedException
clone
method to get a deeper clone.
Returns
ContentInfo
object,
a copy of this object.
Throws
CloneNotSupportedException
- If the cloning operation
is not successful.public void clearInternalContentBuffer()
writeMessage()
method) will cause the encoding to be
re-generated from the component parts. For virtually all uses of reading
and writing messages you do not need this method and its use is
discouraged.public void clearSensitiveData()
finalizer
will clear
the data, but it is not known when the garbage collector will call the
finalizer
. This method clears all sensitive data as soon
as possible.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |