ILIAS
trunk Revision v12.0_alpha-1540-g00f839d5fa1
◀ ilDoc Overview
KeyRotationObjective.php
Go to the documentation of this file.
1
<?php
2
19
declare(strict_types=1);
20
21
namespace
ILIAS\WebDAV\Setup
;
22
23
use
ILIAS\Setup\Artifact
;
24
use
ILIAS\Setup\Artifact\ArrayArtifact
;
25
use
ILIAS\FileDelivery\Setup\BuildStaticConfigStoredObjective
;
26
30
class
KeyRotationObjective
extends
BuildStaticConfigStoredObjective
31
{
32
private
const
int
KEY_LENGTH
= 32;
33
private
const
int
NUMBER_OF_KEYS
= 5;
34
35
public
function
getArtifactName
(): string
36
{
37
return
"webdav_key_rotation"
;
38
}
39
40
public
function
build
():
Artifact
41
{
42
$current_keys = [];
43
if
(is_readable(self::PATH())) {
45
$current_keys = require
self::PATH
();
46
}
47
48
$new_keys = [];
49
// push one new key to the beginning, drop the oldest key until we have 5 keys
50
for
($i = 0; $i < self::NUMBER_OF_KEYS - 1; $i++) {
51
if
($i === 0) {
52
$new_keys[] = $this->
generateRandomString
(self::KEY_LENGTH);
53
}
54
$new_keys[] = $current_keys[$i] ?? $this->
generateRandomString
(self::KEY_LENGTH);
55
}
56
57
return
new
ArrayArtifact($new_keys);
58
}
59
60
private
function
generateRandomString
(
int
$length): string
61
{
62
$return =
''
;
63
for
($i = 0; $i < $length; $i++) {
64
$return .= chr(random_int(33, 125));
65
}
66
return
$return;
67
}
68
}
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\Setup\Artifact\ArrayArtifact
An array as an artifact.
Definition:
ArrayArtifact.php:29
ILIAS\WebDAV\Setup\KeyRotationObjective
Definition:
KeyRotationObjective.php:31
ILIAS\WebDAV\Setup\KeyRotationObjective\generateRandomString
generateRandomString(int $length)
Definition:
KeyRotationObjective.php:60
ILIAS\WebDAV\Setup\KeyRotationObjective\NUMBER_OF_KEYS
const int NUMBER_OF_KEYS
Definition:
KeyRotationObjective.php:33
ILIAS\WebDAV\Setup\KeyRotationObjective\KEY_LENGTH
const int KEY_LENGTH
Definition:
KeyRotationObjective.php:32
ILIAS\WebDAV\Setup\KeyRotationObjective\getArtifactName
getArtifactName()
Definition:
KeyRotationObjective.php:35
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\Setup\Artifact
Definition:
ArrayArtifact.php:21
ILIAS\WebDAV\Setup
Definition:
Agent.php:21
components
ILIAS
WebDAV
src
Setup
KeyRotationObjective.php
Generated on Wed Jun 3 2026 23:04:49 for ILIAS by
1.9.4 (using
Doxyfile
)