Top Inners Fields Constructors Methods
org.bouncycastle.mail.smime.validator

public Class SignedMailValidator

extends Object
Class Inheritance
Imports
java.io.IOException, java.security.GeneralSecurityException, .PublicKey, java.security.cert.CertPath, .CertStore, .CertStoreException, .CertificateEncodingException, .CertificateExpiredException, .CertificateFactory, .CertificateNotYetValidException, .PKIXParameters, .TrustAnchor, .X509CertSelector, .X509Certificate, java.security.interfaces.DSAPublicKey, .RSAPublicKey, java.util.ArrayList, .Collection, .Date, .HashMap, .HashSet, .Iterator, .LinkedHashSet, .List, .Map, .Set, javax.mail.Address, .MessagingException, javax.mail.internet.InternetAddress, .MimeMessage, .MimeMultipart, org.bouncycastle.asn1.ASN1Encoding, .ASN1IA5String, .ASN1InputStream, .ASN1OctetString, .ASN1Primitive, .ASN1Sequence, .ASN1String, .ASN1TaggedObject, .DEROctetString, org.bouncycastle.asn1.cms.Attribute, .AttributeTable, .CMSAttributes, .Time, org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers, org.bouncycastle.asn1.x500.AttributeTypeAndValue, .RDN, org.bouncycastle.asn1.x509.AuthorityKeyIdentifier, .ExtendedKeyUsage, .Extension, .KeyPurposeId, .TBSCertificate, org.bouncycastle.cert.jcajce.JcaCertStoreBuilder, org.bouncycastle.cms.SignerInformation, .SignerInformationStore, org.bouncycastle.cms.jcajce.JcaSimpleSignerInfoVerifierBuilder, .JcaX509CertSelectorConverter, org.bouncycastle.mail.smime.SMIMESigned, org.bouncycastle.pkix.jcajce.CertPathReviewerException, .PKIXCertPathReviewer, org.bouncycastle.pkix.util.ErrorBundle, org.bouncycastle.pkix.util.filter.TrustedInput, .UntrustedInput, org.bouncycastle.util.Integers

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
private Class<T>
private CertStore
private static final Class<T>
private static final String
private String[]
private static final String
private Map<K, V>
private static final JcaX509CertSelectorConverter
private static final int
private SignerInformationStore
private static final String
private static final long

Constructor Summary

AccessConstructor and Description
public
SignedMailValidator(MimeMessage
the signed MimeMessage
message
,
PKIXParameters
the parameters for the certificate path validation
param
)

Validates the signed MimeMessage message.

public
SignedMailValidator(MimeMessage
the signed MimeMessage
message
,
PKIXParameters
the parameters for the certificate path validation
param
,
Class<T>
a subclass of PKIXCertPathReviewer. The SignedMailValidator uses objects of this type for the cert path vailidation. The class must have an empty constructor.
certPathReviewerClass
)

Validates the signed MimeMessage message.

Method Summary

Modifier and TypeMethod and Description
pack-priv static String
protected void
checkSignerCert(X509Certificate cert, List<E> errors, List<E> notifications)

public static CertPath

Returns:

the resulting certificate path.
createCertPath
(X509Certificate
the end of the path
signerCert
,
Set<E>
trust anchors for the path
trustanchors
,
List<E> certStores)

public static Object[]

Returns:

a CertPath and a List of booleans.
createCertPath
(X509Certificate
the end of the path
signerCert
,
Set<E>
trust anchors for the path
trustanchors
,
List<E>
list of CertStore provided by the system
systemCertStores
,
List<E>
list of CertStore provided by the user
userCertStores
)

Returns an Object array containing a CertPath and a List of Booleans.

private static ErrorBundle
private static ErrorBundle
createErrorBundle(String id, Object[] arguments)

private static List<E>
findCerts(List<E> certStores, X509CertSelector selector)

private static X509Certificate
findNextCert(List<E> certStores, X509CertSelector selector, Set<E> certSet)

public CertStore
public static Set<E>
private static ASN1Primitive
getObject(byte[] ext)

public static Date
public SignerInformationStore
private static TBSCertificate
public SignedMailValidator.ValidationResult
protected void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

certPathReviewerClassback to summary
private Class<T> certPathReviewerClass
certsback to summary
private CertStore certs
DEFAULT_CERT_PATH_REVIEWERback to summary
private static final Class<T> DEFAULT_CERT_PATH_REVIEWER
EXT_KEY_USAGEback to summary
private static final String EXT_KEY_USAGE
fromAddressesback to summary
private String[] fromAddresses
RESOURCE_NAMEback to summary
private static final String RESOURCE_NAME
resultsback to summary
private Map<K, V> results
selectorConverterback to summary
private static final JcaX509CertSelectorConverter selectorConverter
shortKeyLengthback to summary
private static final int shortKeyLength
signersback to summary
private SignerInformationStore signers
SUBJECT_ALTERNATIVE_NAMEback to summary
private static final String SUBJECT_ALTERNATIVE_NAME
THIRTY_YEARS_IN_MILLI_SECback to summary
private static final long THIRTY_YEARS_IN_MILLI_SEC

Constructor Detail

SignedMailValidatorback to summary
public SignedMailValidator(MimeMessage message, PKIXParameters param) throws SignedMailValidatorException

Validates the signed MimeMessage message. The PKIXParameters from param are used for the certificate path validation. The actual PKIXParameters used for the certificate path validation is a copy of param with the followin changes:
- The validation date is changed to the signature time
- A CertStore with certificates and crls from the mail message is added to the CertStores.

In param it's also possible to add additional CertStores with intermediate Certificates and/or CRLs which then are also used for the validation.

Parameters
message:MimeMessage

the signed MimeMessage

param:PKIXParameters

the parameters for the certificate path validation

Exceptions
SignedMailValidatorException:
if the message is no signed message or if an exception occurs reading the message
SignedMailValidatorback to summary
public SignedMailValidator(MimeMessage message, PKIXParameters param, Class<T> certPathReviewerClass) throws SignedMailValidatorException

Validates the signed MimeMessage message. The PKIXParameters from param are used for the certificate path validation. The actual PKIXParameters used for the certificate path validation is a copy of param with the followin changes:
- The validation date is changed to the signature time
- A CertStore with certificates and crls from the mail message is added to the CertStores.

In param it's also possible to add additional CertStores with intermediate Certificates and/or CRLs which then are also used for the validation.

Parameters
message:MimeMessage

the signed MimeMessage

param:PKIXParameters

the parameters for the certificate path validation

certPathReviewerClass:Class<T>

a subclass of PKIXCertPathReviewer. The SignedMailValidator uses objects of this type for the cert path vailidation. The class must have an empty constructor.

Exceptions
SignedMailValidatorException:
if the message is no signed message or if an exception occurs reading the message
IllegalArgumentException:
if the certPathReviewerClass is not a subclass of PKIXCertPathReviewer or objects of certPathReviewerClass can not be instantiated

Method Detail

addressesToStringback to summary
pack-priv static String addressesToString(Object[] a)
checkSignerCertback to summary
protected void checkSignerCert(X509Certificate cert, List<E> errors, List<E> notifications)
createCertPathback to summary
public static CertPath createCertPath(X509Certificate signerCert, Set<E> trustanchors, List<E> certStores) throws GeneralSecurityException
Parameters
signerCert:X509Certificate

the end of the path

trustanchors:Set<E>

trust anchors for the path

Returns:CertPath

the resulting certificate path.

createCertPathback to summary
public static Object[] createCertPath(X509Certificate signerCert, Set<E> trustanchors, List<E> systemCertStores, List<E> userCertStores) throws GeneralSecurityException

Returns an Object array containing a CertPath and a List of Booleans. The list contains the value true if the corresponding certificate in the CertPath was taken from the user provided CertStores.

Parameters
signerCert:X509Certificate

the end of the path

trustanchors:Set<E>

trust anchors for the path

systemCertStores:List<E>

list of CertStore provided by the system

userCertStores:List<E>

list of CertStore provided by the user

Returns:Object[]

a CertPath and a List of booleans.

createErrorBundleback to summary
private static ErrorBundle createErrorBundle(String id)
createErrorBundleback to summary
private static ErrorBundle createErrorBundle(String id, Object[] arguments)
findCertsback to summary
private static List<E> findCerts(List<E> certStores, X509CertSelector selector) throws CertStoreException
findNextCertback to summary
private static X509Certificate findNextCert(List<E> certStores, X509CertSelector selector, Set<E> certSet) throws CertStoreException
getCertsAndCRLsback to summary
public CertStore getCertsAndCRLs()
getEmailAddressesback to summary
public static Set<E> getEmailAddresses(X509Certificate cert) throws IOException, CertificateEncodingException
getObjectback to summary
private static ASN1Primitive getObject(byte[] ext) throws IOException
getSignatureTimeback to summary
public static Date getSignatureTime(SignerInformation signer)
getSignerInformationStoreback to summary
public SignerInformationStore getSignerInformationStore()
getTBSCertback to summary
private static TBSCertificate getTBSCert(X509Certificate cert) throws CertificateEncodingException
getValidationResultback to summary
public SignedMailValidator.ValidationResult getValidationResult(SignerInformation signer) throws SignedMailValidatorException
validateSignaturesback to summary
protected void validateSignatures(PKIXParameters pkixParam)
org.bouncycastle.mail.smime.validator back to summary

public Class SignedMailValidator.ValidationResult

extends Object
Class Inheritance
  • java.lang.Object
  • org.bouncycastle.mail.smime.validator.SignedMailValidator.ValidationResult

Field Summary

Modifier and TypeField and Description
private List<E>
private List<E>
private PKIXCertPathReviewer
private boolean
private List<E>

Constructor Summary

AccessConstructor and Description
pack-priv
ValidationResult(PKIXCertPathReviewer review, boolean verified, List<E> errors, List<E> notifications, List<E> userProvidedCerts)

Method Summary

Modifier and TypeMethod and Description
public CertPath

Returns:

the CertPath for this signature or null if an Exception occurred.
getCertPath
()

public PKIXCertPathReviewer

Returns:

the PKIXCertPathReviewer for the CertPath of this signature or null if an Exception occurred.
getCertPathReview
()

public List<E>

Returns:

List of error messages
getErrors
()

Returns a list of error messages of type ErrorBundle.

public List<E>

Returns:

List of notification messages
getNotifications
()

Returns a list of notification messages of type ErrorBundle.

public List<E>

Returns:

a List of Booleans that are true if the corresponding certificate in the CertPath was taken from the CertStore of the SMIME message
getUserProvidedCerts
()

public boolean

Returns:

true if the signature is valid (ie. if it corresponds to the public key of the signer and the cert path for the signers certificate is also valid)
isValidSignature
()

public boolean

Returns:

true if the signature corresponds to the public key of the signer
isVerifiedSignature
()

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

errorsback to summary
private List<E> errors
notificationsback to summary
private List<E> notifications
reviewback to summary
private PKIXCertPathReviewer review
signVerifiedback to summary
private boolean signVerified
userProvidedCertsback to summary
private List<E> userProvidedCerts

Constructor Detail

ValidationResultback to summary
pack-priv ValidationResult(PKIXCertPathReviewer review, boolean verified, List<E> errors, List<E> notifications, List<E> userProvidedCerts)

Method Detail

getCertPathback to summary
public CertPath getCertPath()
Returns:CertPath

the CertPath for this signature or null if an Exception occurred.

getCertPathReviewback to summary
public PKIXCertPathReviewer getCertPathReview()
Returns:PKIXCertPathReviewer

the PKIXCertPathReviewer for the CertPath of this signature or null if an Exception occurred.

getErrorsback to summary
public List<E> getErrors()

Returns a list of error messages of type ErrorBundle.

Returns:List<E>

List of error messages

getNotificationsback to summary
public List<E> getNotifications()

Returns a list of notification messages of type ErrorBundle.

Returns:List<E>

List of notification messages

getUserProvidedCertsback to summary
public List<E> getUserProvidedCerts()
Returns:List<E>

a List of Booleans that are true if the corresponding certificate in the CertPath was taken from the CertStore of the SMIME message

isValidSignatureback to summary
public boolean isValidSignature()
Returns:boolean

true if the signature is valid (ie. if it corresponds to the public key of the signer and the cert path for the signers certificate is also valid)

isVerifiedSignatureback to summary
public boolean isVerifiedSignature()
Returns:boolean

true if the signature corresponds to the public key of the signer