diff --git a/src/Cas/Factories/TicketFactory.php b/src/Cas/Factories/TicketFactory.php index f40cbeb..fe99aec 100644 --- a/src/Cas/Factories/TicketFactory.php +++ b/src/Cas/Factories/TicketFactory.php @@ -26,7 +26,7 @@ namespace SimpleSAML\Module\casserver\Cas\Factories; use SimpleSAML\Configuration; -use SimpleSAML\XML\Utils\Random; +use SimpleSAML\XMLSchema\Type\IDValue; class TicketFactory { @@ -58,11 +58,10 @@ public function __construct(Configuration $config) */ public function createSessionTicket(string $sessionId, int $expiresAt): array { - $randomUtils = new Random(); return [ 'id' => $sessionId, 'validBefore' => $expiresAt, - 'renewId' => $randomUtils->generateID(), + 'renewId' => IDValue::generateID()->getValue(), ]; } @@ -73,8 +72,7 @@ public function createSessionTicket(string $sessionId, int $expiresAt): array */ public function createServiceTicket(array $content): array { - $randomUtils = new Random(); - $id = str_replace('_', 'ST-', $randomUtils->generateID()); + $id = IDValue::generateID('ST-')->getValue(); $expiresAt = time() + $this->serviceTicketExpireTime; return array_merge(['id' => $id, 'validBefore' => $expiresAt], $content); @@ -87,9 +85,8 @@ public function createServiceTicket(array $content): array */ public function createProxyGrantingTicket(array $content): array { - $randomUtils = new Random(); - $id = str_replace('_', 'PGT-', $randomUtils->generateID()); - $iou = str_replace('_', 'PGTIOU-', $randomUtils->generateID()); + $id = IDValue::generateID('PGT-')->getValue(); + $iou = IDValue::generateID('PGTIOU-')->getValue(); $expireAt = time() + $this->proxyGrantingTicketExpireTime; @@ -103,8 +100,7 @@ public function createProxyGrantingTicket(array $content): array */ public function createProxyTicket(array $content): array { - $randomUtils = new Random(); - $id = str_replace('_', 'PT-', $randomUtils->generateID()); + $id = IDValue::generateID('PT-')->getValue(); $expiresAt = time() + $this->proxyTicketExpireTime; return array_merge(['id' => $id, 'validBefore' => $expiresAt], $content); diff --git a/src/Shib13/AuthnResponse.php b/src/Shib13/AuthnResponse.php index afa17a3..a90d5b2 100644 --- a/src/Shib13/AuthnResponse.php +++ b/src/Shib13/AuthnResponse.php @@ -17,8 +17,8 @@ use SimpleSAML\Utils; use SimpleSAML\XML\DOMDocumentFactory; use SimpleSAML\XML\Utils as XMLUtils; -use SimpleSAML\XML\Utils\Random; use SimpleSAML\XML\Validator; +use SimpleSAML\XMLSchema\Type\IDValue; use SimpleXMLElement; /** @@ -362,17 +362,16 @@ public function generate(Configuration $idp, Configuration $sp, string $shire, ? $scopedAttributes = []; } - $randomUtils = new Random(); $timeUtils = new Utils\Time(); - $id = $randomUtils->generateID(); + $id = IDValue::generateID()->getValue(); $issueInstant = $timeUtils->generateTimestamp(); // 30 seconds timeskew back in time to allow differing clocks $notBefore = $timeUtils->generateTimestamp(time() - 30); $assertionExpire = $timeUtils->generateTimestamp(time() + 300); // 5 minutes - $assertionid = $randomUtils->generateID(); + $assertionid = IDValue::generateID()->getValue(); $spEntityId = $sp->getString('entityid'); @@ -380,7 +379,7 @@ public function generate(Configuration $idp, Configuration $sp, string $shire, ? $base64 = $sp->getOptionalBoolean('base64attributes', false); $namequalifier = $sp->getOptionalString('NameQualifier', $spEntityId); - $nameid = $randomUtils->generateID(); + $nameid = (string)IDValue::generateID(); $subjectNode = '' . 'generateID(); + $id = IDValue::generateID()->getValue(); $serviceTicket = [ 'id' => $id, 'validBefore' => time() + $expiration,