public function testSigner_validateTampered_shouldBeFalse() { $foo = 'hillo.7KTthSs1fJgtbigPvFpQH1bpoGA'; $s = new Signer("secret"); $bar = $s->validate($foo); $this->assertFalse($bar); }
public function unsign($value, $max_age = null, $return_timestamp = false) { try { $result = parent::unsign($value); $sig_err = null; } catch (BadSignature $ex) { $sig_err = $ex; $result = $ex->payload; } if (strpos($result, $this->sep) === false) { if (!is_null($sig_err)) { throw $sig_err; } throw new BadTimeSignature("timestamp missing", $result); } list($timestamp, $value) = $this->pop_signature($result); $timestamp = $this->bytes_to_int($this->base64_decode_($timestamp)); # Signature is *not* okay. Raise a proper error now that we have # split the value and the timestamp. if (!is_null($sig_err)) { throw new BadTimeSignature((string) $sig_err, $value, $timestamp); } if (!is_null($max_age)) { $age = $this->get_timestamp() - $timestamp; if ($age > $max_age) { throw new SignatureExpired("Signature age {$age} > {$max_age} seconds", $value, $this->timestamp_to_datetime($timestamp)); } } if ($return_timestamp) { return array($value, $this->timestamp_to_datetime($timestamp)); } return $value; }