security: provide getKeyLocatorName helper function

refs #3920

Change-Id: Iba8fa7776ca63445608f4eb6fa2e4c54307cc99f
diff --git a/src/security/v2/validation-policy-command-interest.cpp b/src/security/v2/validation-policy-command-interest.cpp
index 5753ef3..d765e44 100644
--- a/src/security/v2/validation-policy-command-interest.cpp
+++ b/src/security/v2/validation-policy-command-interest.cpp
@@ -95,30 +95,12 @@
     return std::make_tuple(false, Name(), 0);
   }
 
-  SignatureInfo sig;
-  try {
-    sig.wireDecode(name[signed_interest::POS_SIG_INFO].blockFromValue());
-  }
-  catch (const tlv::Error&) {
-    state->fail({ValidationError::POLICY_ERROR, "Command interest `" +
-                 interest.getName().toUri() + "` does not include SignatureInfo component"});
+  Name klName = getKeyLocatorName(interest, *state);
+  if (!state->getOutcome()) { // already failed
     return std::make_tuple(false, Name(), 0);
   }
 
-  if (!sig.hasKeyLocator()) {
-    state->fail({ValidationError::INVALID_KEY_LOCATOR, "Command interest `" +
-                 interest.getName().toUri() + "` does not include KeyLocator"});
-    return std::make_tuple(false, Name(), 0);
-  }
-
-  const KeyLocator& keyLocator = sig.getKeyLocator();
-  if (keyLocator.getType() != KeyLocator::KeyLocator_Name) {
-    state->fail({ValidationError::INVALID_KEY_LOCATOR, "Command interest `" +
-                 interest.getName().toUri() + "` KeyLocator type is not Name"});
-    return std::make_tuple(false, Name(), 0);
-  }
-
-  return std::make_tuple(true, keyLocator.getName(), timestampComp.toNumber());
+  return std::make_tuple(true, klName, timestampComp.toNumber());
 }
 
 bool