-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathgetcommandhandler.cpp
More file actions
29 lines (24 loc) · 1.01 KB
/
getcommandhandler.cpp
File metadata and controls
29 lines (24 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// SPDX-FileCopyrightText: Estonian Information System Authority
// SPDX-License-Identifier: MIT
#include "commandhandler.hpp"
#include "command-handlers/getcertificate.hpp"
#include "command-handlers/authenticate.hpp"
#include "command-handlers/sign.hpp"
// getCommandHandler() has to be defined in the app project so that a different
// mock implementation can be provided in the tests project.
CommandHandler::ptr getCommandHandler(const CommandWithArguments& cmd)
{
auto cmdType = cmd.first;
auto cmdCopy = CommandWithArguments {cmdType, cmd.second};
switch (cmdType) {
case CommandType::GET_SIGNING_CERTIFICATE:
return std::make_unique<GetCertificate>(cmdCopy);
case CommandType::AUTHENTICATE:
return std::make_unique<Authenticate>(cmdCopy);
case CommandType::SIGN:
return std::make_unique<Sign>(cmdCopy);
default:
throw std::invalid_argument("Unknown command '" + std::string(cmdType)
+ "' in getCommandHandler()");
}
}