security: Fix compile problem caused by changes in Validator constructor
Change-Id: Ia0132ef46e1894c4468d922f6dd4a802d23c9d7f
Refs: #1481
diff --git a/src/sync-validator.cc b/src/sync-validator.cc
index f2c05bb..69e9232 100644
--- a/src/sync-validator.cc
+++ b/src/sync-validator.cc
@@ -26,10 +26,10 @@
SyncValidator::SyncValidator(const Name& prefix,
const IdentityCertificate& anchor,
- shared_ptr<Face> face,
+ Face& face,
const PublishCertCallback& publishCertCallback,
shared_ptr<SecRuleRelative> rule,
- shared_ptr<CertificateCache> certificateCache,
+ shared_ptr<CertificateCache> certificateCache,
const int stepLimit)
: Validator(face)
, m_prefix(prefix)
@@ -39,16 +39,13 @@
, m_publishCertCallback(publishCertCallback)
, m_dataRule(rule)
{
- if(!static_cast<bool>(face))
- throw Error("Face is not set!");
-
if(!static_cast<bool>(m_certificateCache))
- m_certificateCache = make_shared<CertificateCacheTtl>(m_face->ioService());
+ m_certificateCache = make_shared<CertificateCacheTtl>(m_face.ioService());
Name certPrefix = prefix;
certPrefix.append("CHRONOS-INTRO-CERT");
- m_prefixId = m_face->setInterestFilter(certPrefix,
- bind(&SyncValidator::onCertInterest, this, _1, _2),
+ m_prefixId = m_face.setInterestFilter(certPrefix,
+ bind(&SyncValidator::onCertInterest, this, _1, _2),
bind(&SyncValidator::onCertRegisterFailed, this, _1, _2));
setAnchor(m_anchor);
@@ -83,7 +80,7 @@
{
// Check the nodes introduced by the trusted node.
Edges::const_iterator edgeIt = m_introCerts.find(*eeIt);
- if(edgeIt != m_introCerts.end()
+ if(edgeIt != m_introCerts.end()
&& m_trustedNodes.find(edgeIt->second.getIntroduceeCertName()) == m_trustedNodes.end()
&& verifySignature(edgeIt->second, publicKey))
{
@@ -98,14 +95,14 @@
}
void
-SyncValidator::checkPolicy (const Data& data,
- int stepCount,
- const OnDataValidated& onValidated,
+SyncValidator::checkPolicy (const Data& data,
+ int stepCount,
+ const OnDataValidated& onValidated,
const OnDataValidationFailed& onValidationFailed,
std::vector<shared_ptr<ValidationRequest> >& nextSteps)
{
if(m_stepLimit == stepCount)
- return onValidationFailed(data.shared_from_this(),
+ return onValidationFailed(data.shared_from_this(),
"Maximum steps of validation reached: " + data.getName().toUri());
if(m_prefix.isPrefixOf(data.getName()) || (static_cast<bool>(m_dataRule) && m_dataRule->satisfy(data)))
@@ -121,25 +118,25 @@
if(verifySignature(data, sig, it->second))
return onValidated(data.shared_from_this());
else
- return onValidationFailed(data.shared_from_this(),
+ return onValidationFailed(data.shared_from_this(),
"Cannot verify signature: " + data.getName().toUri());
}
else
{
- _LOG_DEBUG("I am: " << m_anchor.getName().get(0).toEscapedString() << " for " << data.getName());
+ _LOG_DEBUG("I am: " << m_anchor.getName().get(0).toEscapedString() << " for " << data.getName());
Name interestName = m_prefix;
interestName.append("CHRONOS-INTRO-CERT").append(keyLocatorName.wireEncode());
Interest interest(interestName);
interest.setInterestLifetime(time::milliseconds(500));
- OnDataValidated onKeyValidated = bind(&SyncValidator::onCertificateValidated, this,
+ OnDataValidated onKeyValidated = bind(&SyncValidator::onCertificateValidated, this,
_1, data.shared_from_this(), onValidated, onValidationFailed);
-
- OnDataValidationFailed onKeyValidationFailed = bind(&SyncValidator::onCertificateValidationFailed, this,
- _1, _2, data.shared_from_this(), onValidationFailed);
- shared_ptr<ValidationRequest> nextStep = make_shared<ValidationRequest>(interest,
+ OnDataValidationFailed onKeyValidationFailed = bind(&SyncValidator::onCertificateValidationFailed, this,
+ _1, _2, data.shared_from_this(), onValidationFailed);
+
+ shared_ptr<ValidationRequest> nextStep = make_shared<ValidationRequest>(interest,
onKeyValidated,
onKeyValidationFailed,
1,
@@ -151,7 +148,7 @@
}
catch(SignatureSha256WithRsa::Error& e)
{
- return onValidationFailed(data.shared_from_this(),
+ return onValidationFailed(data.shared_from_this(),
"Not SignatureSha256WithRsa signature: " + std::string(e.what()));
}
catch(KeyLocator::Error& e)
@@ -166,9 +163,9 @@
}
void
-SyncValidator::checkPolicy (const Interest& interest,
- int stepCount,
- const OnInterestValidated& onValidated,
+SyncValidator::checkPolicy (const Interest& interest,
+ int stepCount,
+ const OnInterestValidated& onValidated,
const OnInterestValidationFailed& onValidationFailed,
std::vector<shared_ptr<ValidationRequest> >& nextSteps)
{
@@ -176,33 +173,33 @@
}
void
-SyncValidator::onCertificateValidated(const shared_ptr<const Data>& signCertificate,
- const shared_ptr<const Data>& data,
- const OnDataValidated& onValidated,
+SyncValidator::onCertificateValidated(const shared_ptr<const Data>& signCertificate,
+ const shared_ptr<const Data>& data,
+ const OnDataValidated& onValidated,
const OnDataValidationFailed& onValidationFailed)
{
try
{
IntroCertificate introCert(*signCertificate);
addParticipant(introCert);
-
+
if(verifySignature(*data, introCert.getIntroduceeCert().getPublicKeyInfo()))
return onValidated(data);
else
- return onValidationFailed(data,
+ return onValidationFailed(data,
"Cannot verify signature: " + data->getName().toUri());
}
catch(IntroCertificate::Error& e)
{
- return onValidationFailed(data,
+ return onValidationFailed(data,
"Intro cert decoding error: " + std::string(e.what()));
}
}
void
-SyncValidator::onCertificateValidationFailed(const shared_ptr<const Data>& signCertificate,
+SyncValidator::onCertificateValidationFailed(const shared_ptr<const Data>& signCertificate,
const std::string& failureInfo,
- const shared_ptr<const Data>& data,
+ const shared_ptr<const Data>& data,
const OnDataValidationFailed& onValidationFailed)
{
onValidationFailed(data, failureInfo);
@@ -211,13 +208,13 @@
void
SyncValidator::onCertInterest(const Name& prefix, const Interest& interest)
{
- Name name = interest.getName();
+ Name name = interest.getName();
Edges::const_iterator it = m_introCerts.begin();
for(; it != m_introCerts.end(); it++)
{
if(name.isPrefixOf(it->first))
{
- m_face->put(it->second);
+ m_face.put(it->second);
return;
}
}