/**
  * @param StringLiteral $contentType
  * @return DeserializerInterface
  */
 public function getDeserializerForContentType(StringLiteral $contentType)
 {
     if (array_key_exists($contentType->toNative(), $this->deserializers)) {
         return $this->deserializers[$contentType->toNative()];
     }
     throw new DeserializerNotFoundException("Unable to find a deserializer for content type '{$contentType->toNative()}'");
 }
 private function setEventId(StringLiteral $eventId)
 {
     if ($eventId->isEmpty()) {
         throw new \InvalidArgumentException('event id can not be empty');
     }
     $this->eventId = $eventId;
 }
 /**
  * @param StringLiteral $actorId
  */
 private function setActorId(StringLiteral $actorId)
 {
     if ($actorId->isEmpty()) {
         throw new \InvalidArgumentException('actor id can not be empty');
     }
     $this->actorId = $actorId;
 }
Exemplo n.º 4
0
 /**
  * @param StringLiteral $tokenString
  * @return Jwt
  */
 public function parse(StringLiteral $tokenString)
 {
     try {
         return $this->parser->parse($tokenString->toNative());
     } catch (\InvalidArgumentException $e) {
         throw new JwtParserException($e);
     }
 }
 /**
  * @test
  */
 public function it_returns_a_redirect_response_to_the_destination_with_a_jwt_as_url_fragment()
 {
     $userId = new StringLiteral('id-1');
     $accessToken = new AccessToken($userId->toNative(), new TokenCredentials('token', 'secret'));
     $destination = new Uri('http://bar.com/sub/directory?query=value');
     $userClaims = new UserClaims($userId, new StringLiteral('foo'), new EmailAddress('*****@*****.**'));
     $jwt = new Jwt(['alg' => 'mocked'], $userClaims->toArray(), new Signature('gibberish'), ['headers', 'body', 'gibberish']);
     $expectedDestination = 'http://bar.com/sub/directory?query=value&jwt=headers.body.gibberish';
     $this->userService->expects($this->once())->method('getUserClaims')->with($accessToken)->willReturn($userClaims);
     $this->encoder->expects($this->once())->method('encode')->with($userClaims->toArray())->willReturn($jwt);
     $response = $this->callbackHandler->handle($accessToken, $destination);
     /* @var RedirectResponse $response */
     $this->assertInstanceOf(RedirectResponse::class, $response);
     $this->assertEquals($expectedDestination, $response->getTargetUrl());
 }
 /**
  * @param AccessToken $userAccessToken
  * @return \CultureFeed
  */
 public function createForUser(AccessToken $userAccessToken)
 {
     $client = $this->createOAuthClient($userAccessToken);
     $client->setEndpoint($this->baseUrl->toNative());
     return new \CultureFeed($client);
 }