ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
PlatformNonce.php
Go to the documentation of this file.
1 <?php
2 
19 namespace ILIAS\LTI\ToolProvider;
20 
29 {
33  public const MAX_NONCE_AGE = 30; // in minutes
34 
42  public static int $maximumLength = 50;
43 
49  public ?int $expires = null;
50 
56  private ?Platform $platform = null;
57 
63  private ?string $value = null;
64 
70  public function __construct(Platform $platform, string $value = null)
71  {
72  $this->platform = $platform;
73  $this->value = substr($value, -self::$maximumLength);
74  $this->expires = time() + (self::MAX_NONCE_AGE * 60);
75  }
76 
82  public function load(): bool
83  {
84  return $this->platform->getDataConnector()->loadPlatformNonce($this);
85  }
86 
92  public function save(): bool
93  {
94  return $this->platform->getDataConnector()->savePlatformNonce($this);
95  }
96 
102  public function delete(): bool
103  {
104  return $this->platform->getDataConnector()->deletePlatformNonce($this);
105  }
106 
112  public function getPlatform(): ?Platform
113  {
114  return $this->platform;
115  }
116 
122  public function getValue(): ?string
123  {
124  return $this->value;
125  }
126 }
Class to represent a platform.
Definition: Platform.php:35
__construct(Platform $platform, string $value=null)
Class constructor.
int $expires
Timestamp for when the nonce value expires.
static int $maximumLength
Maximum length which can be stored.
Class to represent a platform nonce.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: AccessToken.php:19
Platform $platform
Platform to which this nonce applies.
const MAX_NONCE_AGE
Maximum age nonce values will be retained for (in minutes).
save()
Save a nonce value in the database.
load()
Load a nonce value from the database.