IToken.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\Authentication\Token;
  8. use JsonSerializable;
  9. /**
  10. * @since 28.0.0
  11. */
  12. interface IToken extends JsonSerializable {
  13. /**
  14. * @since 28.0.0
  15. */
  16. public const TEMPORARY_TOKEN = 0;
  17. /**
  18. * @since 28.0.0
  19. */
  20. public const PERMANENT_TOKEN = 1;
  21. /**
  22. * @since 28.0.0
  23. */
  24. public const WIPE_TOKEN = 2;
  25. /**
  26. * @since 28.0.0
  27. */
  28. public const DO_NOT_REMEMBER = 0;
  29. /**
  30. * @since 28.0.0
  31. */
  32. public const REMEMBER = 1;
  33. /**
  34. * @since 30.0.0
  35. */
  36. public const SCOPE_FILESYSTEM = 'filesystem';
  37. /**
  38. * @since 30.0.0
  39. */
  40. public const SCOPE_SKIP_PASSWORD_VALIDATION = 'password-unconfirmable';
  41. /**
  42. * Get the token ID
  43. * @since 28.0.0
  44. */
  45. public function getId(): int;
  46. /**
  47. * Get the user UID
  48. * @since 28.0.0
  49. */
  50. public function getUID(): string;
  51. /**
  52. * Get the login name used when generating the token
  53. * @since 28.0.0
  54. */
  55. public function getLoginName(): string;
  56. /**
  57. * Get the (encrypted) login password
  58. * @since 28.0.0
  59. */
  60. public function getPassword(): ?string;
  61. /**
  62. * Get the timestamp of the last password check
  63. * @since 28.0.0
  64. */
  65. public function getLastCheck(): int;
  66. /**
  67. * Set the timestamp of the last password check
  68. * @since 28.0.0
  69. */
  70. public function setLastCheck(int $time): void;
  71. /**
  72. * Get the authentication scope for this token
  73. * @since 28.0.0
  74. */
  75. public function getScope(): string;
  76. /**
  77. * Get the authentication scope for this token
  78. * @since 28.0.0
  79. */
  80. public function getScopeAsArray(): array;
  81. /**
  82. * Set the authentication scope for this token
  83. * @since 28.0.0
  84. */
  85. public function setScope(array $scope): void;
  86. /**
  87. * Get the name of the token
  88. * @since 28.0.0
  89. */
  90. public function getName(): string;
  91. /**
  92. * Get the remember state of the token
  93. * @since 28.0.0
  94. */
  95. public function getRemember(): int;
  96. /**
  97. * Set the token
  98. * @since 28.0.0
  99. */
  100. public function setToken(string $token): void;
  101. /**
  102. * Set the password
  103. * @since 28.0.0
  104. */
  105. public function setPassword(string $password): void;
  106. /**
  107. * Set the expiration time of the token
  108. * @since 28.0.0
  109. */
  110. public function setExpires(?int $expires): void;
  111. }