public function test() { $token = new Token('inao', 'archives', ['group1' => 'right1']); $ednaoCrypt = new EdnaoCryptography(); $tokenManager = new TokenManager($ednaoCrypt); $crypt = $tokenManager->getTokenCrypt($token); $uncryptToken = $tokenManager->getTokenDecrypt($crypt); $this->assertEquals($token->serialize(), $uncryptToken->serialize()); }
public static function iframe($baseUrl, $socle, $version, $product, array $rights, $page) { $token = new Token($socle, $product, $rights); $ednaoCrypt = new EdnaoCryptography(); $ednaoCrypt->setPublicKey(file_get_contents(__DIR__ . '/../../var/auth/public.pem')); $tokenManager = new TokenManager($ednaoCrypt); $encodedToken = $tokenManager->getTokenCrypt($token); $loginUrl = sprintf('/naoned/%s/%s/%s', $encodedToken, urlencode($version), urlencode($page)); return sprintf('<iframe src="" frameborder="1" marginheight="0" marginwidth="0" width="400" height="600" id="ednao" data-login-path="%s" data-base-url="%s" data-context-path="%s" style="%s" > <p>Votre navigateur ne supporte pas l’élément iframe, l’aide ne peut donc pas être affichée</p> </iframe>', $loginUrl, $baseUrl, self::CONTEXT_PATH, self::style()); }