/**
  * {@inhertidoc}
  * @see \InoOicServer\Client\Authentication\Method\MethodInterface::authenticate()
  */
 public function authenticate(Client\Authentication\Info $info, Http\Request $httpRequest)
 {
     /* @var $httpRequest \Zend\Http\Request */
     $postVars = $httpRequest->getPost();
     if (($clientId = $postVars->get($this->getClientIdFieldName())) === null) {
         return $this->createFailureResult('Missing client ID');
     }
     if (($clientSecret = $postVars->get($this->getClientSecretFieldName())) === null) {
         return $this->createFailureResult('Missing client secret');
     }
     if ($clientId !== $info->getClientId()) {
         return $this->createFailureResult(sprintf("Unknown client ID '%s'", $clientId));
     }
     if ($clientSecret !== $info->getOption(self::AUTH_OPTION_SECRET)) {
         return $this->createFailureResult('Invalid authorization');
     }
     return $this->createSuccessResult();
 }
 /**
  * {@inhertidoc}
  * @see \InoOicServer\Client\Authentication\Method\MethodInterface::authenticate()
  */
 public function authenticate(Client\Authentication\Info $info, Http\Request $httpRequest)
 {
     /* @var $httpRequest \Zend\Http\Request */
     $authorizationHeader = $httpRequest->getHeader('Authorization');
     if (!$authorizationHeader) {
         return $this->createFailureResult('Missing authorization header');
     }
     $value = $authorizationHeader->getFieldValue();
     $parts = explode(' ', $value);
     if ('basic' !== trim(strtolower($parts[0]))) {
         return $this->createFailureResult(sprintf("Unsupported authorization '%s'", $parts[0]));
     }
     if (!isset($parts[1])) {
         return $this->createFailureResult('Missing authorization hash');
     }
     $receivedHash = trim($parts[1]);
     $clientHash = base64_encode(sprintf("%s:%s", $info->getClientId(), $info->getOption(self::AUTH_OPTION_SECRET)));
     if ($receivedHash !== $clientHash) {
         return $this->createFailureResult('Invalid authorization');
     }
     return $this->createSuccessResult();
 }
 public function testConstructor()
 {
     $this->assertSame('abc', $this->info->getClientId());
     $this->assertSame('secret', $this->info->getMethod());
     $this->assertSame(array('foo' => 'bar'), $this->info->getOptions());
 }