示例#1
0
 /**
  * @access public
  */
 public function generateKeyAction(Request $request)
 {
     $values = $request->request->get('generator');
     $signature = null;
     if ('POST' === $request->getMethod()) {
         $encoder = new RequestSignatureEncoder();
         $requestToBeSigned = Request::create($values['url'], $values['method']);
         $signature = $encoder->createSignature($requestToBeSigned, $values['private_key']);
     }
     return $this->render('Rest/test.html.twig', array('form' => $values, 'signature' => $signature));
 }
 /**
  * Updates the nonce value.
  *
  * @param string $nonce
  */
 protected function writeNonceValue(BBUserToken $token)
 {
     $now = strtotime($token->getCreated());
     $nonce = $token->getNonce();
     $signature_generator = new RequestSignatureEncoder();
     $signature = $signature_generator->createSignature($token);
     if (null === $this->registryRepository) {
         file_put_contents($this->nonceDir . DIRECTORY_SEPARATOR . $nonce, "{$now};{$signature}");
     } else {
         $registry = $this->getRegistry($nonce)->setValue("{$now};{$signature}");
         $this->registryRepository->save($registry);
     }
 }