Signer.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * This file is part of Lcobucci\JWT, a simple library to handle JWT and JWS
  4. *
  5. * @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
  6. */
  7. namespace Lcobucci\JWT;
  8. use InvalidArgumentException;
  9. use Lcobucci\JWT\Signer\Key;
  10. /**
  11. * Basic interface for token signers
  12. *
  13. * @author Luís Otávio Cobucci Oblonczyk <lcobucci@gmail.com>
  14. * @since 0.1.0
  15. */
  16. interface Signer
  17. {
  18. /**
  19. * Returns the algorithm id
  20. *
  21. * @return string
  22. */
  23. public function getAlgorithmId();
  24. /**
  25. * Apply changes on headers according with algorithm
  26. *
  27. * @param array $headers
  28. */
  29. public function modifyHeader(array &$headers);
  30. /**
  31. * Returns a signature for given data
  32. *
  33. * @param string $payload
  34. * @param Key|string $key
  35. *
  36. * @return Signature
  37. *
  38. * @throws InvalidArgumentException When given key is invalid
  39. */
  40. public function sign($payload, $key);
  41. /**
  42. * Returns if the expected hash matches with the data and key
  43. *
  44. * @param string $expected
  45. * @param string $payload
  46. * @param Key|string $key
  47. *
  48. * @return boolean
  49. *
  50. * @throws InvalidArgumentException When given key is invalid
  51. */
  52. public function verify($expected, $payload, $key);
  53. }