com.ibm.security12.sun.security.pkcs
Class PKCS7

java.lang.Object
  |
  +--com.ibm.security12.sun.security.pkcs.PKCS7

public class PKCS7
extends Object

PKCS7 as defined in RSA Laboratories PKCS7 Technical Note. Profile Supports only SignedData ContentInfo type, where to the type of data signed is plain Data. For signedData, crls, attributes and PKCS#6 Extended Certificates are not supported.

Version:
1.42 98/09/11
Author:
Benjamin Renaud

Constructor Summary
PKCS7(AlgorithmId[] digestAlgorithmIds, ContentInfo contentInfo, X509Certificate[] certificates, SignerInfo[] signerInfos)
          Construct an initialized PKCS7 block.
PKCS7(byte[] bytes)
          Unmarshals a PKCS7 block from its encoded form, parsing the encoded bytes.
PKCS7(DerInputStream derin)
          Unmarshals a PKCS7 block from its encoded form, parsing the encoded bytes from the DerInputStream.
PKCS7(InputStream in)
          Unmarshals a PKCS7 block from its encoded form, parsing the encoded bytes from the InputStream.
 
Method Summary
 void encodeSignedData(DerOutputStream out)
          Encodes the signed data to a DerOutputStream.
 void encodeSignedData(OutputStream out)
          Encodes the signed data to an output stream.
 X509Certificate getCertificate(BigInt serial, X500Name name)
          Returns the X.509 certificate listed in this PKCS7 block which has a matching serial number and Issuer name, or null if one is not found.
 X509Certificate[] getCertificates()
          Returns the X.509 certificates listed in this PKCS7 block.
 ContentInfo getContentInfo()
          Returns the content information specified in this PKCS7 block.
 X509CRL[] getCRLs()
          Returns the X.509 crls listed in this PKCS7 block.
 AlgorithmId[] getDigestAlgorithmIds()
          Returns the message digest algorithms specified in this PKCS7 block.
 SignerInfo[] getSignerInfos()
          Returns the signer's information specified in this PKCS7 block.
 BigInt getVersion()
          Returns the version number of this PKCS7 block.
 boolean isOldStyle()
          Returns true if this is a JDK1.1.x-style PKCS#7 block, and false otherwise.
 String toString()
          Returns the PKCS7 block in a printable string form.
 SignerInfo[] verify()
          Returns all signerInfos which self-verify.
 SignerInfo[] verify(byte[] bytes)
          Returns all signerInfos which self-verify.
 SignerInfo verify(SignerInfo info, byte[] bytes)
          This verifies a given SignerInfo.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PKCS7

public PKCS7(InputStream in)
      throws sun.security.pkcs.ParsingException,
             IOException
Unmarshals a PKCS7 block from its encoded form, parsing the encoded bytes from the InputStream.
Parameters:
in - an input stream holding at least one PKCS7 block.
Throws:
sun.security.pkcs.ParsingException - on parsing errors.
IOException - on other errors.

PKCS7

public PKCS7(DerInputStream derin)
      throws sun.security.pkcs.ParsingException
Unmarshals a PKCS7 block from its encoded form, parsing the encoded bytes from the DerInputStream.
Parameters:
derin - a DerInputStream holding at least one PKCS7 block.
Throws:
sun.security.pkcs.ParsingException - on parsing errors.

PKCS7

public PKCS7(byte[] bytes)
      throws sun.security.pkcs.ParsingException
Unmarshals a PKCS7 block from its encoded form, parsing the encoded bytes.
Parameters:
bytes - the encoded bytes.
Throws:
sun.security.pkcs.ParsingException - on parsing errors.

PKCS7

public PKCS7(AlgorithmId[] digestAlgorithmIds,
             ContentInfo contentInfo,
             X509Certificate[] certificates,
             SignerInfo[] signerInfos)
Construct an initialized PKCS7 block.
Parameters:
digestAlgorithmIds - the message digest algorithm identifiers.
contentInfo - the content information.
certificates - an array of X.509 certificates.
signerInfos - an array of signer information.
Method Detail

encodeSignedData

public void encodeSignedData(OutputStream out)
                      throws IOException
Encodes the signed data to an output stream.
Parameters:
out - the output stream to write the encoded data to.
Throws:
IOException - on encoding errors.

encodeSignedData

public void encodeSignedData(DerOutputStream out)
                      throws IOException
Encodes the signed data to a DerOutputStream.
Parameters:
out - the DerOutputStream to write the encoded data to.
Throws:
IOException - on encoding errors.

verify

public SignerInfo verify(SignerInfo info,
                         byte[] bytes)
                  throws NoSuchAlgorithmException,
                         SignatureException
This verifies a given SignerInfo.
Parameters:
info - the signer information.
bytes - the DER encoded content information.
Throws:
NoSuchAlgorithmException - on unrecognized algorithms.
SignatureException - on signature handling errors.

verify

public SignerInfo[] verify(byte[] bytes)
                    throws NoSuchAlgorithmException,
                           SignatureException
Returns all signerInfos which self-verify.
Parameters:
bytes - the DER encoded content information.
Throws:
NoSuchAlgorithmException - on unrecognized algorithms.
SignatureException - on signature handling errors.

verify

public SignerInfo[] verify()
                    throws NoSuchAlgorithmException,
                           SignatureException
Returns all signerInfos which self-verify.
Throws:
NoSuchAlgorithmException - on unrecognized algorithms.
SignatureException - on signature handling errors.

getVersion

public BigInt getVersion()
Returns the version number of this PKCS7 block.
Returns:
the version or null if version is not specified for the content type.

getDigestAlgorithmIds

public AlgorithmId[] getDigestAlgorithmIds()
Returns the message digest algorithms specified in this PKCS7 block.
Returns:
the array of Digest Algorithms or null if none are specified for the content type.

getContentInfo

public ContentInfo getContentInfo()
Returns the content information specified in this PKCS7 block.

getCertificates

public X509Certificate[] getCertificates()
Returns the X.509 certificates listed in this PKCS7 block.
Returns:
the array of X.509 certificates or null if none are specified for the content type.

getCRLs

public X509CRL[] getCRLs()
Returns the X.509 crls listed in this PKCS7 block.
Returns:
the array of X.509 crls or null if none are specified for the content type.

getSignerInfos

public SignerInfo[] getSignerInfos()
Returns the signer's information specified in this PKCS7 block.
Returns:
the array of Signer Infos or null if none are specified for the content type.

getCertificate

public X509Certificate getCertificate(BigInt serial,
                                      X500Name name)
Returns the X.509 certificate listed in this PKCS7 block which has a matching serial number and Issuer name, or null if one is not found.
Parameters:
serial - the serial number of the certificate to retrieve.
name - the Distinguished Name of the Issuer.

toString

public String toString()
Returns the PKCS7 block in a printable string form.
Overrides:
toString in class Object

isOldStyle

public boolean isOldStyle()
Returns true if this is a JDK1.1.x-style PKCS#7 block, and false otherwise.