From ff511e64985c730a5d952b84d82d051db273e142 Mon Sep 17 00:00:00 2001 From: kyungwook tak Date: Mon, 8 Jun 2015 17:12:29 +0900 Subject: [PATCH] Remove dependency to boost Change-Id: Id51496cc064626b0dc2913f5e83a27454909d7a2 Signed-off-by: kyungwook tak --- packaging/cert-svc.spec | 7 ++----- vcore/src/vcore/CertStoreType.h | 1 - vcore/src/vcore/Certificate.cpp | 24 ++++++++++++------------ vcore/src/vcore/Certificate.h | 20 +++++++++----------- vcore/src/vcore/OCSPImpl.h | 6 ++---- vcore/src/vcore/api.cpp | 20 ++++++++++---------- 6 files changed, 35 insertions(+), 43 deletions(-) mode change 100755 => 100644 packaging/cert-svc.spec diff --git a/packaging/cert-svc.spec b/packaging/cert-svc.spec old mode 100755 new mode 100644 index 018067a..d940aa0 --- a/packaging/cert-svc.spec +++ b/packaging/cert-svc.spec @@ -8,7 +8,6 @@ License: Apache-2.0 Source0: %{name}-%{version}.tar.gz Source1001: %{name}.manifest BuildRequires: cmake -BuildRequires: boost-devel BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(openssl) BuildRequires: pkgconfig(evas) @@ -22,10 +21,8 @@ BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(libxml-2.0) BuildRequires: pkgconfig(libxslt) BuildRequires: pkgconfig(libtzplatform-config) -Requires(post): /sbin/ldconfig -Requires(postun): /sbin/ldconfig +Requires: ca-certificates Requires: libtzplatform-config -Provides: libcert-svc-vcore.so.1 %description Certification service @@ -36,7 +33,7 @@ Group: Development/Libraries Requires: %{name} = %{version}-%{release} %description devel -Certification service (developement files) +Certification service (development files) %prep %setup -q diff --git a/vcore/src/vcore/CertStoreType.h b/vcore/src/vcore/CertStoreType.h index e5f79a5..409d9b7 100644 --- a/vcore/src/vcore/CertStoreType.h +++ b/vcore/src/vcore/CertStoreType.h @@ -25,7 +25,6 @@ #define _VALIDATION_CORE_CERTSTORETYPE_H_ #include -#include namespace ValidationCore { namespace CertStoreId { diff --git a/vcore/src/vcore/Certificate.cpp b/vcore/src/vcore/Certificate.cpp index 3080ab9..45bfba6 100644 --- a/vcore/src/vcore/Certificate.cpp +++ b/vcore/src/vcore/Certificate.cpp @@ -199,12 +199,12 @@ DPL::String Certificate::getOneLine(FieldType type) const return DPL::FromUTF8String(buffer); } -boost::optional Certificate::getField(FieldType type, +DPL::String Certificate::getField(FieldType type, int fieldNid) const { X509_NAME *subjectName = getX509Name(type); X509_NAME_ENTRY *subjectEntry = NULL; - boost::optional < DPL::String > output; + DPL::String output; int entryCount = X509_NAME_entry_count(subjectName); for (int i = 0; i < entryCount; ++i) { @@ -243,45 +243,45 @@ boost::optional Certificate::getField(FieldType type, return output; } -boost::optional Certificate::getCommonName(FieldType type) const +DPL::String Certificate::getCommonName(FieldType type) const { return getField(type, NID_commonName); } -boost::optional Certificate::getCountryName(FieldType type) const +DPL::String Certificate::getCountryName(FieldType type) const { return getField(type, NID_countryName); } -boost::optional Certificate::getStateOrProvinceName(FieldType type) const +DPL::String Certificate::getStateOrProvinceName(FieldType type) const { return getField(type, NID_stateOrProvinceName); } -boost::optional Certificate::getLocalityName(FieldType type) const +DPL::String Certificate::getLocalityName(FieldType type) const { return getField(type, NID_localityName); } -boost::optional Certificate::getOrganizationName(FieldType type) const +DPL::String Certificate::getOrganizationName(FieldType type) const { return getField(type, NID_organizationName); } -boost::optional Certificate::getOrganizationalUnitName(FieldType type) const +DPL::String Certificate::getOrganizationalUnitName(FieldType type) const { return getField(type, NID_organizationalUnitName); } -boost::optional Certificate::getEmailAddres(FieldType type) const +DPL::String Certificate::getEmailAddres(FieldType type) const { return getField(type, NID_pkcs9_emailAddress); } -boost::optional Certificate::getOCSPURL() const +DPL::String Certificate::getOCSPURL() const { // TODO verify this code - boost::optional retValue; + DPL::String retValue; AUTHORITY_INFO_ACCESS *aia = static_cast( X509_get_ext_d2i(m_x509, NID_info_access, @@ -302,7 +302,7 @@ boost::optional Certificate::getOCSPURL() const ad->location->type == GEN_URI) { void* data = ASN1_STRING_data(ad->location->d.ia5); - retValue = boost::optional(DPL::FromUTF8String( + retValue = DPL::String(DPL::FromUTF8String( static_cast(data))); break; diff --git a/vcore/src/vcore/Certificate.h b/vcore/src/vcore/Certificate.h index 8611436..2687468 100644 --- a/vcore/src/vcore/Certificate.h +++ b/vcore/src/vcore/Certificate.h @@ -32,8 +32,6 @@ #include #include #include -#include - #include @@ -111,17 +109,17 @@ class Certificate : public std::enable_shared_from_this // getName uses deprecated functions. Usage is strongly discouraged. DPL::String getOneLine(FieldType type = FIELD_SUBJECT) const; - boost::optional getCommonName(FieldType type = FIELD_SUBJECT) const; - boost::optional getCountryName(FieldType type = FIELD_SUBJECT) const; - boost::optional getStateOrProvinceName( + DPL::String getCommonName(FieldType type = FIELD_SUBJECT) const; + DPL::String getCountryName(FieldType type = FIELD_SUBJECT) const; + DPL::String getStateOrProvinceName( FieldType type = FIELD_SUBJECT) const; - boost::optional getLocalityName(FieldType type = FIELD_SUBJECT) const; - boost::optional getOrganizationName( + DPL::String getLocalityName(FieldType type = FIELD_SUBJECT) const; + DPL::String getOrganizationName( FieldType type = FIELD_SUBJECT) const; - boost::optional getOrganizationalUnitName( + DPL::String getOrganizationalUnitName( FieldType type = FIELD_SUBJECT) const; - boost::optional getEmailAddres(FieldType type = FIELD_SUBJECT) const; - boost::optional getOCSPURL() const; + DPL::String getEmailAddres(FieldType type = FIELD_SUBJECT) const; + DPL::String getOCSPURL() const; // Openssl supports 9 types of alternative name filed. @@ -176,7 +174,7 @@ class Certificate : public std::enable_shared_from_this protected: X509_NAME *getX509Name(FieldType type) const; - boost::optional getField(FieldType type, + DPL::String getField(FieldType type, int fieldNid) const; X509 *m_x509; diff --git a/vcore/src/vcore/OCSPImpl.h b/vcore/src/vcore/OCSPImpl.h index 451a244..11cd647 100644 --- a/vcore/src/vcore/OCSPImpl.h +++ b/vcore/src/vcore/OCSPImpl.h @@ -38,8 +38,6 @@ #include #include -#include - #include #include @@ -166,8 +164,8 @@ class OCSPImpl typedef std::pair HttpResponseBuffer; SoupWrapper::SoupMessageSendBase::RequestStatus sendOcspRequest( - OCSP_REQUEST* argRequest, - const boost::optional& argUri); + OCSP_REQUEST* argRequest, + const DPL::String& argUri); diff --git a/vcore/src/vcore/api.cpp b/vcore/src/vcore/api.cpp index 742b434..34ee76b 100644 --- a/vcore/src/vcore/api.cpp +++ b/vcore/src/vcore/api.cpp @@ -244,13 +244,13 @@ public: auto certPtr = iter->second; - boost::optional result; + DPL::String result; switch(field) { case CERTSVC_SUBJECT: - result = boost::optional(certPtr->getOneLine()); + result = certPtr->getOneLine(); break; case CERTSVC_ISSUER: - result = boost::optional(certPtr->getOneLine(Certificate::FIELD_ISSUER)); + result = certPtr->getOneLine(Certificate::FIELD_ISSUER); break; case CERTSVC_SUBJECT_COMMON_NAME: result = certPtr->getCommonName(); @@ -286,32 +286,32 @@ public: { std::stringstream stream; stream << (certPtr->getVersion()+1); - result = boost::optional(DPL::FromUTF8String(stream.str())); + result = DPL::FromUTF8String(stream.str()); break; } case CERTSVC_SERIAL_NUMBER: - result = boost::optional(certPtr->getSerialNumberString()); + result = certPtr->getSerialNumberString(); break; case CERTSVC_KEY_USAGE: - result = boost::optional(certPtr->getKeyUsageString()); + result = certPtr->getKeyUsageString(); break; case CERTSVC_KEY: - result = boost::optional(certPtr->getPublicKeyString()); + result = certPtr->getPublicKeyString(); break; case CERTSVC_SIGNATURE_ALGORITHM: - result = boost::optional(certPtr->getSignatureAlgorithmString()); + result = certPtr->getSignatureAlgorithmString(); break; default: break; } - if (!result) { + if (result.empty()) { buffer->privateHandler = NULL; buffer->privateLength = 0; buffer->privateInstance = cert.privateInstance; return CERTSVC_SUCCESS; } - std::string output = DPL::ToUTF8String(*result); + std::string output = DPL::ToUTF8String(result); char *cstring = new char[output.size()+1]; if (cstring == NULL) { -- 2.7.4