setData('lti-jwks', json_encode($this->getJwksRepository()->find())); $this->setData('lti-key-chains', json_encode($this->getSafeKeyChains())); $this->setData( 'lti-key-chain-generate-url', $this->getUrlGenerator()->buildUrl('generate', 'KeyChainGenerator') ); $this->setView('ltiKeyChain/ltiKeyChainGenerate.tpl'); } /** * @todo Remove or move this method once UX is validated */ private function getSafeKeyChains(): array { $keyChains = $this->getKeyChainRepository()->findAll(new KeyChainQuery())->getKeyChains(); return array_map(function (KeyChain $keyChain) { return [ 'identifier' => $keyChain->getIdentifier(), 'name' => $keyChain->getName(), 'public' => $keyChain->getPublicKey()->getValue(), ]; }, $keyChains); } private function getJwksRepository(): JwksRepositoryInterface { return $this->getServiceLocator()->get(CachedPlatformJwksRepository::class); } private function getKeyChainRepository(): KeyChainRepositoryInterface { return $this->getServiceLocator()->get(CachedPlatformKeyChainRepository::class); } private function getUrlGenerator(): UrlHelper { return $this->getServiceLocator()->get(UrlHelper::class); } }