Class SignedMailValidator
- java.lang.Object
-
- org.bouncycastle.mail.smime.validator.SignedMailValidator
-
public class SignedMailValidator extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classSignedMailValidator.ValidationResult
-
Constructor Summary
Constructors Constructor Description SignedMailValidator(javax.mail.internet.MimeMessage message, java.security.cert.PKIXParameters param)Validates the signedMimeMessagemessage.SignedMailValidator(javax.mail.internet.MimeMessage message, java.security.cert.PKIXParameters param, java.lang.Class certPathReviewerClass)Validates the signedMimeMessagemessage.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcheckSignerCert(java.security.cert.X509Certificate cert, java.util.List errors, java.util.List notifications)static java.security.cert.CertPathcreateCertPath(java.security.cert.X509Certificate signerCert, java.util.Set trustanchors, java.util.List certStores)static java.lang.Object[]createCertPath(java.security.cert.X509Certificate signerCert, java.util.Set trustanchors, java.util.List systemCertStores, java.util.List userCertStores)Returns an Object array containing a CertPath and a List of Booleans.java.security.cert.CertStoregetCertsAndCRLs()static java.util.SetgetEmailAddresses(java.security.cert.X509Certificate cert)static java.util.DategetSignatureTime(org.bouncycastle.cms.SignerInformation signer)org.bouncycastle.cms.SignerInformationStoregetSignerInformationStore()SignedMailValidator.ValidationResultgetValidationResult(org.bouncycastle.cms.SignerInformation signer)protected voidvalidateSignatures(java.security.cert.PKIXParameters pkixParam)
-
-
-
Constructor Detail
-
SignedMailValidator
public SignedMailValidator(javax.mail.internet.MimeMessage message, java.security.cert.PKIXParameters param) throws SignedMailValidatorExceptionValidates the signedMimeMessagemessage. ThePKIXParametersfrom 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.
Inparamit's also possible to add additional CertStores with intermediate Certificates and/or CRLs which then are also used for the validation.- Parameters:
message- the signed MimeMessageparam- the parameters for the certificate path validation- Throws:
SignedMailValidatorException- if the message is no signed message or if an exception occurs reading the message
-
SignedMailValidator
public SignedMailValidator(javax.mail.internet.MimeMessage message, java.security.cert.PKIXParameters param, java.lang.Class certPathReviewerClass) throws SignedMailValidatorExceptionValidates the signedMimeMessagemessage. ThePKIXParametersfrom 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.
Inparamit's also possible to add additional CertStores with intermediate Certificates and/or CRLs which then are also used for the validation.- Parameters:
message- the signed MimeMessageparam- the parameters for the certificate path validationcertPathReviewerClass- a subclass ofPKIXCertPathReviewer. The SignedMailValidator uses objects of this type for the cert path vailidation. The class must have an empty constructor.- Throws:
SignedMailValidatorException- if the message is no signed message or if an exception occurs reading the messagejava.lang.IllegalArgumentException- if the certPathReviewerClass is not a subclass ofPKIXCertPathRevieweror objects of certPathReviewerClass can not be instantiated
-
-
Method Detail
-
validateSignatures
protected void validateSignatures(java.security.cert.PKIXParameters pkixParam)
-
getEmailAddresses
public static java.util.Set getEmailAddresses(java.security.cert.X509Certificate cert) throws java.io.IOException, java.security.cert.CertificateEncodingException- Throws:
java.io.IOExceptionjava.security.cert.CertificateEncodingException
-
checkSignerCert
protected void checkSignerCert(java.security.cert.X509Certificate cert, java.util.List errors, java.util.List notifications)
-
getSignatureTime
public static java.util.Date getSignatureTime(org.bouncycastle.cms.SignerInformation signer)
-
createCertPath
public static java.security.cert.CertPath createCertPath(java.security.cert.X509Certificate signerCert, java.util.Set trustanchors, java.util.List certStores) throws java.security.GeneralSecurityException- Parameters:
signerCert- the end of the pathtrustanchors- trust anchors for the pathcertStores-- Returns:
- the resulting certificate path.
- Throws:
java.security.GeneralSecurityException
-
createCertPath
public static java.lang.Object[] createCertPath(java.security.cert.X509Certificate signerCert, java.util.Set trustanchors, java.util.List systemCertStores, java.util.List userCertStores) throws java.security.GeneralSecurityExceptionReturns an Object array containing a CertPath and a List of Booleans. The list contains the valuetrueif the corresponding certificate in the CertPath was taken from the user provided CertStores.- Parameters:
signerCert- the end of the pathtrustanchors- trust anchors for the pathsystemCertStores- list ofCertStoreprovided by the systemuserCertStores- list ofCertStoreprovided by the user- Returns:
- a CertPath and a List of booleans.
- Throws:
java.security.GeneralSecurityException
-
getCertsAndCRLs
public java.security.cert.CertStore getCertsAndCRLs()
-
getSignerInformationStore
public org.bouncycastle.cms.SignerInformationStore getSignerInformationStore()
-
getValidationResult
public SignedMailValidator.ValidationResult getValidationResult(org.bouncycastle.cms.SignerInformation signer) throws SignedMailValidatorException
- Throws:
SignedMailValidatorException
-
-