certmanager
hierarchyanalyser.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifdef HAVE_CONFIG_H
00034 #include <config.h>
00035 #endif
00036
00037 #include "hierarchyanalyser.h"
00038
00039 #include <algorithm>
00040 #include <iterator>
00041
00042 HierarchyAnalyser::HierarchyAnalyser( QObject * parent, const char * name )
00043 : QObject( parent, name )
00044 {
00045
00046 }
00047
00048 HierarchyAnalyser::~HierarchyAnalyser() {
00049
00050 }
00051
00052 void HierarchyAnalyser::slotNextKey( const GpgME::Key & key ) {
00053 if ( key.isNull() )
00054 return;
00055 if ( key.isRoot() || !key.chainID() || !*key.chainID() )
00056
00057
00058 mSubjectsByIssuer[0].push_back( key );
00059 else
00060 mSubjectsByIssuer[key.chainID()].push_back( key );
00061 }
00062
00063 const std::vector<GpgME::Key> & HierarchyAnalyser::subjectsForIssuer( const char * issuer_dn ) const {
00064 static const std::vector<GpgME::Key> empty;
00065 std::map< QCString, std::vector<GpgME::Key> >::const_iterator it =
00066 mSubjectsByIssuer.find( issuer_dn );
00067 return it == mSubjectsByIssuer.end() ? empty : it->second ;
00068 }
00069
00070 std::vector<GpgME::Key> HierarchyAnalyser::subjectsForIssuerRecursive( const char * issuer_dn ) const {
00071 std::vector<GpgME::Key> keys = subjectsForIssuer( issuer_dn );
00072 for ( unsigned int i = 0 ; i < keys.size() ; ++i )
00073 if ( const char * fpr = keys[i].primaryFingerprint() ) {
00074 const std::vector<GpgME::Key> & tmp = subjectsForIssuer( fpr );
00075 std::copy( tmp.begin(), tmp.end(), std::back_inserter( keys ) );
00076 }
00077 return keys;
00078 }
00079
00080
00081 #include "hierarchyanalyser.moc"
|