예제 #1
0
 /**
  * Do one or more rounds of prepare()
  *
  * @return true if a dispatch is required
  */
 public final function __doRound()
 {
     //echo "__doRound()\n";
     $toProfile = !!$this->__preparableProfEntry;
     if ($this->__exception) {
         // This Preparable resulted in an Exception some time in the past.
         // Alas, it was readded and we must throw again.  Sorry :(
         if ($toProfile) {
             $this->__preparableProfEntry->throwException($this->__exception);
         }
         throw $this->__exception;
     }
     if ($toProfile) {
         // Make sure we don't share loaders with unrelated preparable in
         // the same pass
         LoaderCoordinator::clearPendingLoaders();
         $this->__preparableProfEntry->startTimer('do_round');
     }
     SignalFetch::assertNotSignaled();
     $this->sequentialPasses = 0;
     $this->__state = PreparableState::RUNNING;
     do {
         ++$this->sequentialPasses;
         // SKIPPING CODE IN www
         $this->__needsFetch = SignalFetch::attributeTo($this);
     } while ($this->__canMakeProgress());
     // nested prep() could have failed us
     if ($this->__state !== PreparableState::FAILED) {
         $this->__state = PreparableState::BLOCKED;
     }
     /*
      This assignment must come after prepare(), otherwise an inline
      prep() may have incremented the pass after it has been saved.
     
      See comment in Preparer::moveToRunnableSet() for more
      discussion.
     
      If no fetch is required then we want to make sure $this can run
      immediately after becoming unblocked rather than waiting for the
      next dispatch.  Setting to null here causes moveToRunnableSet()
      to put this on the runnable queue to run immediately rather than
      the incomplete queue which runs after a dispatch.
     */
     $this->lastPass = $this->__needsFetch ? Preparer::getGlobalPass() : null;
     if ($toProfile) {
         $this->__preparableProfEntry->stopTimer('do_round');
         if ($this->__needsFetch) {
             $this->__preparableProfEntry->startTimer('dispatch');
             memcache_dispatch();
             $this->__preparableProfEntry->stopTimer('dispatch');
         }
     }
 }
예제 #2
0
 /**
  * @param array $data
  * @param array $arrayKeys
  * @return string
  */
 public function sign(array $data, array $arrayKeys)
 {
     $strToSign = $this->preparer->getStringToSign($data, $arrayKeys);
     return $this->signator->sign($strToSign);
 }
예제 #3
0
 /**
  * @param array $data
  * @param array $arrayKeys
  * @param string $signatureBase64
  * @return bool
  */
 public function verify(array $data, array $arrayKeys, $signatureBase64)
 {
     $strToSign = $this->preparer->getStringToSign($data, $arrayKeys);
     return $this->verifier->verify($strToSign, $signatureBase64);
 }
예제 #4
0
 public function testUnusedPrefillsShouldNotBePrefilled()
 {
     $testValue = 1;
     $testKey = 'test1';
     $requirement = new TestRequirement($testKey, true);
     $preparable = $this->buildPreparableMock($requirement, $testKey, $testValue);
     $resolver = $this->buildResolverMock($requirement, $testValue, 1);
     $preparer = new Preparer([TestRequirement::class => $resolver]);
     $preparer->prepare($preparable, [$testKey . '123' => $testValue]);
 }