security mechanism response

@param string $response
486704
protected function _xSecureOk($response)
    {
        $args = new Writer();
        $args->writeLongStr($response);
        $this->sendMethodFrame(array(10, 21), $args);
    }
163062
public function isValid($response)
    {
        if (is_null($this->secretKey))
            throw new \Exception('You must set your secret key');

        if (empty($response)) {

            $this->errorCodes = array('internal-empty-response');

            return false;
        }

        $params = array(
            'secret'   => $this->secretKey,
            'response' => $response,
            'remoteip' => $this->remoteIp,
        );

        $url = self::VERIFY_URL.'?'.http_build_query($params);

        if (function_exists('curl_version'))
        {
            $curl = curl_init($url);
            curl_setopt($curl, CURLOPT_HEADER, false);
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($curl, CURLOPT_TIMEOUT, $this->verifyTimeout);
            curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
            $response = curl_exec($curl);
        }
        else
        {
            $response = file_get_contents($url);
        }

        if (empty($response) || is_null($response) || !$response)
        {
            return false;
        }

        $json = json_decode($response, true);

        if (isset($json['error-codes']))
        {
            $this->errorCodes = $json['error-codes'];
        }

        return $json['success'];
    }
716105
public function verify($response)
    {
        if (!$this->secretKey) {
            throw new Exception('Missing secret key');
        }

        $params = array(
            'secret' => $this->secretKey,
            'response' => $response,
        );

        if ($this->ip !== null) {
            $params['remoteip'] = $this->ip;
        }

        $this->httpClient->setUri(self::VERIFY_SERVER);
        $this->httpClient->setParameterPost($params);

        if ($this->options) {
            $this->httpClient->setOptions($this->options);
        }

        $this->httpClient->setMethod('POST');
        $response = $this->httpClient->send();

        return new CaptchaResponse($response);
    }
501447
public function decryptResponse($response)
    {
        if (!is_string($response)) {
            return $response;
        }

        if ($this->usesEncryption()) {
            return json_decode(
                json_encode(
                    JWT::decode(
                        $response,
                        $this->encryptionKey,
                        array($this->encryptionAlgorithm)
                    )
                ),
                true
            );
        }

        throw EncryptionConfigurationException::undeterminedEncryption();
    }
103354
public function handleResponse($response)
    {
        switch (true) {
            // Render default template and use $response as template variables
            case is_array($response) :
                $content = $this->view->render($this->getDefaultTemplate(), $response);

                return $this->response->setContent($content);

            // Response directly
            case is_scalar($response) || is_null($response) :
                return $this->response->setContent($response);

            // Response if not sent
            case $response instanceof Response :
                return $response;

            default :
                throw new \InvalidArgumentException(sprintf(
                    'Expected argument of type array, printable variable or \Wei\Response, "%s" given',
                    is_object($response) ? get_class($response) : gettype($response)
                ));
        }
    }
319060
protected function encrypt(Response $response)
	{
		foreach ($response->headers->getCookies() as $key => $c)
		{
			$encrypted = $this->encrypter->encrypt($c->getValue());

			$response->headers->setCookie($this->duplicate($c, $encrypted));
		}

		return $response;
	}
300937
public function prepareForResponse(Response $response) {
		$response->setStatus($this->httpStatus);
		$response->setHeader('Content-Type: text/html; charset=' . N2N::CHARSET);
		$response->setHeader('Location: ' . $this->httpLocation);
	}
948232
public function dispatchResponse($response)
    {
        $parts = explode("\r\n\r\n", $response, 2);

        if (count($parts) < 2) {
            $this->throwException();
        }

        list($headersAsString, $body) = $parts;

        $headers = explode("\r\n", $headersAsString);
        list($code, $status) = $this->dispatchHttpStatus(array_shift($headers));
        $headers = $this->dispatchHeaders($headers);

        /** @var Emagedev_Utils_Model_Curl_Response $responseObject */
        $responseObject = Mage::getModel('emagedev_utils/curl_response');

        return $responseObject->setData(
            array(
                'code' => $code,
                'status' => $status,
                'headers_as_string' => $headersAsString,
                'headers' => $headers,
                'body' => $body
            )
        );
    }
212017
public function respond($response)
	{
		if (
			$this->logger !== null &&
			$this->logger->isHandling(Logger::DEBUG)
		) {
			$this->logger->addDebug(
				'Send response',
				array(
					 'content-type' => $this->contentType,
					 'response'     => ctype_print($response) ? $response : 'base64:' . base64_encode($response)
				)
			);
		}

		ob_start();
		while (ob_end_clean()) {
		}
		header('Content-Type: ' . $this->contentType);
		echo $response;
	}
200697
private function parseDiscoveryResponse($response)
    {
        $body = json_decode($response->getBody(), true);

        $this->authorization_endpoint = $body['authorization_endpoint'];
        $this->token_endpoint = $body['token_endpoint'];
        $this->end_session_endpoint = $body['end_session_endpoint'];
        $this->userinfo_endpoint = $body['userinfo_endpoint'];
        $this->jwks_uri = $body['jwks_uri'];

        $this->scopes_supported = $body['scopes_supported'];
    }
67666
public function parseResponse($response)
    {
        // Parse the response and set the last response and headers.
        $info = curl_getinfo($this->ch);
        $this->__last_response_headers = substr(
            $response,
            0,
            $info['header_size']
        );
        $this->__last_response = substr($response, $info['header_size']);
    }
912337
protected function _withCustomHeaders($response)
    {
        foreach ((array)$this->getConfig('headers') as $key => $value) {
            $response = $response->withHeader($key, $value);
        }

        return $response;
    }
1047826
private function checkResponse($response)
    {
        $hasRequestError = false;
        if (preg_match('/4\d\d/', $response->getStatusCode())) {
            $this->log('error', "Invalid API key or password");
            $this->addError(self::ERROR_HTTP_AUTHENTICATION_ERROR, false);
            $hasRequestError = true;
        } elseif (preg_match('/5\d\d/', $response->getStatusCode())) {
            $this->log('error', "Gateway error - HTTP " . $response->getStatusCode());
            $this->addError(self::ERROR_HTTP_SERVER_ERROR);
            $hasRequestError = true;
        } elseif ($response->getError()) {
            $this->log('error', "Connection error: " . $response->getError());
            $this->addError(self::ERROR_CONNECTION_ERROR);
            $hasRequestError = true;
        }

        if ($hasRequestError) {
            throw new RequestException(sprintf("Last HTTP response status code: %s", $response->getStatusCode()));
        }
    }
979860
protected function processSecurityTokenResponse($response)
    {
        $xml = new \DOMDocument();
        $xml->loadXML($response);
        $xpath = new \DOMXPath($xml);
        if ($xpath->query("//wsse:BinarySecurityToken")->length > 0) {
            $nodeToken = $xpath->query("//wsse:BinarySecurityToken")->item(0);
            if (!empty($nodeToken)) {
              return $nodeToken->nodeValue;
            }
        }

        if ($xpath->query("//S:Fault")->length > 0) {
            // Returning the full fault value in case any other response comes within the fault node.
            throw new \RuntimeException($xpath->query("//S:Fault")->item(0)->nodeValue);
        }

        throw new \RuntimeException('Error trying to get a token, check your URL or credentials');
    }
587025
protected function store_response($response) {

        set_config('recentfetch', time(), 'core_plugin');
        set_config('recentresponse', $response, 'core_plugin');

        if (defined('CACHE_DISABLE_ALL') and CACHE_DISABLE_ALL) {
            // Very nasty hack to work around cache coherency issues on admin/index.php?cache=0 page,
            // we definitely need to keep caches in sync when writing into DB at all times!
            \cache_helper::purge_all(true);
        }

        $this->restore_response(true);
    }
613697
protected function addCookieConsentScriptToResponse(Response $response)
    {
        $content = $response->getContent();

        $closingBodyTagPosition = $this->getLastClosingBodyTagPosition($content);

        $content = ''
            .substr($content, 0, $closingBodyTagPosition)
            .view('cookieConsent::index')->render()
            .substr($content, $closingBodyTagPosition);

        return $response->setContent($content);
    }
914734
public static function decode_response($response)
    {
        if (!$response) {
            return PASSWORD_CONNECT_ERROR;
        }

        // $result should be `null` or `stdClass` object
        $result = json_decode($response);

        // The UAPI may return HTML instead of JSON on missing authentication
        if ($result && $result->status === 1) {
            return PASSWORD_SUCCESS;
        }

        if ($result && is_array($result->errors) && count($result->errors) > 0) {
            return array(
                'code'    => PASSWORD_ERROR,
                'message' => $result->errors[0],
            );
        }

        return PASSWORD_ERROR;
    }