sync with master
[platform/framework/native/appfw.git] / inc / FSecCertICertificateStore.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file                        FSecCertICertificateStore.h
20  * @brief               This is the header file for the %ICertificateStore interface.
21  *
22  * This header file contains the declarations of the %ICertificateStore interface.
23  *
24  */
25 #ifndef _FSEC_CERT_ICERTIFICATE_STORE_H_
26 #define _FSEC_CERT_ICERTIFICATE_STORE_H_
27
28 #include <FBaseString.h>
29 #include <FBaseByteBuffer.h>
30 #include <FSecIPrivateKey.h>
31 #include <FSecCertICertificate.h>
32 #include <FSecCertICertificateSelector.h>
33
34
35 namespace Tizen { namespace Security { namespace Cert
36 {
37
38 /**
39  *      @interface      ICertificateStore
40  *      @brief          This is the interface for retrieving and managing the certificates from a repository.
41  *
42  *      @since          2.0
43  *
44  *      The %ICertificateStore interface is used for retrieving and managing the certificates from a repository.
45  */
46 class _OSP_EXPORT_ ICertificateStore
47 {
48
49 public:
50         /**
51          *      This is the destructor for this class.
52          *
53          *      @since          2.0
54          */
55         virtual ~ICertificateStore(void) {}
56
57         /**
58          *  Gets the @c name of the certificate store.
59          *
60          *      @since          2.0
61          *
62          *      @return         An error code
63          *      @param[out]     name                                    The name of the certificate store
64          *      @exception      E_SUCCESS                               The method is successful.
65          *      @exception      E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
66          */
67         virtual result GetName(Tizen::Base::String& name) const = 0;
68
69         /**
70          *      Sets a list of certificates that match the specified selector.
71          *
72          *      @since          2.0
73          *
74          *      @return         An error code
75          *      @param[in]      selector                                A selector that defines a set of criterion for selecting certificates
76          *      @exception      E_SUCCESS                               The method is successful.
77          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
78          *      @exception      E_SYSTEM                                A system error has occurred. @n
79          *                                                                              The IPC operation has failed.
80          *      @exception      E_INVALID_ARG                   The specified @c selector is invalid.
81          *      @exception      E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
82          */
83         virtual result SetCertificateSelector(const Tizen::Security::Cert::ICertificateSelector& selector) = 0;
84
85         /**
86          *      Gets the count of certificates that match the specified selector.
87          *
88          *      @since          2.0
89          *
90          *      @return         An error code
91          *      @param[out] count                                       The count of certificates
92          *      @exception      E_SUCCESS                               The method is successful.
93          *      @exception      E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
94          */
95         virtual result GetCertificateCount(int& count) const = 0;
96
97         /**
98          *      Gets each certificate that matches the specified selector.
99          *
100          *      @since          2.0
101          *
102          *      @return         The certificates that match the specified selector
103          *      @exception      E_SUCCESS                               The method is successful.
104          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
105          *      @exception      E_OBJ_NOT_FOUND                 The certificate is not found.
106          *      @exception      E_SYSTEM                                A system error has occurred. @n
107          *                                                                              The Tizen::Base::ByteBuffer operation has failed.
108          *      @exception      E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
109          *  @remarks        The specific error code can be accessed using the GetLastResult() method.
110          */
111         virtual Tizen::Security::Cert::ICertificate* GetNextCertificateN(void) const = 0;
112
113         /**
114          *  Inserts the certificate into the certificate store.
115          *
116          *      @since          2.0
117          *
118          *      @return         An error code
119          *      @param[in]      certificateType                 The type of the Certificate (that is, ROOT_CA, OPERATOR_DOMAIN, or TRUSTED_THIRD_PARTY_DOMAIN)
120          *      @param[in]      certificate                             A reference to the certificate to insert
121          *      @exception      E_SUCCESS                               The method is successful.
122          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
123          *      @exception      E_INVALID_ARG                   The specified @c certificate or the certificate data is invalid, or
124          *                                                                              the specified @c certificateType is invalid.
125          *      @exception      E_SYSTEM                                A system error has occurred. @n
126          *                                      Either the IPC operation or the file operation or the DB operation has failed.
127          *      @exception      E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
128          */
129         virtual result Insert(CertificateType certificateType, const Tizen::Security::Cert::ICertificate& certificate) = 0;
130
131         /**
132          *  Updates the certificate in the certificate store.
133          *
134          *      @since          2.0
135          *
136          *      @return         An error code
137          *      @param[in]      certificateType                 The type of the Certificate (that is, ROOT_CA, OPERATOR_DOMAIN, or TRUSTED_THIRD_PARTY_DOMAIN)
138          *      @param[in]      oldCert                                 A reference to the old certificate
139          *      @param[in]      newCert                                 A reference to the new certificate
140          *      @exception      E_SUCCESS                               The method is successful.
141          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
142          *      @exception      E_INVALID_ARG                   The specified @c certificate or the certificate data is invalid, or
143          *                                                                                      the specified @c certificateType is invalid.
144          *      @exception      E_OBJ_NOT_FOUND                 The certificate is not found.
145          *      @exception      E_SYSTEM                                A system error has occurred. @n
146          *                                      Either the IPC operation or the file operation or the DB operation has failed.
147          *      @exception      E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
148          */
149         virtual result Update(CertificateType certificateType, const Tizen::Security::Cert::ICertificate& oldCert, const Tizen::Security::Cert::ICertificate& newCert) = 0;
150
151         /**
152          *  Removes the certificate from the certificate store.
153          *
154          *      @since          2.0
155          *
156          *      @return         An error code
157          *      @param[in]      certificateType                 The type of the Certificate (that is, ROOT_CA, OPERATOR_DOMAIN, or TRUSTED_THIRD_PARTY_DOMAIN)
158          *      @param[in]      certificate                             A reference to the certificate to remove
159          *      @exception      E_SUCCESS                               The method is successful.
160          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
161          *      @exception      E_INVALID_ARG                   The specified @c certificate or the certificate data is invalid, or
162          *                                                                                      the specified @c certificateType is invalid.
163          *      @exception      E_OBJ_NOT_FOUND                 The certificate is not found.
164          *      @exception      E_SYSTEM                                A system error has occurred. @n
165          *                                      Either the IPC operation or the file operation or the DB operation has failed.
166          *      @exception      E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
167          */
168         virtual result Remove(CertificateType certificateType, const Tizen::Security::Cert::ICertificate& certificate) = 0;
169
170 protected:
171         //
172         // This method is for internal use only. Using this method can cause behavioral, security-related,
173         // and consistency-related issues in the application.
174         //
175         // This method is reserved and may change its name at any time without prior notice.
176         //
177         // @since 2.0
178         //
179         virtual void ICertificateStore_Reserved1(void) {}
180
181         //
182         // This method is for internal use only. Using this method can cause behavioral, security-related,
183         // and consistency-related issues in the application.
184         //
185         // This method is reserved and may change its name at any time without prior notice.
186         //
187         // @since 2.0
188         //
189         virtual void ICertificateStore_Reserved2(void) {}
190
191         //
192         // This method is for internal use only. Using this method can cause behavioral, security-related,
193         // and consistency-related issues in the application.
194         //
195         // This method is reserved and may change its name at any time without prior notice.
196         //
197         // @since 2.0
198         //
199         virtual void ICertificateStore_Reserved3(void) {}
200
201 }; //ICertificateStore
202
203 } } } //Tizen::Security::Cert
204
205 #endif //_FSEC_CERT_ICERTIFICATE_STORE_H_