Search in sources :

Example 6 with DefaultMessageSignatureImpl

use of org.nhindirect.stagent.DefaultMessageSignatureImpl in project nhin-d by DirectProject.

the class TrustModel_findTrustedSignatureTest method testFindTrustedSignatureTest_singleRecipSignature_nullRecip_assertMessageSignatureNotNull.

public void testFindTrustedSignatureTest_singleRecipSignature_nullRecip_assertMessageSignatureNotNull() throws Exception {
    final TrustModel trustModel = new TrustModel();
    trustModel.findSenderSignatures(inMessage);
    DefaultMessageSignatureImpl impl = trustModel.findTrustedSignature(inMessage, Arrays.asList(sigUser1CA));
    assertNotNull(impl);
}
Also used : DefaultMessageSignatureImpl(org.nhindirect.stagent.DefaultMessageSignatureImpl)

Example 7 with DefaultMessageSignatureImpl

use of org.nhindirect.stagent.DefaultMessageSignatureImpl in project nhin-d by DirectProject.

the class TrustModel_findTrustedSignatureTest method testFindTrustedSignatureTest_singleRecipSignature_senderHasNonMatchingCert_assertMessageSignatureNotNull.

public void testFindTrustedSignatureTest_singleRecipSignature_senderHasNonMatchingCert_assertMessageSignatureNotNull() throws Exception {
    final TrustModel trustModel = new TrustModel();
    trustModel.findSenderSignatures(inMessage);
    inMessage.getSender().setCertificates(Arrays.asList(otherCert));
    DefaultMessageSignatureImpl impl = trustModel.findTrustedSignature(inMessage, inMessage.getRecipients().get(0), Arrays.asList(sigUser1CA));
    assertNotNull(impl);
}
Also used : DefaultMessageSignatureImpl(org.nhindirect.stagent.DefaultMessageSignatureImpl)

Example 8 with DefaultMessageSignatureImpl

use of org.nhindirect.stagent.DefaultMessageSignatureImpl in project nhin-d by DirectProject.

the class TrustModel_findTrustedSignatureTest method testFindTrustedSignatureTest_singleRecipSignature_notPolicyCompliant_assertMessageSignatureNull.

public void testFindTrustedSignatureTest_singleRecipSignature_notPolicyCompliant_assertMessageSignatureNull() throws Exception {
    final TrustModel trustModel = new TrustModel() {

        @Override
        protected boolean isCertPolicyCompliant(InternetAddress recipient, X509Certificate cert) {
            return false;
        }
    };
    trustModel.findSenderSignatures(inMessage);
    DefaultMessageSignatureImpl impl = trustModel.findTrustedSignature(inMessage, inMessage.getRecipients().get(0), Arrays.asList(sigUser1CA));
    assertNull(impl);
}
Also used : InternetAddress(javax.mail.internet.InternetAddress) DefaultMessageSignatureImpl(org.nhindirect.stagent.DefaultMessageSignatureImpl) X509Certificate(java.security.cert.X509Certificate)

Example 9 with DefaultMessageSignatureImpl

use of org.nhindirect.stagent.DefaultMessageSignatureImpl in project nhin-d by DirectProject.

the class TrustModel method findTrustedSignature.

protected DefaultMessageSignatureImpl findTrustedSignature(IncomingMessage message, Collection<X509Certificate> anchors) {
    NHINDAddress sender = message.getSender();
    Collection<DefaultMessageSignatureImpl> signatures = message.getSenderSignatures();
    DefaultMessageSignatureImpl lastTrustedSignature = null;
    for (DefaultMessageSignatureImpl signature : signatures) {
        if (certChainValidator.isTrusted(signature.getSignerCert(), anchors) && signature.checkSignature()) {
            if (!sender.hasCertificates())
                // Can't really check thumbprints etc. So, this is about as good as its going to get
                return signature;
            if (signature.checkThumbprint(sender)) {
                return signature;
            }
            //
            // We'll save this guy, but keep looking for a signer whose thumbprint we can verify
            // If we can't find one, we'll use the last trusted signer we found.. and just mark the recipient's trust
            // enforcement status as Success_ThumbprintMismatch
            //    
            lastTrustedSignature = signature;
        }
    }
    return lastTrustedSignature;
}
Also used : NHINDAddress(org.nhindirect.stagent.NHINDAddress) DefaultMessageSignatureImpl(org.nhindirect.stagent.DefaultMessageSignatureImpl)

Aggregations

DefaultMessageSignatureImpl (org.nhindirect.stagent.DefaultMessageSignatureImpl)9 NHINDAddress (org.nhindirect.stagent.NHINDAddress)4 X509Certificate (java.security.cert.X509Certificate)1 ArrayList (java.util.ArrayList)1 InternetAddress (javax.mail.internet.InternetAddress)1 AgentException (org.nhindirect.stagent.AgentException)1 NHINDAddressCollection (org.nhindirect.stagent.NHINDAddressCollection)1 RevocationManager (org.nhindirect.stagent.cert.RevocationManager)1 SignerCertPair (org.nhindirect.stagent.cert.SignerCertPair)1 CRLRevocationManager (org.nhindirect.stagent.cert.impl.CRLRevocationManager)1