|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.security.pkcsutil.PKCSDerObject | +--com.ibm.security.pkcs7.ContentInfo
Implements the ASN.1 ContentInfo type.
ContentInfo objects are not immutable; they can be changed once created. ContentInfo may contain an instance of a Content object that is mutable.
Data
,
SignedData
,
EnvelopedData
,
SignedAndEnvelopedData
,
DigestedData
,
EncryptedData
,
AuthenticatedData
Fields inherited from class com.ibm.security.pkcsutil.PKCSDerObject |
provider |
Constructor Summary | |
ContentInfo(byte[] der)
Create a ContentInfo object with a DER-encoded byte array. |
|
ContentInfo(byte[] der,
String provider)
Create a ContentInfo object with a DER-encoded byte array. |
|
ContentInfo(Content content)
Create a ContentInfo object with a preconstructed Content object. |
|
ContentInfo(Content content,
String provider)
Create a ContentInfo object with a preconstructed Content object. |
|
ContentInfo(ObjectIdentifier contentType,
byte[] bytes)
Create a ContentInfo object with an ObjectIdenfitier for the contentType and a DER byte array without the leading tag or length for the content. |
|
ContentInfo(ObjectIdentifier contentType,
byte[] bytes,
String provider)
Create a ContentInfo object with an ObjectIdenfitier for the contentType and a DER byte array without the leading tag or length for the content. |
|
ContentInfo(String filename,
boolean base64)
Create a ContentInfo with the filename of the DER-encoded or BASE64-encoded object. |
|
ContentInfo(String filename,
boolean base64,
String provider)
Create a ContentInfo with the filename of the DER-encoded or BASE64-encoded object. |
Method Summary | |
Object |
clone()
Creates a clone of this ContentInfo object. |
protected void |
decode(com.ibm.security.pkcs7.DerValue encoding)
Initializes a ContentInfo object from a DerValue. |
ContentInfo |
decrypt(PrivateKey recipientPrivateKey,
Certificate recipientCert)
Decrypts the ContentInfo stored in the ContentInfo object. |
void |
encode(OutputStream os)
Encodes this object to an OutputStream. |
ContentInfo |
encrypt(Certificate[] recipientCerts,
String encryptionAlgorithm,
int keySize)
Encrypts a copy of this ContentInfo with the recipient's certificate(s). |
boolean |
equals(Object other)
Determines if this ContentInfo object is equivalent to the input object. |
Content |
getContent()
Returns a copy of the Content of this ContentInfo object. |
ObjectIdentifier |
getContentType()
Returns a reference to the ObjectIdentifer for the ContentInfo object. |
String |
getContentTypeString()
Returns the string representation of the content type of this ContentInfo object. |
boolean |
isData()
Determines if this ContentInfo object has a ContentType of Data. |
boolean |
isDigestedData()
Determines if this ContentInfo object has a ContentType of DigestedData. |
boolean |
isEncryptedData()
Determines if this ContentInfo object has a ContentType of EncryptedData. |
boolean |
isEnvelopedData()
Determines if this ContentInfo object has a ContentType of EnvelopedData. |
boolean |
isSignedAndEnvelopedData()
Determines if this ContentInfo object has a ContentType of SignedAndEnvelopedData. |
boolean |
isSignedData()
Determines if this ContentInfo object has a ContentType of SignedData. |
protected void |
readBASE64(String filename)
Read the BASE64 encoding of a DER-encode object from the input file and decode the contents into the current object. |
ContentInfo |
seal(Certificate[] recipientCerts,
String encryptionAlgorithm,
int keySize,
Certificate signerCert,
String digestSignatureAlgorithm,
PrivateKey privateKey,
boolean signatureOnly)
Signs and encrypts a copy of this ContentInfo. |
ContentInfo |
sign(Certificate signerCert,
String digestSignatureAlgorithm,
PrivateKey privateKey,
boolean signatureOnly)
Signs a copy of this ContentInfo with the specified certificate and private key. |
String |
toString()
Returns a string representation of this ContentInfo object. |
ContentInfo |
unseal(Certificate recipientCert,
Certificate signerCert,
PrivateKey recipientPrivateKey)
Performs the opposite of the seal operation and returns the decrypted ContentInfo. |
boolean |
verify(Certificate signerCert)
Verifies the SignedData content for this ContentInfo object. |
Methods inherited from class com.ibm.security.pkcsutil.PKCSDerObject |
decode,
decode,
encode,
getObjectIdentifier,
hashCode,
read,
write,
write,
writeBASE64 |
Methods inherited from class java.lang.Object |
finalize,
getClass,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public ContentInfo(byte[] der) throws IOException
der
- a DER-encoded byte array of a ContentInfo object.public ContentInfo(byte[] der, String provider) throws IOException
der
- a DER-encoded byte array of a ContentInfo object.provname
- the name of the java.security provider to usepublic ContentInfo(ObjectIdentifier contentType, byte[] bytes) throws IOException
contentType
- ObjectIdentifier of the Content. The OID value must
be Data, SignedData, EnvelopedData, SignedAndEnvelopedData, DigestedData,
or EncryptedDatabytes
- DER byte array of the content that matches the contentType
without the leading tag or length.public ContentInfo(ObjectIdentifier contentType, byte[] bytes, String provider) throws IOException
contentType
- ObjectIdentifier of the Content. The OID value must
be Data, SignedData, EnvelopedData, SignedAndEnvelopedData, DigestedData,
or EncryptedDatabytes
- DER byte array of the content that matches the contentType
without the leading tag or length.provname
- the name of the java.security provider to usepublic ContentInfo(Content content)
content
- Content objectpublic ContentInfo(Content content, String provider)
content
- Content objectprovname
- the name of the java.security provider the caller is usingpublic ContentInfo(String filename, boolean base64) throws IOException
filename
- name of the DER-encoded or base64-encoded objectbase64
- true if BASE64-encoded, false if DER-encodedpublic ContentInfo(String filename, boolean base64, String provider) throws IOException
filename
- name of the DER-encoded or base64-encoded objectbase64
- true if BASE64-encoded, false if DER-encodedprovname
- the name of the java.security provider to useMethod Detail |
public Object clone()
public boolean equals(Object other)
other
- the object to compare this one to.public void encode(OutputStream os) throws IOException
os
- the OutputStream to write the encoded data to.protected void decode(com.ibm.security.pkcs7.DerValue encoding) throws IOException
encoding
- a DER-encoded ContentInfo object.public ObjectIdentifier getContentType()
public Content getContent()
public boolean isData()
public boolean isSignedData()
public boolean isEnvelopedData()
public boolean isSignedAndEnvelopedData()
public boolean isDigestedData()
public boolean isEncryptedData()
public String getContentTypeString()
public String toString()
public ContentInfo encrypt(Certificate[] recipientCerts, String encryptionAlgorithm, int keySize) throws IOException, PKCSException
recipientCerts
- array of certificates identifying the recipientsencryptionAlgorithm
- encryption algorithmkeySize
- length of the encryption keypublic ContentInfo decrypt(PrivateKey recipientPrivateKey, Certificate recipientCert) throws IOException, PKCSException
recipientPrivateKey
- private key of the recipientrecipientCert
- certificate of the recipientpublic ContentInfo sign(Certificate signerCert, String digestSignatureAlgorithm, PrivateKey privateKey, boolean signatureOnly) throws PKCSException, IOException, NoSuchAlgorithmException
signerCert
- certificate of the signerdigestSignatureAlgorithm
- signature algorithm (e.g., MD5withRSA)privateKey
- private key of the signing certificatesignatureOnly
- indicate if the default signed attributes should be included.public boolean verify(Certificate signerCert) throws PKCSException, IOException, NoSuchAlgorithmException
signerCert
- certificate of the signerpublic ContentInfo seal(Certificate[] recipientCerts, String encryptionAlgorithm, int keySize, Certificate signerCert, String digestSignatureAlgorithm, PrivateKey privateKey, boolean signatureOnly) throws PKCSException, IOException, NoSuchAlgorithmException
recipientCerts
- array of recipient certificatesencryptionAlgorithm
- encryption algorithmkeySize
- size of the encryption keysignerCert
- certificate of the signerdigestSignatureAlgorithm
- signature algorithm (e.g., MD5withRSA)privateKey
- private key of the signersignatureOnly
- indicate if the default signed attributes should be included.public ContentInfo unseal(Certificate recipientCert, Certificate signerCert, PrivateKey recipientPrivateKey) throws PKCSException, IOException, NoSuchAlgorithmException
The content must be of SignedData or EnvelopedData type or the method will throw an IllegalArgumentException.
recipientCert
- certificate of the recipientsignerCert
- certificate of the signerrecipientPrivateKey
- private key of the recipientprotected void readBASE64(String filename) throws IOException
If the file does not contain the header and footer, this method will attempt to decode the entire file.
filename
- the BASE64 file to read an object's DER encoding from.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |