6b3cf8baea1f432d6261559a3b4d16e4236b44c3
[platform/framework/native/appfw.git] / inc / FSecCertX509CertificatePath.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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 /**
18  * @file                        FSecCertX509CertificatePath.h
19  * @brief               This is the header file for the %X509CertificatePath class.
20  *
21  * This header file contains the declarations of the %X509CertificatePath class.
22  */
23 #ifndef _FSEC_CERT_X509_CERTIFICATE_PATH_H_
24 #define _FSEC_CERT_X509_CERTIFICATE_PATH_H_
25
26 #include <FBaseObject.h>
27 #include <FSecCertICertificatePath.h>
28 #include <FSecCertX509Certificate.h>
29
30
31 namespace Tizen { namespace Security { namespace Cert
32 {
33
34 class _CertMgrSvcProxy;
35
36 /**
37  *      @class          X509CertificatePath
38  *      @brief          This class provides the certificate path.
39  *
40  *      @since          2.0
41  *
42  * The %X509CertificatePath class provides the certificate path. @n
43  *
44  * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/security/certificate_namespace.htm">Certificates</a>.
45  */
46 class _OSP_EXPORT_ X509CertificatePath
47         : public virtual ICertificatePath
48         , public Tizen::Base::Object
49 {
50
51 public:
52         /**
53          *      This is the default constructor for this class.
54          *
55          *      @since          2.0
56          */
57         X509CertificatePath(void);
58
59         /**
60          *      This is the destructor for this class.
61          *
62          *      @since          2.0
63          */
64         virtual ~X509CertificatePath(void);
65
66         /**
67          *      Gets the format name for the certificate path.
68          *
69          *      @since          2.0
70          *
71          *      @return         The format of the certificate
72          */
73         virtual Tizen::Base::String GetFormat(void) const;
74
75         /**
76          *  Adds a certificate to the certificate chain.
77          *  The order of certificates should be as follows: @n
78          *  1. User certificate.
79          *  2. Intermediate certificate.
80          *  3. Root CA certificate.
81          *
82          *      @since          2.0
83          *
84          *      @return         An error code
85          *      @param[in]      certificate                             A reference to a certificate
86          *      @exception      E_SUCCESS                               The method is successful.
87          *      @exception      E_INVALID_ARG                   The specified @c certificate or the certificate data is invalid.
88          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
89          *      @exception      E_SYSTEM                                A system error has occurred. @n
90          *                                                                              The certificate link list operation has failed.
91          */
92         virtual result AddCertificate(const Tizen::Security::Cert::ICertificate& certificate);
93
94         /**
95          *      Validates the specified certificate path.
96          *
97          *      @since          2.0
98          *
99          *      @return         The result of the certificate path validation
100          *      @exception      E_SUCCESS                               The method is successful.
101          *      @exception      E_SYSTEM                                A system error has occurred.
102          *                                                                              The certificate link list operation has failed.
103          * @remarks        The specific error code can be accessed using the GetLastResult() method.
104          */
105         virtual Tizen::Security::Cert::ValidationResult Validate(void);
106
107         /**
108          *      Validates the specified certificate path.
109          *
110          *      @since          2.0
111          *
112          *      @return         The result of the certificate path validation
113          *      @param[in]      trustAnchor                             The most trusted Certificate Authority (CA)
114          *      @exception      E_SUCCESS                               The method is successful.
115          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
116          *      @exception      E_INVALID_ARG                   The specified input parameter is invalid.
117          *      @exception      E_SYSTEM                                A system error has occurred. @n
118          *                                                                              The certificate link list operation has failed.
119          * @remarks        The specific error code can be accessed using the GetLastResult() method.
120          */
121         virtual Tizen::Security::Cert::ValidationResult Validate(const Tizen::Security::Cert::ICertificate& trustAnchor);
122
123         /**
124          *      Gets the length of the certificate path.
125          *
126          *      @since          2.0
127          *
128          *      @return         The length of the certificate path, @n
129          *                              else @c -1 if an error occurs
130          *      @exception      E_SUCCESS                               The method is successful.
131          *      @exception      E_SYSTEM                                A system error has occurred. @n
132          *                                                                              The certificate link list operation has failed.
133          */
134         virtual int GetLength(void) const;
135
136         /**
137          *      Gets the list of the certificates in this certificate path.
138          *
139          *      @since          2.0
140          *
141          *      @return         A pointer to the ICertificate interface, @n
142          *                              else @c null if an error occurs
143          *  @param[in]  nth                                             The nth certificate in the certificate path (starts from @c 0)
144          *      @exception      E_SUCCESS                               The method is successful.
145          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
146          *      @exception      E_INVALID_ARG                   The value of the specified @c nth is out of the valid range. @n
147          *                                                                              It must be less than the value retrieved by the GetLength() method.
148          *      @exception      E_OBJ_NOT_FOUND                 The certificate is not found.
149          *      @exception      E_SYSTEM                                A system error has occurred. @n
150          *                                                                              The certificate link list operation has failed.
151          * @remarks        The specific error code can be accessed using the GetLastResult() method.
152          */
153         virtual Tizen::Security::Cert::ICertificate* GetCertificateN(int nth) const;
154
155         /**
156          *      Gets the trust anchor for the certificate path.
157          *
158          *      @since                  2.0
159          *
160          *      @return         The root certificate, @n
161          *                                      else @c null if an error occurs
162          *      @exception      E_SUCCESS                               The method is successful.
163          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
164          *      @exception      E_OBJ_NOT_FOUND                 The certificate is not found.
165          *      @exception      E_SYSTEM                                A system error has occurred. @n
166          *                                                                              The certificate link list operation or
167          *                                                                              the Tizen::Base::ByteBuffer operation has failed.
168          * @remarks        The specific error code can be accessed using the GetLastResult() method.
169          */
170         virtual Tizen::Security::Cert::ICertificate* GetTrustAnchorN(void) const;
171
172 private:
173         X509CertificatePath(const X509CertificatePath& rhs);
174         X509CertificatePath& operator =(const X509CertificatePath& rhs);
175
176 private:
177         void* __certCtx;
178         int __depth;
179         int __trustAnchorIndex;
180
181         class _X509CertificatePathImpl* __pX509CertificatePathImpl;
182         friend class _X509CertificatePathImpl;
183
184 }; //X509CertificatePath
185
186 } } } //Tizen::Security::Cert
187
188 #endif //_FSEC_CERT_X509_CERTIFICATE_PATH_H_