Merge branch '4.x' into 5.x

This commit is contained in:
Ben Ramsey
2025-05-31 18:52:25 -05:00
91 changed files with 831 additions and 1316 deletions
+11 -19
View File
@@ -31,8 +31,8 @@ use function substr_replace;
use const STR_PAD_LEFT;
/**
* DceSecurityGenerator generates strings of binary data based on a local
* domain, local identifier, node ID, clock sequence, and the current time
* DceSecurityGenerator generates strings of binary data based on a local domain, local identifier, node ID, clock
* sequence, and the current time
*/
class DceSecurityGenerator implements DceSecurityGeneratorInterface
{
@@ -55,7 +55,7 @@ class DceSecurityGenerator implements DceSecurityGeneratorInterface
public function __construct(
private readonly NumberConverterInterface $numberConverter,
private readonly TimeGeneratorInterface $timeGenerator,
private readonly DceSecurityProviderInterface $dceSecurityProvider
private readonly DceSecurityProviderInterface $dceSecurityProvider,
) {
}
@@ -63,32 +63,26 @@ class DceSecurityGenerator implements DceSecurityGeneratorInterface
int $localDomain,
?IntegerObject $localIdentifier = null,
Hexadecimal | int | string | null $node = null,
?int $clockSeq = null
?int $clockSeq = null,
): string {
if (!in_array($localDomain, self::DOMAINS)) {
throw new DceSecurityException(
'Local domain must be a valid DCE Security domain'
);
throw new DceSecurityException('Local domain must be a valid DCE Security domain');
}
if ($localIdentifier && $localIdentifier->isNegative()) {
throw new DceSecurityException(
'Local identifier out of bounds; it must be a value between 0 and 4294967295'
'Local identifier out of bounds; it must be a value between 0 and 4294967295',
);
}
if ($clockSeq > self::CLOCK_SEQ_HIGH || $clockSeq < self::CLOCK_SEQ_LOW) {
throw new DceSecurityException(
'Clock sequence out of bounds; it must be a value between 0 and 63'
);
throw new DceSecurityException('Clock sequence out of bounds; it must be a value between 0 and 63');
}
switch ($localDomain) {
case Uuid::DCE_DOMAIN_ORG:
if ($localIdentifier === null) {
throw new DceSecurityException(
'A local identifier must be provided for the org domain'
);
throw new DceSecurityException('A local identifier must be provided for the org domain');
}
break;
@@ -109,13 +103,11 @@ class DceSecurityGenerator implements DceSecurityGeneratorInterface
$identifierHex = $this->numberConverter->toHex($localIdentifier->toString());
// The maximum value for the local identifier is 0xffffffff, or
// 4294967295. This is 8 hexadecimal digits, so if the length of
// hexadecimal digits is greater than 8, we know the value is greater
// than 0xffffffff.
// The maximum value for the local identifier is 0xffffffff, or 4,294,967,295. This is 8 hexadecimal digits, so
// if the length of hexadecimal digits is greater than 8, we know the value is greater than 0xffffffff.
if (strlen($identifierHex) > 8) {
throw new DceSecurityException(
'Local identifier out of bounds; it must be a value between 0 and 4294967295'
'Local identifier out of bounds; it must be a value between 0 and 4294967295',
);
}