/*
- * Copyright 2001-2006 Internet2
+ * Copyright 2001-2007 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
/**
* ClientCertAuthRule.cpp
*
- * XML Signature checking SecurityPolicyRule
+ * TLS client authentication SecurityPolicyRule
*/
#include "internal.h"
#include "exceptions.h"
-#include "binding/ClientCertAuthRule.h"
+#include "binding/SecurityPolicyRule.h"
#include "saml2/metadata/Metadata.h"
#include "saml2/metadata/MetadataProvider.h"
using namespace std;
namespace opensaml {
+ class SAML_DLLLOCAL ClientCertAuthRule : public SecurityPolicyRule
+ {
+ public:
+ ClientCertAuthRule(const DOMElement* e) {}
+ virtual ~ClientCertAuthRule() {}
+
+ void evaluate(const xmltooling::XMLObject& message, const GenericRequest* request, SecurityPolicy& policy) const;
+ };
+
SecurityPolicyRule* SAML_DLLLOCAL ClientCertAuthRuleFactory(const DOMElement* const & e)
{
return new ClientCertAuthRule(e);
}
};
-bool ClientCertAuthRule::evaluate(const XMLObject& message, const GenericRequest* request, SecurityPolicy& policy) const
+void ClientCertAuthRule::evaluate(const XMLObject& message, const GenericRequest* request, SecurityPolicy& policy) const
{
Category& log=Category::getInstance(SAML_LOGCAT".SecurityPolicyRule.ClientCertAuth");
- log.debug("evaluating client certificate authentication policy");
- if (!request) {
- log.debug("ignoring message, no protocol request available");
- return false;
- }
- else if (!policy.getIssuerMetadata()) {
+ if (!request)
+ return;
+
+ if (!policy.getIssuerMetadata()) {
log.debug("ignoring message, no issuer metadata supplied");
- return false;
+ return;
}
const X509TrustEngine* x509trust;
if (!(x509trust=dynamic_cast<const X509TrustEngine*>(policy.getTrustEngine()))) {
log.debug("ignoring message, no X509TrustEngine supplied");
- return false;
+ return;
}
const std::vector<XSECCryptoX509*>& chain = request->getClientCertificates();
- if (chain.empty()) {
- log.debug("ignoring message, no client certificates in request");
- return false;
- }
+ if (chain.empty())
+ return;
if (!x509trust->validate(chain.front(), chain, *(policy.getIssuerMetadata()), true,
policy.getMetadataProvider()->getKeyResolver())) {
log.error("unable to verify certificate chain with supplied trust engine");
- return false;
+ return;
}
log.debug("client certificate verified against message issuer");
- return true;
+ policy.setSecure(true);
}