Change error condition of ToDouble()&ToFloat()
[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          *
78          *      @since          2.0
79          *
80          *      @return         An error code
81          *      @param[in]      certificate                             A reference to a certificate
82          *      @exception      E_SUCCESS                               The method is successful.
83          *      @exception      E_INVALID_ARG                   The specified @c certificate or the certificate data is invalid.
84          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
85          *      @exception      E_SYSTEM                                A system error has occurred. @n
86          *                                                                              The certificate link list operation has failed.
87          */
88         virtual result AddCertificate(const Tizen::Security::Cert::ICertificate& certificate);
89
90         /**
91          *      Validates the specified certificate path.
92          *
93          *      @since          2.0
94          *
95          *      @return         The result of the certificate path validation
96          *      @exception      E_SUCCESS                               The method is successful.
97          *      @exception      E_SYSTEM                                A system error has occurred.
98          *                                                                              The certificate link list operation has failed.
99          * @remarks        The specific error code can be accessed using the GetLastResult() method.
100          */
101         virtual Tizen::Security::Cert::ValidationResult Validate(void);
102
103         /**
104          *      Validates the specified certificate path.
105          *
106          *      @since          2.0
107          *
108          *      @return         The result of the certificate path validation
109          *      @param[in]      trustAnchor                             The most trusted Certificate Authority (CA)
110          *      @exception      E_SUCCESS                               The method is successful.
111          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
112          *      @exception      E_INVALID_ARG                   The specified input parameter is invalid.
113          *      @exception      E_SYSTEM                                A system error has occurred. @n
114          *                                                                              The certificate link list operation has failed.
115          * @remarks        The specific error code can be accessed using the GetLastResult() method.
116          */
117         virtual Tizen::Security::Cert::ValidationResult Validate(const Tizen::Security::Cert::ICertificate& trustAnchor);
118
119         /**
120          *      Gets the length of the certificate path.
121          *
122          *      @since          2.0
123          *
124          *      @return         The length of the certificate path, @n
125          *                              else @c -1 if an error occurs
126          *      @exception      E_SUCCESS                               The method is successful.
127          *      @exception      E_SYSTEM                                A system error has occurred. @n
128          *                                                                              The certificate link list operation has failed.
129          */
130         virtual int GetLength(void) const;
131
132         /**
133          *      Gets the list of the certificates in this certificate path.
134          *
135          *      @since          2.0
136          *
137          *      @return         A pointer to the ICertificate interface, @n
138          *                              else @c null if an error occurs
139          *  @param[in]  nth                                             The nth certificate in the certificate path (starts from @c 0)
140          *      @exception      E_SUCCESS                               The method is successful.
141          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
142          *      @exception      E_INVALID_ARG                   The value of the specified @c nth is out of the valid range. @n
143          *                                                                              It must be less than GetLength().
144          *      @exception      E_OBJ_NOT_FOUND                 The certificate is not found.
145          *      @exception      E_SYSTEM                                A system error has occurred. @n
146          *                                                                              The certificate link list operation has failed.
147          * @remarks        The specific error code can be accessed using the GetLastResult() method.
148          */
149         virtual Tizen::Security::Cert::ICertificate* GetCertificateN(int nth) const;
150
151         /**
152          *      Gets the trust anchor for the certificate path.
153          *
154          *      @since                  2.0
155          *
156          *      @return         The root certificate, @n
157          *                                      else @c null if an error occurs
158          *      @exception      E_SUCCESS                               The method is successful.
159          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
160          *      @exception      E_OBJ_NOT_FOUND                 The certificate is not found.
161          *      @exception      E_SYSTEM                                A system error has occurred. @n
162          *                                                                              The certificate link list operation or
163          *                                                                              the Tizen::Base::ByteBuffer operation has failed.
164          * @remarks        The specific error code can be accessed using the GetLastResult() method.
165          */
166         virtual Tizen::Security::Cert::ICertificate* GetTrustAnchorN(void) const;
167
168 private:
169         X509CertificatePath(const X509CertificatePath& rhs);
170         X509CertificatePath& operator =(const X509CertificatePath& rhs);
171
172 private:
173         void* __certCtx;
174         int __depth;
175         int __trustAnchorIndex;
176
177         class _X509CertificatePathImpl* __pX509CertificatePathImpl;
178         friend class _X509CertificatePathImpl;
179
180 }; //X509CertificatePath
181
182 } } } //Tizen::Security::Cert
183
184 #endif //_FSEC_CERT_X509_CERTIFICATE_PATH_H_