ILIAS
trunk Revision v12.0_alpha-377-g3641b37b9db
◀ ilDoc Overview
KeyRotationObjective.php
Go to the documentation of this file.
1
<?php
2
19
declare(strict_types=1);
20
21
namespace
ILIAS\FileDelivery\Setup
;
22
23
use
ILIAS\Setup\Artifact
;
24
use
ILIAS\Setup\Artifact\ArrayArtifact
;
25
29
class
KeyRotationObjective
extends
BuildStaticConfigStoredObjective
30
{
31
private
const
int
KEY_LENGTH
= 32;
32
private
const
int
NUMBER_OF_KEYS
= 5;
33
34
public
function
getArtifactName
(): string
35
{
36
return
"key_rotation"
;
37
}
38
39
public
function
build
():
Artifact
40
{
41
$current_keys = [];
42
if
(is_readable(self::PATH())) {
44
$current_keys = require
self::PATH
();
45
}
46
47
$new_keys = [];
48
// push one new key to the beginning, drop the oldest key until we have 5 keys
49
for
($i = 0; $i < self::NUMBER_OF_KEYS - 1; $i++) {
50
if
($i === 0) {
51
$new_keys[] = $this->
generateRandomString
(self::KEY_LENGTH);
52
}
53
$new_keys[] = $current_keys[$i] ?? $this->
generateRandomString
(self::KEY_LENGTH);
54
}
55
56
return
new
ArrayArtifact($new_keys);
57
}
58
59
private
function
generateRandomString
(
int
$length): string
60
{
61
$return =
''
;
62
for
($i = 0; $i < $length; $i++) {
63
$return .= chr(random_int(33, 125));
64
}
65
return
$return;
66
}
67
}
ILIAS\FileDelivery\Setup\BuildStaticConfigStoredObjective
Definition:
BuildStaticConfigStoredObjective.php:31
ILIAS\FileDelivery\Setup\BuildStaticConfigStoredObjective\PATH
static PATH()
Definition:
BuildStaticConfigStoredObjective.php:37
ILIAS\FileDelivery\Setup\BuildStaticConfigStoredObjective\build
build()
ILIAS\FileDelivery\Setup\KeyRotationObjective
Definition:
KeyRotationObjective.php:30
ILIAS\FileDelivery\Setup\KeyRotationObjective\KEY_LENGTH
const int KEY_LENGTH
Definition:
KeyRotationObjective.php:31
ILIAS\FileDelivery\Setup\KeyRotationObjective\generateRandomString
generateRandomString(int $length)
Definition:
KeyRotationObjective.php:59
ILIAS\FileDelivery\Setup\KeyRotationObjective\NUMBER_OF_KEYS
const int NUMBER_OF_KEYS
Definition:
KeyRotationObjective.php:32
ILIAS\FileDelivery\Setup\KeyRotationObjective\getArtifactName
getArtifactName()
Definition:
KeyRotationObjective.php:34
ILIAS\Setup\Artifact\ArrayArtifact
An array as an artifact.
Definition:
ArrayArtifact.php:29
ILIAS\Setup\Artifact
An artifact is some file that is build on demand per installation and is not shipped with the ILIAS s...
Definition:
Artifact.php:28
ILIAS\FileDelivery\Setup
Definition:
Agent.php:21
ILIAS\Setup\Artifact
Definition:
ArrayArtifact.php:21
components
ILIAS
FileDelivery
src
Setup
KeyRotationObjective.php
Generated on Sat Dec 13 2025 23:02:20 for ILIAS by
1.9.4 (using
Doxyfile
)