6a65f12613d6407a92a50b7f758191527ac4c829
[platform/core/security/key-manager.git] / src / manager / common / certificate-impl.h
1 /* Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd All Rights Reserved
2  *
3  *  Licensed under the Apache License, Version 2.0 (the "License");
4  *  you may not use this file except in compliance with the License.
5  *  You may obtain a copy of the License at
6  *
7  *      http://www.apache.org/licenses/LICENSE-2.0
8  *
9  *  Unless required by applicable law or agreed to in writing, software
10  *  distributed under the License is distributed on an "AS IS" BASIS,
11  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  *  See the License for the specific language governing permissions and
13  *  limitations under the License
14  *
15  *
16  * @file        client-certificate-impl.h
17  * @author      Barlomiej Grzelewski (b.grzelewski@samsung.com)
18  * @version     1.0
19  * @brief       Certificate Implmentation.
20  */
21
22 #pragma once
23
24 #include <memory>
25 #include <vector>
26 #include <ckm/ckm-type.h>
27
28 #include <generic-key.h>
29
30 extern "C" {
31 struct x509_st;
32 typedef struct x509_st X509;
33 }
34
35 namespace CKM {
36
37 class CertificateImpl {
38 public:
39     CertificateImpl(){}
40     CertificateImpl(X509* x509);
41     CertificateImpl(const RawBuffer &data, DataFormat format);
42     CertificateImpl(const CertificateImpl &);
43     CertificateImpl(CertificateImpl &&);
44     CertificateImpl& operator=(const CertificateImpl &);
45     CertificateImpl& operator=(CertificateImpl &&);
46     RawBuffer getDER() const;
47     bool empty() const;
48
49     GenericKey::EvpShPtr getEvpShPtr() const;
50     GenericKey getGenericKey() const;
51
52     std::string getOneLine(CertificateFieldId type) const;
53     std::string getField(CertificateFieldId type, int fieldNid) const;
54     std::string getCommonName(CertificateFieldId type) const;
55     std::string getCountryName(CertificateFieldId type) const;
56     std::string getStateOrProvinceName(CertificateFieldId type) const;
57     std::string getLocalityName(CertificateFieldId type) const;
58     std::string getOrganizationName(CertificateFieldId type) const;
59     std::string getOrganizationalUnitName(CertificateFieldId type) const;
60     std::string getEmailAddres(CertificateFieldId type) const;
61     std::string getOCSPURL() const;
62
63     X509* getX509() const;
64
65     virtual ~CertificateImpl();
66 protected:
67     X509* m_x509;
68 };
69
70 typedef std::vector<CertificateImpl> CertificateImplVector;
71
72 } // namespace CKM
73