예제 #1
0
 /**
  * {@inheritdoc}
  */
 public function checkElement(DigestDataInterface $digest_data)
 {
     $opaque = base64_encode(hash_hmac($this->hash_algorithm, $digest_data->get('nonce') . $digest_data->get('realm'), $this->hash_key, true));
     if ($opaque !== $digest_data->get('opaque')) {
         throw new \InvalidArgumentException('Invalid "opaque" value.');
     }
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function checkElement(DigestDataInterface $digest_data)
 {
     if (false === $digest_data->has('nonce')) {
         throw new \InvalidArgumentException('Missing mandatory digest value: "nonce".');
     }
     if (false === ($nonceAsPlainText = base64_decode($digest_data->get('nonce')))) {
         throw new \InvalidArgumentException(sprintf('Nonce is not encoded in Base64; received nonce "%s".', $digest_data->get('nonce')));
     }
     $nonceTokens = explode(':', $nonceAsPlainText);
     if (2 !== count($nonceTokens)) {
         throw new \InvalidArgumentException(sprintf('Nonce should have yielded two tokens but was "%s".', $nonceAsPlainText));
     }
     $nonce_expiry_time = $nonceTokens[0];
     $signature = $nonceTokens[1];
     $this->checkSignature($nonce_expiry_time, $signature);
     $this->checkExpired($nonce_expiry_time);
 }
예제 #3
0
 /**
  * {@inheritdoc}
  */
 public function checkElement(DigestDataInterface $digest_data)
 {
     if ($this->realm !== $digest_data->get('realm')) {
         throw new \InvalidArgumentException(sprintf('Response realm name "%s" does not match system realm name of "%s".', $digest_data->get('realm'), $this->realm));
     }
 }
 /**
  * @param \HttpDigest\DigestDataInterface $digest_data
  * @param bool                            $is_sess
  *
  * @return \HttpDigest\Algorithm\AlgorithmInterface
  */
 private function getAlgorithm(DigestDataInterface $digest_data, &$is_sess)
 {
     $algorithm_name = $digest_data->has('algorithm') ? $digest_data->get('algorithm') : 'MD5';
     if ('-sess' === substr($algorithm_name, 0, -5)) {
         $is_sess = true;
         $algorithm_name = substr($algorithm_name, 0, strlen($algorithm_name) - 5);
     } else {
         $is_sess = false;
     }
     return $this->getSchemeAlgorithm($algorithm_name);
 }
 private function checkSubElement(DigestDataInterface $digest_data, $element)
 {
     if (!$digest_data->has($element)) {
         throw new \InvalidArgumentException(sprintf('Missing mandatory digest value "%s".', $element));
     }
 }
 /**
  * {@inheritdoc}
  */
 public function checkElement(DigestDataInterface $digest_data)
 {
     if ($keys = array_diff(['realm', 'nonce', 'uri', 'response', 'opaque'], $digest_data->all())) {
         throw new \InvalidArgumentException(sprintf('Missing mandatory digest value(s): %s.', implode(', ', $keys)));
     }
 }
 private function checkUsername(DigestDataInterface $digest_data)
 {
     if (!$digest_data->has('username')) {
         throw new \InvalidArgumentException('Missing mandatory digest value "username".');
     }
 }