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:----IPd6C9Al8b3fexTaPOsN5A4TItR5x0RmArtUhGvU7s43y7suq8XP5h2WlldF2Z9FQYXRhaX5mziEY5/YcUw1/2ikHl72xz28rkSbUCtykypeAOjK8u+dU+5GQHtV9oEp7FePLZrY3hgn4vtawjvyFqTH4/6immY8rOf7oDd1Xa+eFQUEHi541X7wvQM6MXQ8C9m9+sudtMMRNCKQAjiTs7IqZ+AjHuwZ0RsgyrfGhKAkv9ikAOKLgyVkg5zNOhDaB+uPYfT0BfnQs5D7s1x9vkwk2xXQAZaI+6Xs9VPGeTWksSK6FBs2CgqWX5VXh5W+DXneMELBIfwcqB0bQM9suqRZqi94QjVlhAXsDqB9a5cUYR1Spn0Yu0Y2PUpxeBmAucennOnO5AiAeNICSHhTKH1GsN9H4ltTSuVsuqNEOHQhRicU+SsJiujDjYHq4XoQdqTBmeU68Sc2sIpAq1pe+h4rZvgsuk+xtizpfOlGVMyTx7cN5e1OMTnbRSeKksLc+OfmdYAGBhXLgypOvWnS8V6L0uMKk5I4ZTO1VM5dqo7vJ0f67/h6M2g0EqUFOsFCBtLyQ9G4BSuB1NsgUdQgey5yq77Y16ZD0lFvRDLyP2mtfskpzInNUEm6jnU3vkUQMp9uB5QashV+4rHgkWAB1oJ1se8tF/j4PD0wpInNjuk=----ATTACHMENT:----MjU3NjA4MzA2NDEwNjU4OSAxNzA5NjEzNDk0MjE3NzYyIDgyMjA2OTYyMjE2MjEyNjU=