Add initial values support - values to feed the shared database on first startup.
[platform/core/security/key-manager.git] / src / manager / initial-values / InitialValueHandler.h
1 /*
2  *  Copyright (c) 2000 - 2015 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        InitialValueHandler.h
18  * @author      Maciej Karpiuk (m.karpiuk2@samsung.com)
19  * @version     1.0
20  * @brief       InitialValueHandler class.
21  */
22
23 #ifndef INITIALVALUEHANDLER_H_
24 #define INITIALVALUEHANDLER_H_
25
26 #include <parser.h>
27 #include <BufferHandler.h>
28 #include <PermissionHandler.h>
29 #include <EncodingType.h>
30 #include <ckm/ckm-type.h>
31 #include <ckm-logic.h>
32 #include <protocols.h>
33
34 namespace CKM {
35 namespace InitialValues {
36
37 class InitialValueHandler : public XML::Parser::ElementHandler
38 {
39 public:
40     typedef std::shared_ptr<InitialValueHandler> InitialValueHandlerPtr;
41
42     explicit InitialValueHandler(CKMLogic & db_logic) : m_exportable(false),
43                                                         m_db_logic(db_logic) {}
44     virtual ~InitialValueHandler() {};
45
46     BufferHandler::BufferHandlerPtr CreateBufferHandler(EncodingType type);
47     PermissionHandler::PermissionHandlerPtr CreatePermissionHandler();
48     virtual void Start(const XML::Parser::Attributes &);
49     virtual void Characters(const std::string & data);
50     virtual void End();
51
52 protected:
53     virtual DataType getDataType() const = 0;
54
55     Alias      m_name;
56     Password   m_password;
57     bool       m_exportable;
58     CKMLogic & m_db_logic;
59
60     BufferHandler::BufferHandlerPtr m_bufferHandler;
61     std::vector<PermissionHandler::PermissionHandlerPtr> m_permissions;
62 };
63
64 }
65 }
66 #endif /* INITIALVALUEHANDLER_H_ */