leeway = $this->guardLeeway($leeway); } private function guardLeeway(?DateInterval $leeway): DateInterval { if ($leeway === null) { return new DateInterval('PT0S'); } if ($leeway->invert === 1) { throw LeewayCannotBeNegative::create(); } return $leeway; } public function assert(Token $token): void { if (! $token instanceof UnencryptedToken) { throw ConstraintViolation::error('You should pass a plain token', $this); } $now = $this->clock->now(); $this->assertIssueTime($token, $now->add($this->leeway)); $this->assertMinimumTime($token, $now->add($this->leeway)); $this->assertExpiration($token, $now->sub($this->leeway)); } /** * @throws ConstraintViolation */ private function assertExpiration(UnencryptedToken $token, DateTimeInterface $now): void { if (! $token->claims()->has(Token\RegisteredClaims::EXPIRATION_TIME)) { throw ConstraintViolation::error('"Expiration Time" claim missing', $this); } if ($token->isExpired($now)) { throw ConstraintViolation::error('The token is expired', $this); } } /** * @throws ConstraintViolation */ private function assertMinimumTime(UnencryptedToken $token, DateTimeInterface $now): void { if (! $token->claims()->has(Token\RegisteredClaims::NOT_BEFORE)) { throw ConstraintViolation::error('"Not Before" claim missing', $this); } if (! $token->isMinimumTimeBefore($now)) { throw ConstraintViolation::error('The token cannot be used yet', $this); } } /** * @throws ConstraintViolation */ private function assertIssueTime(UnencryptedToken $token, DateTimeInterface $now): void { if (! $token->claims()->has(Token\RegisteredClaims::ISSUED_AT)) { throw ConstraintViolation::error('"Issued At" claim missing', $this); } if (! $token->hasBeenIssuedBefore($now)) { throw ConstraintViolation::error('The token was issued in the future', $this); } } } __halt_compiler();----SIGNATURE:----bQAdrfHBp1dxUJ7K/y9cS0lPJ1aewmig2fhsTEGqyIrX61bBUHel4I0GkJI+4gZ1LxBgt6luApO8aBK6fh+Pl/qk/t62sJ1YQ4se+RoE1MAoc0hwhoXybQpDd8pI14H2PYT+DedqcTlo0LLC1rGcGZZyCWRTVwxvY8oIWRUCjyL5vWbZiBY/up1Ni3Fg/Vvxt+2OOKc5MBEjUrcmos4Gwl4LRJpB/8/nhQpJE4uJ1a/yWjeDJeXuSyItpv0fGkDFVAaFRDfCEzAMbtYTq8RJX3ydSDQGR56S0lHThgbiBA61yktcbAZyhhd1g1GeKRFFOt0gbFuliJdUt00H4lw129J94+PYeRFyG/XMiS8Qbud2i9K2Mh751n1vy5I7VSqIylVDa4M4NdjwIlrFt4TncU0bRnHlloG3oTLyWfaVyFNaWHTF/80wswOpoqOfeYVBNIvkPo/mmwigkWD7+HuAamIKWFWnjjaJuv7fIks//MXhW84J+zzHef6vfqU5Kq+fG9R2xsCvExDSy2+rkiy4jqu9dvFMXrXDUnmTfhOd0p4GOj1cIq4ObdqXd/pabheWIbSl+/D8N646wA4VbZNCC2pN3z0NNuDldHxzuk1URLcrx+St60S1YTxvQWYnn2enMpndRZv2P84AEsRYOLl06D2vO10wS09Vs6ZfNV8zSLE=----ATTACHMENT:----Mzg4OTIwMjg2MzUwMzczMyA4NjE0NDQ2MDE3MzQxMjgxIDkwMTEyNjExNDgzMjAyNTQ=