IToken.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2016, ownCloud, Inc.
  5. *
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Robin Appelman <robin@icewind.nl>
  8. * @author Roeland Jago Douma <roeland@famdouma.nl>
  9. *
  10. * @license AGPL-3.0
  11. *
  12. * This code is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License, version 3,
  14. * as published by the Free Software Foundation.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License, version 3,
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>
  23. *
  24. */
  25. namespace OC\Authentication\Token;
  26. use JsonSerializable;
  27. interface IToken extends JsonSerializable {
  28. public const TEMPORARY_TOKEN = 0;
  29. public const PERMANENT_TOKEN = 1;
  30. public const WIPE_TOKEN = 2;
  31. public const DO_NOT_REMEMBER = 0;
  32. public const REMEMBER = 1;
  33. /**
  34. * Get the token ID
  35. *
  36. * @return int
  37. */
  38. public function getId(): int;
  39. /**
  40. * Get the user UID
  41. *
  42. * @return string
  43. */
  44. public function getUID(): string;
  45. /**
  46. * Get the login name used when generating the token
  47. *
  48. * @return string
  49. */
  50. public function getLoginName(): string;
  51. /**
  52. * Get the (encrypted) login password
  53. *
  54. * @return string|null
  55. */
  56. public function getPassword();
  57. /**
  58. * Get the timestamp of the last password check
  59. *
  60. * @return int
  61. */
  62. public function getLastCheck(): int;
  63. /**
  64. * Set the timestamp of the last password check
  65. *
  66. * @param int $time
  67. */
  68. public function setLastCheck(int $time);
  69. /**
  70. * Get the authentication scope for this token
  71. *
  72. * @return string
  73. */
  74. public function getScope(): string;
  75. /**
  76. * Get the authentication scope for this token
  77. *
  78. * @return array
  79. */
  80. public function getScopeAsArray(): array;
  81. /**
  82. * Set the authentication scope for this token
  83. *
  84. * @param array $scope
  85. */
  86. public function setScope($scope);
  87. /**
  88. * Get the name of the token
  89. * @return string
  90. */
  91. public function getName(): string;
  92. /**
  93. * Get the remember state of the token
  94. *
  95. * @return int
  96. */
  97. public function getRemember(): int;
  98. /**
  99. * Set the token
  100. *
  101. * @param string $token
  102. */
  103. public function setToken(string $token);
  104. /**
  105. * Set the password
  106. *
  107. * @param string $password
  108. */
  109. public function setPassword(string $password);
  110. /**
  111. * Set the expiration time of the token
  112. *
  113. * @param int|null $expires
  114. */
  115. public function setExpires($expires);
  116. }