/** * @param Notification $notification * @throws InvalidNotificationException * @return void */ public function validate(Notification $notification) { $certificateList = $this->client->certificateGet($notification->getIssuer()); if (0 == count($certificateList->getCertificates())) { throw new InvalidNotificationException(sprintf("Issuer '%s' has no Appsco certificates", $notification->getIssuer())); } $error = null; foreach ($certificateList->getCertificates() as $certificate) { try { $this->jwtEncoder->verify($notification, $certificate->getCertificate()); $error = null; break; } catch (\Exception $ex) { $error = $ex; } } if ($error) { throw new InvalidNotificationException(sprintf("Unable to verify certificate of issuer '%s'", $notification->getIssuer()), 0, $error); } }
/** * @param string $kind * @param string $orderId * @param int $appId * @param int $packageId * @param int $ownerId * @return \Appsco\Market\Api\Model\Notification */ public static function create($kind, $orderId, $appId, $packageId, $ownerId) { $result = new Notification(); $result->setAppId($appId)->setKind($kind)->setOrderId($orderId)->setPackageId($packageId)->setOwnerId($ownerId); return $result; }
/** * @param Notification $notification * @throws InvalidNotificationException * @return void */ public function validate(Notification $notification) { if (abs($notification->getIssuedAt() - time()) > $this->maxDifference) { throw new InvalidNotificationException("Notification expired"); } }
/** * @param Notification $notification * @return string */ public function notificationChallengeReply(Notification $notification) { $result = new Notification(); $result->setChallenge($notification->getChallenge()); $this->timestampJwt($result); $token = $this->getJwtToken($result); return $token; }
/** * @param Notification $notification * @throws InvalidNotificationException * @return void */ public function validate(Notification $notification) { if (false == array_key_exists($notification->getIssuer(), $this->validIssuers)) { throw new InvalidNotificationException(sprintf("Invalid issuer '%s'", $notification->getIssuer())); } }