CACTrustRoot.cpp
Go to the documentation of this file.00001
00009 #include "PKIFTrustRoot.h"
00010 #include "ToolkitUtils.h"
00011 #include "components.h"
00012
00013 #include "Certificate.h"
00014 #include "Name.h"
00015 #include "SubjectKeyIdentifier.h"
00016
00018
00019 struct CPKIFTrustRootImp {
00020 CPKIFCertificatePtr m_cert;
00021
00022 };
00023
00025
00033 CPKIFTrustRoot::CPKIFTrustRoot():m_impl(new CPKIFTrustRootImp)
00034 {
00035 LOG_STRING_DEBUG("CPKIFTrustRoot::CPKIFTrustRoot()", TOOLKIT_PATH_MISC, 0, this);
00036 }
00044 CPKIFTrustRoot::~CPKIFTrustRoot()
00045 {
00046 LOG_STRING_DEBUG("CPKIFTrustRoot::CPKIFTrustRoot()", TOOLKIT_PATH_MISC, 0, this);
00047 delete m_impl;
00048 m_impl = '\0';
00049 }
00057 void CPKIFTrustRoot::SetCert(
00060 const CPKIFCertificatePtr& cert)
00061 {
00062 m_impl->m_cert = cert;
00063 }
00071 void CPKIFTrustRoot::GetCert(
00074 CPKIFCertificatePtr& cert)const
00075 {
00076 cert = m_impl->m_cert;
00077 }
00078
00079 CPKIFCertificatePtr CPKIFTrustRoot::GetCertificate() const
00080 {
00081 CPKIFCertificatePtr cert;
00082 GetCert(cert);
00083 return cert;
00084 }
00085
00086 CPKIFSubjectKeyIdentifierPtr CPKIFTrustRoot::GetKeyIdentifier() const
00087 {
00088 CPKIFCertificatePtr cert;
00089 GetCert(cert);
00090 CPKIFSubjectKeyIdentifierPtr kidFromCert;
00091 if(cert)
00092 {
00093 kidFromCert = cert->GetExtension<CPKIFSubjectKeyIdentifier>();
00094 }
00095 return kidFromCert;
00096 }
00097
00106 void CPKIFTrustRoot::GetName(
00108 CPKIFNamePtr& name)const
00109 {
00110 name = m_impl->m_cert->Subject();
00111 }
00128 CPKIFNamePtr CPKIFTrustRoot::GetSubjectName()const
00129 {
00130 return m_impl->m_cert->Subject();
00131 }
00132
00140 CPKIFNamePtr CPKIFTrustRoot::GetIssuerName()const
00141 {
00142 return m_impl->m_cert->Issuer();
00143 }
00144
00156 bool CPKIFTrustRoot::operator==(
00158 const CPKIFTrustRoot& tr)
00159 {
00160 return *m_impl->m_cert==*tr.m_impl->m_cert;
00161 }
00162
00170 CPKIFBufferPtr CPKIFTrustRoot::GetKey() const
00171 {
00172
00173 return m_impl->m_cert->GetKey();
00174 }
00175
00183 CPKIFSubjectPublicKeyInfoPtr CPKIFTrustRoot::GetSubjectPublicKeyInfo() const
00184 {
00185 return m_impl->m_cert->SubjectPublicKeyInfo();
00186 }
00187
00196 bool CPKIFTrustRoot::operator==(const IPKIFTrustAnchor& tr)
00197 {
00198 const CPKIFTrustRoot* taPtr = dynamic_cast<const CPKIFTrustRoot*>(&tr);
00199 if(taPtr)
00200 return *this == *taPtr;
00201 else
00202 return false;
00203 }
00204
00205 void CPKIFTrustRoot::GetExtensions (IPKIFParseExtensions* m, std::vector<CPKIFX509ExtensionPtr>& exts)
00206 {
00207 if(!m_impl->m_cert)
00208 return;
00209 else
00210 return m_impl->m_cert->GetExtensions(m, exts);
00211 }
00212 void CPKIFTrustRoot::GetExtensionByOID(const CPKIFOID& oid, CPKIFX509ExtensionPtr& ref)
00213 {
00214 if(!m_impl->m_cert)
00215 return;
00216 else
00217 return m_impl->m_cert->GetExtensionByOID(oid, ref);
00218 }
00219 void CPKIFTrustRoot::GetEncodedExtensions (CPKIFBufferPtr& buf)
00220 {
00221 if(!m_impl->m_cert)
00222 return;
00223 else
00224 return m_impl->m_cert->GetEncodedExtensions(buf);
00225 }
00226 CPKIFBufferPtr CPKIFTrustRoot::Encoded()
00227 {
00228 CPKIFBufferPtr empty;
00229 if(!m_impl->m_cert)
00230 return empty;
00231 else
00232 return m_impl->m_cert->Encoded();
00233 }