Refactor SignatureValidator and reduce interface headers
[platform/core/security/cert-svc.git] / vcore / src / vcore / SignatureFinder.h
1 /*
2  * Copyright (c) 2011 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        SignatureFinder.h
18  * @author      Bartlomiej Grzelewski (b.grzelewski@samsung.com)
19  * @version     1.0
20  * @brief       Search for author-signature.xml and signatureN.xml files.
21  *              This class is WAC 2.0 specific and shuld be moved to
22  *              wrt-installer.
23  */
24 #ifndef _VALIDATION_CORE_SIGNATUREFINDER_H_
25 #define _VALIDATION_CORE_SIGNATUREFINDER_H_
26
27 #include <set>
28 #include <string>
29
30 namespace ValidationCore {
31
32 class SignatureFileInfo {
33 public:
34     SignatureFileInfo(const std::string &fileName, int num)
35       : m_fileName(fileName)
36       , m_fileNumber(num)
37     {}
38
39     std::string getFileName() const
40     {
41         return m_fileName;
42     }
43
44     int getFileNumber() const
45     {
46         return m_fileNumber;
47     }
48
49     bool operator<(const SignatureFileInfo &second) const
50     {
51         return m_fileNumber < second.m_fileNumber;
52     }
53
54 private:
55     std::string m_fileName;
56     int m_fileNumber;
57 };
58
59 typedef std::set<SignatureFileInfo> SignatureFileInfoSet;
60
61 class SignatureFinder {
62 public:
63     enum Result
64     {
65         NO_ERROR,
66         ERROR_OPENING_DIR,
67         ERROR_READING_DIR,
68         ERROR_ISTREAM
69     };
70
71     SignatureFinder() = delete;
72     explicit SignatureFinder(const std::string& dir);
73
74     virtual ~SignatureFinder();
75
76     Result find(SignatureFileInfoSet &set);
77
78 private:
79     class Impl;
80     Impl *m_impl;
81
82     SignatureFinder(const SignatureFinder &);
83     const SignatureFinder &operator=(const SignatureFinder &);
84 };
85
86 } // namespace ValidationCore
87
88 #endif // _VALIDATION_CORE_SIGNATUREFINDER_H_