Creates object from $parsedResponse.

@param array $parsedResponse JSON response parsed into array

@return OAuthAccessToken
327931
public static function create(array $parsedResponse)
    {
        $result = new self();

        $result->setAccessToken($parsedResponse[Resources::OAUTH_ACCESS_TOKEN]);
        $result->setExpiresIn($parsedResponse[Resources::OAUTH_EXPIRES_IN] + time());
        $result->setScope($parsedResponse[Resources::OAUTH_SCOPE]);

        return $result;
    }
1030211
protected function createResponse($rawResponse)
    {
        $response = new Response();

        $headerSize = curl_getinfo($this->handle, CURLINFO_HEADER_SIZE);
        $rawHeaders = trim(substr($rawResponse, 0, $headerSize));
        $rawHeadersArray = explode("\r\n\r\n", $rawHeaders);

        if (!empty($rawHeadersArray)) {
            $headerLines = explode("\r\n", $rawHeadersArray[0]);
            foreach ($headerLines as $headerLine) {
                if (stripos(trim($headerLine), 'http', 0) === 0) {
                    if (preg_match('/^http\/((\d*[.])?\d+)\s+(\d+)\s+([a-z]+)/i', trim($headerLine), $matches)) {
                        $response = $response->withStatus($matches[3], $matches[4])
                            ->withProtocolVersion($matches[1]);
                    }
                    continue;
                }

                $header = explode(':', $headerLine, 2);
                $name = trim($header[0]);
                $value = trim($header[1]);

                if ($response->hasHeader($name)) {
                    $response = $response->withAddedHeader($name, $value);
                } else {
                    $response = $response->withHeader($name, $value);
                }
            }
        }

        $content = substr($rawResponse, $headerSize);
        $response->getBody()->write($content);
        $response->getBody()->rewind();

        return $response;
    }
437842
public static function create($parsed)
    {
        $result = new self();
        $properties = Utilities::tryGetValue(
            $parsed,
            Resources::XTAG_HOSTED_SERVICE_PROPERTIES
        );
        $result->_hostedService = new HostedService($parsed, $properties);

        return $result;
    }
401174
private function createUserByOAuthUserResponse(UserResponseInterface $response): WebUserInterface
    {
        /** @var WebUserInterface $user */
        $user = $this->userFactory->createNew();

        if (!$canonicalEmail = $this->canonicalizer->canonicalize($response->getEmail())) {
            throw new AuthorizationException('phpmob.ui.oauth_response_not_found_email');
        }

        $user->setEmailCanonical($canonicalEmail);

        if ($firstName = $response->getFirstName()) {
            $user->setFirstName($firstName);
        }

        if ($lastName = $response->getLastName()) {
            $user->setLastName($lastName);
        }

        if ($displayName = $response->getRealName()) {
            $user->setDisplayName($displayName);
        }

        // set random password to prevent issue with not nullable field & potential security hole
        $user->setPlainPassword(substr(sha1($response->getAccessToken()), 0, 10));
        $user->setEnabled(true);

        return $this->updateUserByOAuthUserResponse($user, $response);
    }
794867
public static function create(array $tokens) {
        HashMap::assert($tokens, 'tokens');

        if (empty($tokens['ORDER'])) return [];

        $headers = [];
        $orderQueryArr = array_map(function($order){
            $query = end($order['no_quotes']['parts']);
            if (empty($query)) return null;
            return !isset($order['direction']) ? $query : $query . ' ' . $order['direction'];
        },$tokens['ORDER']);
        array_push($headers, 'Order: '.implode(',',$orderQueryArr));
        return $headers;
    }
750291
protected function buildUrl(array $parsedUrl)
    {
        if (true === isset($parsedUrl['scheme'])) {
            $scheme = $parsedUrl['scheme'].'://';
        } else {
            $scheme = '';
        }

        if (true === isset($parsedUrl['host'])) {
            $host = $parsedUrl['host'];
        } else {
            $host = '';
        }

        if (true === isset($parsedUrl['port'])) {
            $port = ':'.$parsedUrl['port'];
        } else {
            $port = '';
        }

        if (true === isset($parsedUrl['user'])) {
            $user = (string) $parsedUrl['user'];
        } else {
            $user = '';
        }

        if (true === isset($parsedUrl['pass'])) {
            $pass = ':'.$parsedUrl['pass'];
        } else {
            $pass = '';
        }

        if (false === empty($user) || false === empty($pass)) {
            $host = '@'.$host;
        }

        if (true === isset($parsedUrl['path'])) {
            $path = (string) $parsedUrl['path'];
        } else {
            $path = '';
        }

        if (true === isset($parsedUrl['query'])) {
            $query = '?'.$parsedUrl['query'];
        } else {
            $query = '';
        }

        if (true === isset($parsedUrl['fragment'])) {
            $fragment = '#'.$parsedUrl['fragment'];
        } else {
            $fragment = '';
        }

        return $scheme.$user.$pass.$host.$port.$path.$query.$fragment;

    }
573474
private static function createOTP(array $parsed_url): OTPInterface
    {
        switch ($parsed_url['host']) {
            case 'totp':
                $totp = TOTP::create($parsed_url['query']['secret']);
                $totp->setLabel(self::getLabel($parsed_url['path']));

                return $totp;
            case 'hotp':
                $hotp = HOTP::create($parsed_url['query']['secret']);
                $hotp->setLabel(self::getLabel($parsed_url['path']));

                return $hotp;
            default:
                throw new \InvalidArgumentException(sprintf('Unsupported "%s" OTP type', $parsed_url['host']));
        }
    }
588529
protected function transformMessage(ParsedMessage $parsedMessage)
    {
        $message = new \Swift_Message();

        if ($from = $parsedMessage->getFrom()) {
            $message->setFrom($from);
        }

        // handle to with defaults
        if ($to = $parsedMessage->getTo()) {
            $message->setTo($to);
        }

        // handle cc with defaults
        if ($cc = $parsedMessage->getCc()) {
            $message->setCc($cc);
        }

        // handle bcc with defaults
        if ($bcc = $parsedMessage->getBcc()) {
            $message->setBcc($bcc);
        }

        // handle reply to with defaults
        if ($replyTo = $parsedMessage->getReplyTo()) {
            $message->setReplyTo($replyTo);
        }

        // handle subject with default
        if ($subject = $parsedMessage->getSubject()) {
            $message->setSubject($subject);
        }

        // handle body, no default values here
        $message->setBody($parsedMessage->getMessageText());
        if ($parsedMessage->getMessageHtml()) {
            $message->addPart($parsedMessage->getMessageHtml(), 'text/html');
        }

        return $message;
    }
530399
public function makeSignedRequest($url, $options = array(), $parseJson = true) {
		if (!$this->getIsAuthenticated()) {
			throw new CHttpException(401, Yii::t('eauth', 'Unable to complete the authentication because the required data was not received.', array('{provider}' => $this->getServiceTitle())));
		}

		$options['query']['oauth_token'] = $this->access_token;
		$result = $this->makeRequest($url, $options);
		return $result;
	}
428368
public static function create($response)
    {
        Validate::isString($response, 'response');

        $wrapAccessTokenResult = new self();
        parse_str($response, $parsedResponse);

        $wrapAccessTokenResult->setAccessToken(
            Utilities::tryGetValue(
                $parsedResponse, Resources::WRAP_ACCESS_TOKEN
            )
        );

        $wrapAccessTokenResult->setExpiresIn(
            Utilities::tryGetValue(
                $parsedResponse, Resources::WRAP_ACCESS_TOKEN_EXPIRES_IN
            )
        );

        return $wrapAccessTokenResult;
    }
1171546
public function parse(): Parsed
    {
        return new Parsed(
            $this->jwt,
            $this->decodeHeader(),
            $this->decodePayload(),
            $this->getSignature()
        );
    }
1085845
protected function createDefaultJwtAccessTokenResponseType()
    {
        if (!isset($this->storages['public_key'])) {
            throw new \LogicException('You must supply a storage object implementing OAuth2\Storage\PublicKeyInterface to use crypto tokens');
        }

        $tokenStorage = null;
        if (isset($this->storages['access_token'])) {
            $tokenStorage = $this->storages['access_token'];
        }

        $refreshStorage = null;
        if (isset($this->storages['refresh_token'])) {
            $refreshStorage = $this->storages['refresh_token'];
        }

        $config = array_intersect_key($this->config, array_flip(explode(' ', 'store_encrypted_token_string issuer access_lifetime refresh_token_lifetime jwt_extra_payload_callable')));

        return new JwtAccessToken($this->storages['public_key'], $tokenStorage, $refreshStorage, $config);
    }
273235
public static function create($parsed)
    {
        $result = new self();

        $result->_id = Utilities::tryGetValue(
            $parsed,
            Resources::XTAG_ID
        );
        $result->_status = Utilities::tryGetValue(
            $parsed,
            Resources::XTAG_STATUS
        );
        $result->_httpStatusCode = Utilities::tryGetValue(
            $parsed,
            Resources::XTAG_HTTP_STATUS_CODE
        );
        $error = Utilities::tryGetValue(
            $parsed,
            Resources::XTAG_ERROR
        );

        if (!empty($error)) {
            $code = Utilities::tryGetValue($error, Resources::XTAG_CODE);
            $message = Utilities::tryGetValue($error, Resources::XTAG_MESSAGE);

            $result->_error = new ServiceException($code, $message);
        }

        return $result;
    }
715430
protected function post($url, $params, $parse = true){
		$curl = curl_init();
		curl_setopt($curl, CURLOPT_URL, $url);
		curl_setopt($curl, CURLOPT_POST, 1);
//		curl_setopt($curl, CURLOPT_POSTFIELDS, urldecode(http_build_query($params)));
//		curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($params));
		curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
		curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
		$result = curl_exec($curl);
		curl_close($curl);
		if($parse){
			$result = json_decode($result, true);
			}
		return $result;
		}
34512
public function makeSignedRequest($url, $options = array(), $parseJson = true) {
		if (!$this->getIsAuthenticated()) {
			throw new CHttpException(401, 'Unable to complete the authentication because the required data was not received.');
		}

		$options['query']['oauth_token'] = $this->access_token;
		$result = $this->makeRequest($url, $options);
		return $result;
	}
378378
public static function createFromRaw($rawResponse, Response $parentResponse = null)
    {
        /** @var Response $response */
        $response = ResponseInformationHelper::createFromRaw($rawResponse, self::class);
        $response->parentResponse = $parentResponse;

        return $response;
    }
134384
protected function setParsedData($parsedData): Payload
    {
        $data = json_decode($parsedData);
        if (JSON_ERROR_NONE === json_last_error()) {
            $this->parsedData = $data;
        }

        return $this;
    }