34 ndn::KeyChain& keyChain)
36 , m_keyChain(keyChain)
38 face->getValidator().addSupportedPrivilege(privilege);
48 ControlParameters& extractedParameters)
52 Block rawParameters = parameterComponent.blockFromValue();
53 extractedParameters.wireDecode(rawParameters);
55 catch (
const tlv::Error&)
67 const std::string& text)
69 ControlResponse response(code, text);
76 const std::string& text,
79 ControlResponse response(code, text);
80 response.setBody(body);
86 const ControlResponse& response)
90 <<
" code: " << response.getCode()
91 <<
" text: " << response.getText());
93 const Block& encodedControl = response.wireEncode();
95 shared_ptr<Data> responseData(make_shared<Data>(name));
96 responseData->setContent(encodedControl);
99 m_face->put(*responseData);
108 meta.setType(tlv::ContentType_Nack);
110 shared_ptr<Data> responseData(make_shared<Data>(name));
111 responseData->setMetaInfo(meta);
114 m_face->put(*responseData);
119 ControlParameters& parameters)
123 command.validateRequest(parameters);
125 catch (
const ControlCommand::ArgumentError& error)
130 command.applyDefaultsToRequest(parameters);
137 const std::string& error)
139 NFD_LOG_DEBUG(
"command result: unauthorized command: " << *command <<
" (" << error <<
")");
140 sendResponse(command->getName(), 403,
"Unauthorized command");
shared_ptr< InternalFace > m_face
#define NFD_LOG_DEBUG(expression)
ndn::KeyChain & m_keyChain
void sendResponse(const Name &name, const ControlResponse &response)
static bool extractParameters(const Name::Component ¶meterComponent, ControlParameters &extractedParameters)
void onCommandValidationFailed(const shared_ptr< const Interest > &command, const std::string &error)
ManagerBase(shared_ptr< InternalFace > face, const std::string &privilege, ndn::KeyChain &keyChain)
void sendNack(const Name &name)
#define NFD_LOG_INIT(name)
virtual bool validateParameters(const ControlCommand &command, ControlParameters ¶meters)