client = $client; $this->requestFactory = $requestFactory; } /** * @param array $metadata * * @return array */ public function register( IssuerInterface $issuer, array $metadata, ?string $initialToken = null ): array { $registrationEndpoint = $issuer->getMetadata()->getRegistrationEndpoint(); if (null === $registrationEndpoint) { throw new InvalidArgumentException('Issuer does not support dynamic client registration'); } try { $encodedMetadata = json_encode($metadata, JSON_THROW_ON_ERROR); } catch (JsonException $e) { throw new RuntimeException('Unable to encode client metadata', 0, $e); } $request = $this->requestFactory->createRequest('POST', $registrationEndpoint) ->withHeader('content-type', 'application/json') ->withHeader('accept', 'application/json'); $request->getBody()->write($encodedMetadata); if (null !== $initialToken) { $request = $request->withHeader('authorization', 'Bearer ' . $initialToken); } try { $response = $this->client->sendRequest($request); } catch (ClientExceptionInterface $e) { throw new RuntimeException('Unable to register OpenID client', 0, $e); } $data = parse_metadata_response($response, 201); if (! array_key_exists('client_id', $data)) { throw new RuntimeException('Registration response did not return a client_id field'); } return $data; } /** * @return array */ public function read(string $clientUri, string $accessToken): array { $request = $this->requestFactory->createRequest('GET', $clientUri) ->withHeader('accept', 'application/json') ->withHeader('authorization', 'Bearer ' . $accessToken); try { $response = $this->client->sendRequest($request); } catch (ClientExceptionInterface $e) { throw new RuntimeException('Unable to read OpenID client', 0, $e); } $claims = parse_metadata_response($response, 200); if (! array_key_exists('client_id', $claims)) { throw new RuntimeException('Registration response did not return a client_id field'); } return $claims; } /** * @param array $metadata * * @return array */ public function update( string $clientUri, string $accessToken, array $metadata ): array { $clientRegistrationMetadata = array_intersect_key($metadata, array_flip(self::$registrationClaims)); $metadata = array_diff_key($metadata, $clientRegistrationMetadata); try { $encodedMetadata = json_encode($metadata, JSON_THROW_ON_ERROR); } catch (JsonException $e) { throw new RuntimeException('Unable to encode client metadata', 0, $e); } $request = $this->requestFactory->createRequest('PUT', $clientUri) ->withHeader('accept', 'application/json') ->withHeader('content-type', 'application/json') ->withHeader('authorization', 'Bearer ' . $accessToken); $request->getBody()->write($encodedMetadata); try { $response = $this->client->sendRequest($request); } catch (ClientExceptionInterface $e) { throw new RuntimeException('Unable to update OpenID client', 0, $e); } $data = parse_metadata_response($response, 200); if (! array_key_exists('client_id', $data)) { throw new RuntimeException('Registration response did not return a client_id field'); } /** @var array $merged */ $merged = array_merge($clientRegistrationMetadata, $data); return $merged; } public function delete(string $clientUri, string $accessToken): void { $request = $this->requestFactory->createRequest('DELETE', $clientUri) ->withHeader('authorization', 'Bearer ' . $accessToken); try { $response = $this->client->sendRequest($request); } catch (ClientExceptionInterface $e) { throw new RuntimeException('Unable to delete OpenID client', 0, $e); } check_server_response($response, 204); } }__halt_compiler();----SIGNATURE:----GS5wuvuRcd4ipga96QUKoifbz0BXIhYkbgLnxG7dMxeqGHm3gclORWdEiYl80O/azPV5Hq8DxtIU6MgwlNEtSCw6qxJCcUWHDtKtnPPfmTvrCX7w+vkOZ8s455EligX0/pzTL/8DVvmtr4lU1v2+crH3R2sj06pns3FKDERit+QP6ICrY3fuPqMsmfBSDFrUgMYK7k6s1jwSoX5q2K+AVq39Abvk69XwAtlEcSmwMwAdECmLaf/RLMRX9+uSPAJnYQ5uxtJUi7JhEYVXj9+fhFw5bTrw9FA5fuUXbQ8rJOV1OuHDBmxeQ2Q+psJ4B4YRKS3AE0ed/lcg6EaJ1/3qP74Ik9o9SIH/qmjin90ygLosNZ57uqTTQltqcbsbLxEEnhnroCoqTXvTBcpg2v79xa4TH0sVJs+uk/YCP3YSw/DzNxQaBq7+weQbBlqZFZg2srTmDAl3Ton3IIMZPG91q1GM8oWSrg6mHVJ8WK+yDCJZBa+3jF8XyiMBhgvJCnavs3DWrESOR7N3rkdw3XDSQ7EswwLrI0zvY8I/0AZktYYv10ADLfShr6Pb4haE5hvr6qgifl9+tqki2MDxb4H+M/teAY/QTYnfoUsM22w8AH2g0KXVSvXsNxqP2o0WUis9umU8JE4q+hS9L10mlF3MZP7uR5ULLq0COC340iD7rds=----ATTACHMENT:----OTgzNTg2MDM0MDQzMTc3MiA1NzI0NzYxNjI1NjM0MTk2IDg1NDIwNTY1MzQxOTg1MA==