1
0

IToken.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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 OCP\Authentication\Token;
  26. use JsonSerializable;
  27. /**
  28. * @since 28.0.0
  29. */
  30. interface IToken extends JsonSerializable {
  31. /**
  32. * @since 28.0.0
  33. */
  34. public const TEMPORARY_TOKEN = 0;
  35. /**
  36. * @since 28.0.0
  37. */
  38. public const PERMANENT_TOKEN = 1;
  39. /**
  40. * @since 28.0.0
  41. */
  42. public const WIPE_TOKEN = 2;
  43. /**
  44. * @since 28.0.0
  45. */
  46. public const DO_NOT_REMEMBER = 0;
  47. /**
  48. * @since 28.0.0
  49. */
  50. public const REMEMBER = 1;
  51. /**
  52. * Get the token ID
  53. * @since 28.0.0
  54. */
  55. public function getId(): int;
  56. /**
  57. * Get the user UID
  58. * @since 28.0.0
  59. */
  60. public function getUID(): string;
  61. /**
  62. * Get the login name used when generating the token
  63. * @since 28.0.0
  64. */
  65. public function getLoginName(): string;
  66. /**
  67. * Get the (encrypted) login password
  68. * @since 28.0.0
  69. */
  70. public function getPassword(): ?string;
  71. /**
  72. * Get the timestamp of the last password check
  73. * @since 28.0.0
  74. */
  75. public function getLastCheck(): int;
  76. /**
  77. * Set the timestamp of the last password check
  78. * @since 28.0.0
  79. */
  80. public function setLastCheck(int $time): void;
  81. /**
  82. * Get the authentication scope for this token
  83. * @since 28.0.0
  84. */
  85. public function getScope(): string;
  86. /**
  87. * Get the authentication scope for this token
  88. * @since 28.0.0
  89. */
  90. public function getScopeAsArray(): array;
  91. /**
  92. * Set the authentication scope for this token
  93. * @since 28.0.0
  94. */
  95. public function setScope(array $scope): void;
  96. /**
  97. * Get the name of the token
  98. * @since 28.0.0
  99. */
  100. public function getName(): string;
  101. /**
  102. * Get the remember state of the token
  103. * @since 28.0.0
  104. */
  105. public function getRemember(): int;
  106. /**
  107. * Set the token
  108. * @since 28.0.0
  109. */
  110. public function setToken(string $token): void;
  111. /**
  112. * Set the password
  113. * @since 28.0.0
  114. */
  115. public function setPassword(string $password): void;
  116. /**
  117. * Set the expiration time of the token
  118. * @since 28.0.0
  119. */
  120. public function setExpires(?int $expires): void;
  121. }