IToken.php 2.6 KB

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