public class

PKCS7

extends Object
java.lang.Object
   ↳ sun.security.pkcs.PKCS7

Class Overview

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.

Summary

Public Constructors
PKCS7(InputStream in)
Unmarshals a PKCS7 block from its encoded form, parsing the encoded bytes from the InputStream.
PKCS7(DerInputStream derin)
Unmarshals a PKCS7 block from its encoded form, parsing the encoded bytes from the DerInputStream.
PKCS7(byte[] bytes)
Unmarshals a PKCS7 block from its encoded form, parsing the encoded bytes.
PKCS7(AlgorithmId[] digestAlgorithmIds, ContentInfo contentInfo, X509Certificate[] certificates, SignerInfo[] signerInfos)
Construct an initialized PKCS7 block.
Public Methods
void encodeSignedData(OutputStream out)
Encodes the signed data to an output stream.
void encodeSignedData(DerOutputStream out)
Encodes the signed data to a DerOutputStream.
X509CRL[] getCRLs()
Returns the X.509 crls listed in this PKCS7 block.
X509Certificate getCertificate(BigInteger serial, X500Name issuerName)
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.
AlgorithmId[] getDigestAlgorithmIds()
Returns the message digest algorithms specified in this PKCS7 block.
SignerInfo[] getSignerInfos()
Returns the signer's information specified in this PKCS7 block.
BigInteger 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.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public PKCS7 (InputStream in)

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
ParsingException on parsing errors.
IOException on other errors.

public PKCS7 (DerInputStream derin)

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
ParsingException on parsing errors.

public PKCS7 (byte[] bytes)

Unmarshals a PKCS7 block from its encoded form, parsing the encoded bytes.

Parameters
bytes the encoded bytes.
Throws
ParsingException on parsing errors.

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.

Public Methods

public void encodeSignedData (OutputStream out)

Encodes the signed data to an output stream.

Parameters
out the output stream to write the encoded data to.
Throws
IOException on encoding errors.

public void encodeSignedData (DerOutputStream out)

Encodes the signed data to a DerOutputStream.

Parameters
out the DerOutputStream to write the encoded data to.
Throws
IOException on encoding errors.

public X509CRL[] getCRLs ()

Returns the X.509 crls listed in this PKCS7 block.

Returns
  • a clone of the array of X.509 crls or null if none are specified for the content type.

public X509Certificate getCertificate (BigInteger serial, X500Name issuerName)

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.
issuerName the Distinguished Name of the Issuer.

public X509Certificate[] getCertificates ()

Returns the X.509 certificates listed in this PKCS7 block.

Returns
  • a clone of the array of X.509 certificates or null if none are specified for the content type.

public ContentInfo getContentInfo ()

Returns the content information specified in this PKCS7 block.

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.

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.

public BigInteger getVersion ()

Returns the version number of this PKCS7 block.

Returns
  • the version or null if version is not specified for the content type.

public boolean isOldStyle ()

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

public String toString ()

Returns the PKCS7 block in a printable string form.

Returns
  • a string representation of the object.

public SignerInfo[] verify ()

Returns all signerInfos which self-verify.

Throws
NoSuchAlgorithmException on unrecognized algorithms.
SignatureException on signature handling errors.

public SignerInfo[] verify (byte[] bytes)

Returns all signerInfos which self-verify.

Parameters
bytes the DER encoded content information.
Throws
NoSuchAlgorithmException on unrecognized algorithms.
SignatureException on signature handling errors.

public SignerInfo verify (SignerInfo info, byte[] bytes)

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.