void startAnotherJob()
    {
      static int counter = 0;
      counter++;

      // Randomly kill a running job
      if ( counter % 10 == 0 && !mRunningJobs.isEmpty() ) {
        mRunningJobs.at( counter % mRunningJobs.size() )->slotCancel();
      }

      // Randomly either start a keylist or a verify job
      Kleo::Job *job;
      if ( counter % 2 == 0 ) {
        Kleo::VerifyDetachedJob *vdj = mBackend->verifyDetachedJob();
        QVERIFY( !vdj->start( mSignature, mSignedData ) );
        job = vdj;
      }
      else {
        Kleo::KeyListJob *klj = mBackend->keyListJob();
        QVERIFY( !klj->start( QStringList() ) );
        job = klj;
      }
      mRunningJobs.append( job );
      connect( job, SIGNAL(done()), this, SLOT(someJobDone()) );

      // Quit after 2500 jobs, that should be enough
      mJobsStarted++;
      if ( mJobsStarted >= 2500 ) {
        QTimer::singleShot( 1000, &mEventLoop, SLOT(quit()) );
      }
      else {
        QTimer::singleShot( 0, this, SLOT(startAnotherJob()) );
      }
    }
示例#2
0
void CertificateInfoWidgetImpl::startCertificateChainListing() {
  kdDebug() << "CertificateInfoWidgetImpl::startCertificateChainListing()" << endl;

  if ( mChain.empty() ) {
    // we need a seed...
    kdWarning() << "CertificateInfoWidgetImpl::startCertificateChainListing(): mChain is empty!" << endl;
    return;
  }
  const char * chainID = mChain.front().chainID();
  if ( !chainID || !*chainID ) {
    // cert not found:
    kdDebug() << "CertificateInfoWidgetImpl::startCertificateChainListing(): empty chain ID - root not found" << endl;
    return;
  }
  const char * fpr = mChain.front().primaryFingerprint();
  if ( qstricmp( fpr, chainID ) == 0 ) {
    kdDebug() << "CertificateInfoWidgetImpl::startCertificateChainListing(): chain_id equals fingerprint -> found root" << endl;
    return;
  }
  if ( mChain.size() > 100 ) {
    // safe guard against certificate loops (paranoia factor 8 out of 10)...
    kdWarning() << "CertificateInfoWidgetImpl::startCertificateChainListing(): maximum chain length of 100 exceeded!" << endl;
    return;
  }
  if ( !mFoundIssuer ) {
    // key listing failed. Don't end up in endless loop
    kdDebug() << "CertificateInfoWidgetImpl::startCertificateChainListing(): issuer not found - giving up" << endl;
    return;
  }

  mFoundIssuer = false;

  // gpgsm / dirmngr / LDAP / whoever doesn't support looking up
  // external keys by fingerprint. Furthermore, since we actually got
  // a chain-id set on the key, we know that we have the issuer's cert
  // in the local keyring, so just use local keylisting.
  Kleo::KeyListJob * job =
    Kleo::CryptoBackendFactory::instance()->smime()->keyListJob( false );
  assert( job );

  connect( job, SIGNAL(result(const GpgME::KeyListResult&)),
	   SLOT(slotCertificateChainListingResult(const GpgME::KeyListResult&)) );
  connect( job, SIGNAL(nextKey(const GpgME::Key&)),
	   SLOT(slotNextKey(const GpgME::Key&)) );

  kdDebug() << "Going to fetch" << endl
	    << "  issuer  : \"" << mChain.front().issuerName() << "\"" << endl
	    << "  chain id: " << mChain.front().chainID() << endl
	    << "for" << endl
	    << "  subject : \"" << mChain.front().userID(0).id() << "\"" << endl
	    << "  subj.fpr: " << mChain.front().primaryFingerprint() << endl;

  const GpgME::Error err = job->start( mChain.front().chainID() );

  if ( err )
    showChainListError( this, err, mChain.front().issuerName() );
  else
    (void)new Kleo::ProgressDialog( job, i18n("Fetching Certificate Chain"), this );
}
    void slotParallelVerifyJobFinished( GpgME::VerificationResult result )
    {
      // Verify the result of the job is correct
      QVERIFY( mParallelVerifyJobs.contains( static_cast<Kleo::VerifyDetachedJob*>( sender() ) ) );
      QCOMPARE( result.signature( 0 ).validity(), GpgME::Signature::Full );
      mParallelVerifyJobs.removeAll( static_cast<Kleo::VerifyDetachedJob*>( sender() ) );

      // Start a key list job
      Kleo::KeyListJob *job = mBackend->keyListJob();
      mParallelKeyListJobs.append( job );
      connect( job, SIGNAL(done()),
               this, SLOT(slotParallelKeyListJobFinished()) );
      QVERIFY( !job->start( QStringList() ) );
    }
示例#4
0
void CertListView::slotStart() {
  kdDebug() << "CertListView::slotStart()" << endl;
  Kleo::KeyListJob * job = Kleo::CryptoBackendFactory::instance()->smime()->keyListJob( false );
  assert( job );
  QObject::connect( job, SIGNAL(nextKey(const GpgME::Key&)),
		    this, SLOT(slotAddKey(const GpgME::Key&)) );
  QObject::connect( job, SIGNAL(result(const GpgME::KeyListResult&)),
		    this, SLOT(slotResult(const GpgME::KeyListResult&)) );
#if 0
  QStringList l;
  l << "Marc";
  job->start( l, false );
#else
  job->start( QStringList(), false );
#endif
}
示例#5
0
void CertificateInfoWidgetImpl::startKeyExistanceCheck() {
  if ( !mExternal )
    // we already have it if it's from a local keylisting :)
    return;
  if ( mChain.empty() || mChain.back().isNull() )
    // need a key to look for
    return;
  const QString fingerprint = mChain.back().primaryFingerprint();
  if ( fingerprint.isEmpty() )
    // empty pattern means list all keys. We don't want that
    return;

  // start _local_ keylistjob (no progressdialog needed here):
  Kleo::KeyListJob * job =
    Kleo::CryptoBackendFactory::instance()->smime()->keyListJob( false );
  assert( job );

  connect( job, SIGNAL(nextKey(const GpgME::Key&)),
	   SLOT(slotKeyExistanceCheckNextCandidate(const GpgME::Key&)) );
  connect( job, SIGNAL(result(const GpgME::KeyListResult&)),
	   SLOT(slotKeyExistanceCheckFinished()) );
  // nor to check for errors:
  job->start( fingerprint );
}