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:----WgYAfUeFhxapiqKMD8oWpjlGF9Z1GSlUP96Qf3BxLY4ItV4Ltz3tB73yftGc7kD9IsvLmZtp0N1Cf+dF9VJpoLz+H+UBUsoflFxNWSCtoLzCuRefiprGDh3u/Eoe/rY5G9xmg+VGU9r66d42aTvun07qgHvNmnke8+m0bfBN7Z3uTp2NRq9SZ9v4IlEvwCLZ0oCnmNZc2ZUH/oJ/EKBE1kMy/1G68jg6HKc5Wm/Q9KOp5gm/yUSDkpNYFPUalnK/A/ZiFrj06RK+amWGx45k+7v/SsRFVFlD5nt+2uUWH02nXqFnH4D22KcRYcv+723k83LJ8UN5x9JZJugSgAVDgxfHDrU2eYO/hq3rXQo0aM7xLymc9BvWGHwA503FKEksmyy1kfb/yM6vMewkwoI7Xh22qLu5gw1Oh7r0BhPNBg0cY1oe7uZc48FZfQHp1JDObM6ADpblMtLE+LLSK6qtNWzJtlfNizHVqJqFjpMwznwGwuk6tQPfvUKDEAZp5zMs71SCKm5nvVhV06X91OxEBnAi+vFK3eY+QQfMyOxN9T51KCDTUcHSR3jAJ+WjTTurr4YwRp8sp79S8cE40qmARwY3IsuIUIWXhm3GaUGFf5IUOlLeM8mGQJTAGrneSFCXkMk1EgvWOviPJpSFVa/q/SPIXjPU2Rjqt+38b3cZOw0=----ATTACHMENT:----MTE1MDQ2NTE0MjcyMTU0OSAzODQ5OTcwMjkwMTYwNzA4IDU2NTkxMzMwNTM1ODgwODc=