Change RawBuffer into SafeBuffer.
[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 #include <ckm/ckm-certificate.h>
28
29 #include <generic-key.h>
30
31 namespace CKM {
32
33 class CertificateImpl : public Certificate {
34 public:
35     CertificateImpl(){}
36     CertificateImpl(X509* x509);
37     CertificateImpl(const SafeBuffer &data, DataFormat format);
38     CertificateImpl(const RawBuffer &data, DataFormat format);
39     CertificateImpl(const CertificateImpl &);
40     CertificateImpl(CertificateImpl &&);
41     CertificateImpl& operator=(const CertificateImpl &);
42     CertificateImpl& operator=(CertificateImpl &&);
43
44     virtual RawBuffer getDER() const;
45     virtual bool empty() const;
46     virtual X509* getX509() const;
47
48     SafeBuffer getDERSB() const;
49
50     GenericKey::EvpShPtr getEvpShPtr() const;
51     GenericKey getGenericKey() const;
52
53     std::string getOneLine(CertificateFieldId type) const;
54     std::string getField(CertificateFieldId type, int fieldNid) const;
55     std::string getCommonName(CertificateFieldId type) const;
56     std::string getCountryName(CertificateFieldId type) const;
57     std::string getStateOrProvinceName(CertificateFieldId type) const;
58     std::string getLocalityName(CertificateFieldId type) const;
59     std::string getOrganizationName(CertificateFieldId type) const;
60     std::string getOrganizationalUnitName(CertificateFieldId type) const;
61     std::string getEmailAddres(CertificateFieldId type) const;
62     std::string getOCSPURL() const;
63
64     virtual ~CertificateImpl();
65 protected:
66     X509* m_x509;
67 };
68
69 typedef std::vector<CertificateImpl> CertificateImplVector;
70
71 } // namespace CKM
72