Implement --set-policy option in Cyad
[platform/core/security/cynara.git] / src / cyad / CommandsDispatcher.h
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Apache License, Version 2.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16 /**
17  * @file        src/cyad/CommandsDispatcher.h
18  * @author      Aleksander Zdyb <a.zdyb@samsung.com>
19  * @version     1.0
20  * @brief       CommandsDispatcher class
21  */
22
23 #ifndef SRC_CYAD_COMMANDSDISPATCHER_H_
24 #define SRC_CYAD_COMMANDSDISPATCHER_H_
25
26 #include <cyad/BaseAdminApiWrapper.h>
27 #include <cyad/CommandlineParser/CyadCommand.h>
28 #include <cyad/DispatcherIO.h>
29
30 struct cynara_admin;
31 struct cynara_admin_policy;
32
33 namespace Cynara {
34
35 class CommandsDispatcher {
36 public:
37     CommandsDispatcher(BaseDispatcherIO &io, BaseAdminApiWrapper &adminApiWrapper);
38     virtual ~CommandsDispatcher();
39
40     virtual int execute(CyadCommand &);
41     virtual int execute(HelpCyadCommand &);
42     virtual int execute(ErrorCyadCommand &);
43     virtual int execute(DeleteBucketCyadCommand &);
44     virtual int execute(SetBucketCyadCommand &);
45     virtual int execute(SetPolicyCyadCommand &);
46     virtual int execute(SetPolicyBulkCyadCommand &);
47
48 private:
49     // TODO: Get argv[0] instead of hardcoded name
50     const std::string helpMessage = "Usage: cyad [OPTIONS]\n\n"
51                                     "Bucket set options (with -b or --set-bucket)\n"
52                                     "  -b, --set-bucket=<name>        name of bucket\n"
53                                     "  -p, --policy=<policy>          default policy\n"
54                                     "  -m, --metadata=<metadata>      metadata for default policy\n"
55                                     "\n"
56                                     "Bucket delete options (with -d or --delete-bucket)\n"
57                                     "  -d, --delete-bucket=<name>     name of bucket to delete\n"
58                                     "\n"
59                                     "Policy set options (with -s or --set-policy)\n"
60                                     "  -c, --client=<client>          client value\n"
61                                     "  -u, --user=<user>              user value\n"
62                                     "  -r, --privilege=<privilege>    privilege value\n"
63                                     "  -p, --policy=<policy>          policy\n"
64                                     "  -m, --metadata=<metadata>      metadata for policy\n"
65                                     "  -f, --bulk=<filename>          path or - for stdin\n"
66                                     "\n"
67                                     "Help options:\n"
68                                     "  -h, --help                     print help message";
69     BaseDispatcherIO &m_io;
70     BaseAdminApiWrapper &m_adminApiWrapper;
71     struct cynara_admin *m_cynaraAdmin;
72 };
73
74 } /* namespace Cynara */
75
76 #endif /* SRC_CYAD_COMMANDSDISPATCHER_H_ */