base: ensure Element::Error inherits from tlv::Error
Adding static asserts to ensure (Name|name::Component|Interest|
Selectors|Exclude|KeyLocator|Data|MetaInfo|Signature|SignatureInfo)
::Error are subclasses of tlv::Error.
This commit also adds WireEncodable and WireDecodable concept checks
to Name,name::Component,Interest,Selectors,Exclude,KeyLocator,Data,
MetaInfo,SignatureInfo types.
This commit also moves definition of Selectors method into .cpp.
refs #1983
Change-Id: I15220b93437d4a624ae09df66defc91ceac2386c
diff --git a/src/security/conf/checker.hpp b/src/security/conf/checker.hpp
index 040d343..3c4ceb2 100644
--- a/src/security/conf/checker.hpp
+++ b/src/security/conf/checker.hpp
@@ -188,18 +188,18 @@
}
}
}
- catch (tlv::Error& e)
- {
- onValidationFailed(packet.shared_from_this(),
- "Cannot decode signature");
- return -1;
- }
catch (KeyLocator::Error& e)
{
onValidationFailed(packet.shared_from_this(),
"Cannot decode KeyLocator");
return -1;
}
+ catch (tlv::Error& e)
+ {
+ onValidationFailed(packet.shared_from_this(),
+ "Cannot decode signature");
+ return -1;
+ }
std::string failInfo;
if (m_keyLocatorChecker->check(packet, signature.getKeyLocator(), failInfo))
diff --git a/src/security/sec-public-info-sqlite3.cpp b/src/security/sec-public-info-sqlite3.cpp
index 0c70d02..c147bf1 100644
--- a/src/security/sec-public-info-sqlite3.cpp
+++ b/src/security/sec-public-info-sqlite3.cpp
@@ -489,10 +489,6 @@
{
return;
}
- catch (KeyLocator::Error& e)
- {
- return;
- }
sqlite3_bind_text(statement, 3, identity.toUri(), SQLITE_TRANSIENT);
sqlite3_bind_text(statement, 4, keyId, SQLITE_STATIC);
diff --git a/src/security/sec-rule-relative.cpp b/src/security/sec-rule-relative.cpp
index 958eb66..042d04f 100644
--- a/src/security/sec-rule-relative.cpp
+++ b/src/security/sec-rule-relative.cpp
@@ -73,10 +73,6 @@
{
return false;
}
- catch (KeyLocator::Error& e)
- {
- return false;
- }
catch (RegexMatcher::Error& e)
{
return false;
@@ -124,10 +120,6 @@
{
return false;
}
- catch (KeyLocator::Error& e)
- {
- return false;
- }
catch (RegexMatcher::Error& e)
{
return false;
diff --git a/src/security/sec-rule-specific.cpp b/src/security/sec-rule-specific.cpp
index cb7adf4..061132f 100644
--- a/src/security/sec-rule-specific.cpp
+++ b/src/security/sec-rule-specific.cpp
@@ -80,10 +80,6 @@
{
return false;
}
- catch (KeyLocator::Error& e)
- {
- return false;
- }
catch (RegexMatcher::Error& e)
{
return false;
diff --git a/src/security/validator-config.cpp b/src/security/validator-config.cpp
index 83b7a62..5891ff1 100644
--- a/src/security/validator-config.cpp
+++ b/src/security/validator-config.cpp
@@ -537,16 +537,16 @@
return onValidationFailed(interest.shared_from_this(),
"No valid signature");
}
- catch (tlv::Error& e)
- {
- return onValidationFailed(interest.shared_from_this(),
- "Cannot decode signature");
- }
catch (KeyLocator::Error& e)
{
return onValidationFailed(interest.shared_from_this(),
"No valid KeyLocator");
}
+ catch (tlv::Error& e)
+ {
+ return onValidationFailed(interest.shared_from_this(),
+ "Cannot decode signature");
+ }
catch (IdentityCertificate::Error& e)
{
return onValidationFailed(interest.shared_from_this(),
diff --git a/src/security/validator-config.hpp b/src/security/validator-config.hpp
index 69f626d..6b70a3c 100644
--- a/src/security/validator-config.hpp
+++ b/src/security/validator-config.hpp
@@ -320,14 +320,14 @@
"Unsupported signature type");
}
}
- catch (tlv::Error& e) {
- return onValidationFailed(packet.shared_from_this(),
- "Cannot decode public key signature");
- }
catch (KeyLocator::Error& e) {
return onValidationFailed(packet.shared_from_this(),
"Cannot decode KeyLocator in public key signature");
}
+ catch (tlv::Error& e) {
+ return onValidationFailed(packet.shared_from_this(),
+ "Cannot decode public key signature");
+ }
if (signature.getKeyLocator().getType() != KeyLocator::KeyLocator_Name) {
return onValidationFailed(packet.shared_from_this(), "Unsupported KeyLocator type");
diff --git a/src/security/validator-regex.cpp b/src/security/validator-regex.cpp
index 194aaf1..0539abd 100644
--- a/src/security/validator-regex.cpp
+++ b/src/security/validator-regex.cpp
@@ -161,17 +161,17 @@
return;
}
}
- catch (tlv::Error& e)
- {
- return onValidationFailed(data.shared_from_this(),
- "Cannot decode signature");
- }
catch (KeyLocator::Error& e)
{
return onValidationFailed(data.shared_from_this(),
"Key Locator is not a name: " +
data.getName().toUri());
}
+ catch (tlv::Error& e)
+ {
+ return onValidationFailed(data.shared_from_this(),
+ "Cannot decode signature");
+ }
}
}