Verifies the signature for the response.

@throws InvalidResponseException if the signature doesn't match

@return void
266
public function verifySignature()
    {
        if ( isset($this->data['CreditCardTransactionResults']['ResponseCode']) && (
            '1' == $this->data['CreditCardTransactionResults']['ResponseCode'] ||
            '2' == $this->data['CreditCardTransactionResults']['ResponseCode']) )
        {
            $signature  = $this->request->getMerchantPassword();
            $signature .= $this->request->getMerchantId();
            $signature .= $this->request->getAcquirerId();
            $signature .= $this->request->getTransactionId();

            $signature  = base64_encode( sha1($signature, true) );

            if ( $signature !== $this->data['Signature'] ) {
                throw new InvalidResponseException('Signature verification failed');
            }
        }
    }
355096
private function verifySignature(Object\JWSInterface $jws, Object\JWKSetInterface $jwk_set, Object\SignatureInterface $signature, $detached_payload = null)
    {
        $input = $this->getInputToVerify($jws, $signature, $detached_payload);
        foreach ($jwk_set->getKeys() as $jwk) {
            $algorithm = $this->getAlgorithm($signature);

            try {
                $this->checkKeyUsage($jwk, 'verification');
                $this->checkKeyAlgorithm($jwk, $algorithm->getAlgorithmName());
                if (true === $algorithm->verify($jwk, $input, $signature->getSignature())) {
                    return true;
                }
            } catch (\Exception $e) {
                //We do nothing, we continue with other keys
                continue;
            }
        }

        return false;
    }
1298383
public function responseIsSuccessfully()
    {
        Assertions::assertEquals(200, $this->response->getStatusCode(), sprintf(
            'Response with error "%s".',
            $this->response->getBody()
        ));

        Assertions::assertNull($this->response->getRpcErrorCode(), sprintf(
            'Response with error "%s".',
            $this->response->getBody()
        ));
    }
700426
protected function validateServerResponse(Response $response)
    {
        switch ($response->getStatusCode()) {
            case Response::REST_CLIENT_ERROR_UNAUTHORIZED:
                throw new ClientException('You have provided an invalid API key', ClientException::INVALID_APPLICATION_SECRET, $response);
                break;
            case Response::REST_CLIENT_ERROR_FORBIDDEN:
                throw new ClientException('Your account is not enabled for the service', ClientException::INVALID_APPLICATION_SECRET, $response);
                break;
            case Response::REST_CLIENT_ERROR_NOT_FOUND:
                throw new ClientException('The requested entity was not found on the server', ClientException::ENTITY_NOT_FOUND, $response);
                break;
            case Response::REST_CLIENT_ERROR_CONFLICT:
                $body = $response->getBody();

                $message = (isset($body['detail'])) ? $body['detail'] : 'The request was rejected due to an conflict.';
                throw new ClientException($message, ClientException::INVALID_RESPONSE, $response);
                break;
            case Response::REST_CLIENT_ERROR_UNPROCESSABLE_ENTITY:
                $body = $response->getBody();

                $message = (isset($body['detail'])) ? $body['detail'] : 'Unable to process the request';
                throw new ClientException($message, ClientException::INVALID_RESPONSE, $response);
                break;
            case Response::REST_CLIENT_ERROR_LOCKED:
                $body = $response->getBody();

                $message = (isset($body['detail'])) ? $body['detail'] : 'The request could not be processed as the entity was locked.';
                throw new ClientException($message, ClientException::INVALID_RESPONSE, $response);
                break;
            case Response::REST_CLIENT_ERROR_TOO_MANY_REQUESTS:
                throw new ClientException('You are sending too fast and your calls are throttled', ClientException::SERVER_UNAVAILABLE, $response);
                break;
            case Response::REST_CLIENT_ERROR_PAYMENT_REQUIRED:
                throw new ClientException('Insufficient credit for your wallet', ClientException::INSUFFICIENT_CREDIT, $response);
                break;
            case Response::REST_SUCCESS_OK:
            case Response::REST_SUCCESS_CREATED:
                break; // Valid response
            default:
                throw new ClientException(sprintf('Unknown status code %d received from server', $response->getStatusCode()), ClientException::INVALID_RESPONSE, $response);
                break;
        }
    }
269482
protected function checkErrorResponse(ResponseInterface $response)
    {
        $statusCode = $response->getStatusCode();
        if (200 <= $statusCode && $statusCode < 299) {
            if (!$response->getBody()->getSize()) {
                throw new BadResponseException('unexpected empty body');
            }

            return;
        }

        // Mitake API always return status code 200
        throw new BadResponseException(sprintf('unexpected status code: %d', $statusCode));
    }
282279
public static boolean verify(
      Signature signatureAlgorithm, PublicKey publicKey, byte[] signatureBytes, byte[] contentBytes)
      throws InvalidKeyException, SignatureException {
    signatureAlgorithm.initVerify(publicKey);
    signatureAlgorithm.update(contentBytes);
    // SignatureException may be thrown if we are tring the wrong key.
    try {
      return signatureAlgorithm.verify(signatureBytes);
    } catch (SignatureException e) {
      return false;
    }
  }
378037
public function verifySignedStringResponse(
        ResponseInterface $response,
        SigningPublicKey $publicKey
    ): string {
        $verified = $this->verifySignedResponse($response, $publicKey);
        return (string) $verified->getBody();
    }
220559
protected function verifyResponse($response)
    {
        if (false === $response) {
            throw new BadResponseException('WAMP Server did not respond properly');
        }

        $subres = substr($response, 0, 12);

        if ($subres != 'HTTP/1.1 101') {
            throw new BadResponseException('Unexpected Response. Expected HTTP/1.1 101 got ' . $subres);
        }
    }
108090
protected function _verifyResponse($expected)
	{
		$parts = null;

		// Wait for a response from the server, but timeout after the set time limit
		$endTime = time() + $this->timeout;
		$this->response = '';

		do
		{
			$this->response .= fgets($this->conn, 4096);
		}

		while (!preg_match("/^([0-9]{3})(-(.*" . CRLF . ")+\\1)? [^" . CRLF . "]+" . CRLF . "$/", $this->response, $parts) && time() < $endTime);

		// Catch a timeout or bad response
		if (!isset($parts[1]))
		{
			Log::add(
				sprintf(
					'%1$s: Timeout or unrecognised response while waiting for a response from the server. Server response: %2$s',
					__METHOD__, $this->response
				),
				Log::WARNING, 'jerror'
			);

			return false;
		}

		// Separate the code from the message
		$this->_responseCode = $parts[1];
		$this->_responseMsg = $parts[0];

		// Did the server respond with the code we wanted?
		if (is_array($expected))
		{
			if (in_array($this->_responseCode, $expected))
			{
				$retval = true;
			}
			else
			{
				$retval = false;
			}
		}
		else
		{
			if ($this->_responseCode == $expected)
			{
				$retval = true;
			}
			else
			{
				$retval = false;
			}
		}

		return $retval;
	}
1234568
protected function checkSignature(&$request, $consumer, $token)
    {
        // this should probably be in a different method
        $timestamp = @$request->getParameter('oauth_timestamp');
        $nonce = @$request->getParameter('oauth_nonce');
        
        $this->checkTimestamp($timestamp);
        $this->checkNonce($consumer, $token, $nonce, $timestamp);
        
        $signature_method = $this->getSignatureMethod($request);
        
        $signature = $request->getParameter('oauth_signature');
        $valid_sig = $signature_method->check_signature(
            $request,
            $consumer,
            $token,
            $signature
        );
        
        if (!$valid_sig) {
            throw new OAuthException("Invalid signature");
        }
    }
19952
def validate(self):
        
        if not self.api_token or not self.api_token_secret:
            raise ImproperlyConfigured("'api_token' and 'api_token_secret' are required for authentication.")

        if self.response_type not in ["json", "pson", "xml", "debug", None]:
            raise ImproperlyConfigured("'%s' is an invalid response_type" % self.response_type)
62456
protected function isValidResponse($response)
    {
        if (empty($this->acceptable)) {
            return true;
        }

        if ($this->acceptableIsClosure()) {
            return call_user_func($this->acceptable, $response);
        }

        return $this->isAcceptableResponse($response);
    }
104147
private function checkSignature() 
    {
        if ($this->signature !== false && $this->timestamp !== false && $this->nonce !== false) {
            $tmp_signature = SHA1::getSignature($this->token, $this->timestamp, $this->nonce);
            if ($tmp_signature === false) {
                error_log('Validate signature error.', 0);
            } else if ($tmp_signature === $this->signature) {
                return true;
            }
        }
        return false;
    }
112698
protected function verifyResponse(Response $response)
    {
        $content = json_decode($response->getContent(), true);
        $statusCode = $response->getStatusCode();

        if ($statusCode !== 204 && null === $content) {
            throw new LibraryException('Unable to parse response from server (status code: '.$response->getStatusCode().') '.$response->getContent());
        }

        if (isset($content['status']) && $content['status'] !== ExceptionFactory::STATUS_SUCCESS) {
            throw ExceptionFactory::createExceptionFromArray($content);
        }

        if ($statusCode !== 200 && $statusCode !== 204 && ($statusCode < 300 || $statusCode > 303)) {
            throw new LibraryException(sprintf('Invalid status code (expected 200, 204, or 300-303. Got %s). Response content: %s', $statusCode, $response->getContent()));
        }
    }
52276
private function isJsonResponse(ResponseInterface $response)
    {
        if ($response->getStatusCode() == 200) {
            return;
        }

        if ($response->getStatusCode() == 400) {
            throw new InvalidRequestException($response);
        }

        if ($response->getStatusCode() == 401) {
            throw new UnauthorizedRequestException($response);
        }

        throw new ServerResponseException($response);
    }
28476
public function verify($response, $remoteIp = null)
    {
        $this->errors = [];
        try {
            $response = (new Client())->get($this->verificationUrl($response, $remoteIp))->send();
        } catch (GuzzleException $e) {
            $this->errors[] = 'transfer-error';

            return false;
        }
        
        if ($response->getStatusCode() !== 200) {
            $this->errors[] = 'api-error';

            return false;
        }

        try {
            $responseBody = $response->json();
        } catch (GuzzleException $e) {
            $this->errors[] = 'response-error';

            return false;
        }
        
        if (isset($responseBody['error-codes'])) {
            $this->errors = $responseBody['error-codes'];
        }
        return $responseBody['success'];
    }
1309095
public function verifyAction()
    {
        $server = $this->get('oauth2.server');

        if (!$server->verifyResourceRequest($this->get('oauth2.request'), $this->get('oauth2.response'))) {
            return $server->getResponse();
        }

        $tokenData = $server->getAccessTokenData($this->get('oauth2.request'), $this->get('oauth2.response'));

        return new JsonResponse($tokenData);
    }