/** * @param JwtContext $context * @throws \BWC\Component\JwtApiBundle\Error\JwtException */ public function handleContext(JwtContext $context) { $token = $context->getRequestJwtToken(); if ($this->logger) { $this->logger->debug('DecoderHandler.token', array('token' => $token)); } /** @var MethodJwt $jwt */ $jwt = $this->encoder->decode($token, $this->class); if ($this->logger) { $this->logger->debug('DecoderHandler.jwt', array('jwt' => $jwt)); } if (false == $jwt instanceof MethodJwt) { throw new JwtException(sprintf("Expected MethodJwt but got '%s'", get_class($jwt))); } $context->setRequestJwt($jwt); }
/** * @test */ public function shouldGetRequestJwtToken() { $context = new JwtContext(new Request(), JwtBindingTypes::HTTP_REDIRECT, $expectedToken = 'token'); $this->assertEquals($expectedToken, $context->getRequestJwtToken()); }