2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @file FSecCertX509CertificateStore.cpp
20 * @brief This is the implementation file for X509CertificateStore class.
25 #include <FBaseResult.h>
26 #include <FSecCertX509CertificateStore.h>
27 #include <FSecCertX509Certificate.h>
28 #include <FBaseSysLog.h>
29 #include <FSecCert_X509CertificateStoreImpl.h>
30 #include <FSec_AccessController.h>
31 #include <FSec_AccessControlTypes.h>
32 #include <FApp_AppInfo.h>
34 using namespace Tizen::Base;
35 using namespace Tizen::App;
37 namespace Tizen { namespace Security { namespace Cert
40 X509CertificateStore::X509CertificateStore(void)
41 : __pX509CertificateStoreImpl(null)
43 __pX509CertificateStoreImpl = new (std::nothrow) _X509CertificateStoreImpl();
44 SysTryReturnVoidResult(NID_SEC_CERT, __pX509CertificateStoreImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
48 X509CertificateStore::~X509CertificateStore(void)
51 delete __pX509CertificateStoreImpl;
55 X509CertificateStore::GetName(String& name) const
59 SysAssertf(__pX509CertificateStoreImpl != null, "Not yet constructed. Reconstructor the object.");
61 r = __pX509CertificateStoreImpl->GetName(name);
62 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] An internal system error occurred.", GetErrorMessage(r));
68 X509CertificateStore::SetCertificateSelector(const Tizen::Security::Cert::ICertificateSelector& selector)
72 SysAssertf(__pX509CertificateStoreImpl != null, "Not yet constructed. Re-construct the object.");
74 r = __pX509CertificateStoreImpl->SetCertificateSelector(selector);
75 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] An internal system error occurred.", GetErrorMessage(r));
82 X509CertificateStore::GetCertificateCount(int& count) const
86 SysAssertf(__pX509CertificateStoreImpl != null, "Not yet constructed. Reconstructor the object.");
88 r = __pX509CertificateStoreImpl->GetCertificateCount(count);
89 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] An internal system error occurred.", GetErrorMessage(r));
96 Tizen::Security::Cert::ICertificate*
97 X509CertificateStore::GetNextCertificateN(void) const
100 ICertificate* pCert = null;
103 SysAssertf(__pX509CertificateStoreImpl != null, "Not yet constructed. Reconstructor the object.");
105 pCert = __pX509CertificateStoreImpl->GetNextCertificateN();
107 SysTryReturn(NID_SEC_CERT, pCert != null, null, r, "[%s] An internal system error occurred.", GetErrorMessage(r));
114 X509CertificateStore::Insert(CertificateType certificateType, const Tizen::Security::Cert::ICertificate& certificate)
116 result r = E_SUCCESS;
118 SysAssertf(__pX509CertificateStoreImpl != null, "Not yet constructed. Reconstructor the object.");
120 r = __pX509CertificateStoreImpl->Insert(certificateType, certificate);
121 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] An internal system error occurred.", GetErrorMessage(r));
128 X509CertificateStore::InsertPkcs12(const String& filePath, const String& password)
130 result r = E_SUCCESS;
132 SysAssertf(__pX509CertificateStoreImpl != null, "Not yet constructed. Reconstructor the object.");
134 r = __pX509CertificateStoreImpl->InsertPkcs12(filePath, password);
135 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] An internal system error occurred.", GetErrorMessage(r));
142 X509CertificateStore::Update(CertificateType certificateType, const Tizen::Security::Cert::ICertificate& oldCert, const Tizen::Security::Cert::ICertificate& newCert)
144 result r = E_SUCCESS;
146 SysAssertf(__pX509CertificateStoreImpl != null, "Not yet constructed. Reconstructor the object.");
148 r = __pX509CertificateStoreImpl->Update(certificateType, oldCert, newCert);
149 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] An internal system error occurred.", GetErrorMessage(r));
157 X509CertificateStore::Remove(CertificateType certificateType, const Tizen::Security::Cert::ICertificate& certificate)
159 result r = E_SUCCESS;
161 SysAssertf(__pX509CertificateStoreImpl != null, "Not yet constructed. Reconstructor the object.");
163 r = __pX509CertificateStoreImpl->Remove(certificateType, certificate);
164 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] An internal system error occurred.", GetErrorMessage(r));
169 } } } // Tizen::Security::Cert