1 // Copyright (c) 2016 The Chromium Embedded Framework Authors. All rights 2 // reserved. Use of this source code is governed by a BSD-style license that 3 // can be found in the LICENSE file. 4 5 #include "libcef/browser/x509_cert_principal_impl.h" 6 7 namespace { 8 TransferVector(const std::vector<std::string> & source,std::vector<CefString> & target)9void TransferVector(const std::vector<std::string>& source, 10 std::vector<CefString>& target) { 11 if (!target.empty()) 12 target.clear(); 13 14 if (!source.empty()) { 15 std::vector<std::string>::const_iterator it = source.begin(); 16 for (; it != source.end(); ++it) 17 target.push_back(*it); 18 } 19 } 20 21 } // namespace 22 CefX509CertPrincipalImpl(const net::CertPrincipal & value)23CefX509CertPrincipalImpl::CefX509CertPrincipalImpl( 24 const net::CertPrincipal& value) 25 : value_(value) {} 26 GetDisplayName()27CefString CefX509CertPrincipalImpl::GetDisplayName() { 28 return value_.GetDisplayName(); 29 } 30 GetCommonName()31CefString CefX509CertPrincipalImpl::GetCommonName() { 32 return value_.common_name; 33 } 34 GetLocalityName()35CefString CefX509CertPrincipalImpl::GetLocalityName() { 36 return value_.locality_name; 37 } 38 GetStateOrProvinceName()39CefString CefX509CertPrincipalImpl::GetStateOrProvinceName() { 40 return value_.state_or_province_name; 41 } 42 GetCountryName()43CefString CefX509CertPrincipalImpl::GetCountryName() { 44 return value_.country_name; 45 } 46 GetStreetAddresses(std::vector<CefString> & addresses)47void CefX509CertPrincipalImpl::GetStreetAddresses( 48 std::vector<CefString>& addresses) { 49 TransferVector(value_.street_addresses, addresses); 50 } 51 GetOrganizationNames(std::vector<CefString> & names)52void CefX509CertPrincipalImpl::GetOrganizationNames( 53 std::vector<CefString>& names) { 54 TransferVector(value_.organization_names, names); 55 } 56 GetOrganizationUnitNames(std::vector<CefString> & names)57void CefX509CertPrincipalImpl::GetOrganizationUnitNames( 58 std::vector<CefString>& names) { 59 TransferVector(value_.organization_unit_names, names); 60 } 61 GetDomainComponents(std::vector<CefString> & components)62void CefX509CertPrincipalImpl::GetDomainComponents( 63 std::vector<CefString>& components) { 64 TransferVector(value_.domain_components, components); 65 } 66