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);
}
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);
}
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);
}
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;
}
Aggregations