diff --git a/lib/SimpleSAML/Bindings/Shib13/Artifact.php b/lib/SimpleSAML/Bindings/Shib13/Artifact.php index 0623bd175b98b24bf5e13517c3bf41cb9d19a5a3..73c7592c770d955b354cabe91ef75c4597a5e4c2 100644 --- a/lib/SimpleSAML/Bindings/Shib13/Artifact.php +++ b/lib/SimpleSAML/Bindings/Shib13/Artifact.php @@ -50,7 +50,7 @@ class SimpleSAML_Bindings_Shib13_Artifact { '<samlp:Request xmlns:samlp="urn:oasis:names:tc:SAML:1.0:protocol"' . ' RequestID="' . SimpleSAML_Utils_Random::generateID() . '"' . ' MajorVersion="1" MinorVersion="1"' . - ' IssueInstant="' . SimpleSAML_Utilities::generateTimestamp() . '"' . + ' IssueInstant="' . SimpleSAML\Utils\Time::generateTimestamp() . '"' . '>'; foreach ($artifacts as $a) { diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php b/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php index 3e086193fe27b7f93e8e347f823da3142e665795..70aba6d1d0c13b6caf062f850a9948ec4b4d9848 100644 --- a/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php +++ b/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php @@ -144,7 +144,7 @@ class SimpleSAML_Metadata_MetaDataStorageHandler { unset($srcList[$key]); SimpleSAML_Logger::warning("Dropping metadata entity " . var_export($key,true) . ", expired " . - SimpleSAML_Utilities::generateTimestamp($le['expire']) . + SimpleSAML\Utils\Time::generateTimestamp($le['expire']) . "."); } } diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php index 94c5fe56c01fe36f0e31d6d029e0a4edc4951913..2b825caef7f46646cf825c4a20b74d1de54584b6 100644 --- a/lib/SimpleSAML/Utilities.php +++ b/lib/SimpleSAML/Utilities.php @@ -390,16 +390,10 @@ class SimpleSAML_Utilities { /** - * This function generates a timestamp on the form used by the SAML protocols. - * - * @param $instant The time the timestamp should represent. - * @return The timestamp. + * @deprecated This function will be removed in SSP 2.0. Please use \SimpleSAML\Utils\Time::generateTimestamp() instead. */ public static function generateTimestamp($instant = NULL) { - if($instant === NULL) { - $instant = time(); - } - return gmdate('Y-m-d\TH:i:s\Z', $instant); + return SimpleSAML\Utils\Time::generateTimestamp($instant); } diff --git a/lib/SimpleSAML/Utils/Time.php b/lib/SimpleSAML/Utils/Time.php new file mode 100644 index 0000000000000000000000000000000000000000..50d8f5b67839e81ea9b3eac1d3bc32ed1110df7c --- /dev/null +++ b/lib/SimpleSAML/Utils/Time.php @@ -0,0 +1,29 @@ +<?php +/** + * Time-related utility methods. + * + * @package SimpleSAMLphp + */ + +namespace SimpleSAML\Utils; + + +class Time +{ + + /** + * This function generates a timestamp on the form used by the SAML protocols. + * + * @param int $instant The time the timestamp should represent. Defaults to current time. + * + * @return string The timestamp. + * @author Olav Morken, UNINETT AS <olav.morken@uninett.no> + */ + public static function generateTimestamp($instant = null) + { + if ($instant === null) { + $instant = time(); + } + return gmdate('Y-m-d\TH:i:s\Z', $instant); + } +} \ No newline at end of file diff --git a/lib/SimpleSAML/XML/Shib13/AuthnResponse.php b/lib/SimpleSAML/XML/Shib13/AuthnResponse.php index 563882e9409c9d70d01bd906da369799eb3cf9b1..a70dcb16ac19af2338ad35a21abc74b9451ac3fb 100644 --- a/lib/SimpleSAML/XML/Shib13/AuthnResponse.php +++ b/lib/SimpleSAML/XML/Shib13/AuthnResponse.php @@ -306,13 +306,13 @@ class SimpleSAML_XML_Shib13_AuthnResponse { $id = SimpleSAML_Utils_Random::generateID(); - $issueInstant = SimpleSAML_Utilities::generateTimestamp(); + $issueInstant = SimpleSAML\Utils\Time::generateTimestamp(); // 30 seconds timeskew back in time to allow differing clocks. - $notBefore = SimpleSAML_Utilities::generateTimestamp(time() - 30); + $notBefore = SimpleSAML\Utils\Time::generateTimestamp(time() - 30); - $assertionExpire = SimpleSAML_Utilities::generateTimestamp(time() + 60 * 5);# 5 minutes + $assertionExpire = SimpleSAML\Utils\Time::generateTimestamp(time() + 60 * 5);# 5 minutes $assertionid = SimpleSAML_Utils_Random::generateID(); $spEntityId = $sp->getString('entityid'); diff --git a/modules/adfs/lib/IdP/ADFS.php b/modules/adfs/lib/IdP/ADFS.php index cdb23f95767f900fcaa1df6bf1648edcd9389236..341f91e2970f0f69a5c9374cb57d4037f998b0d2 100644 --- a/modules/adfs/lib/IdP/ADFS.php +++ b/modules/adfs/lib/IdP/ADFS.php @@ -47,9 +47,9 @@ class sspmod_adfs_IdP_ADFS { public static function ADFS_GenerateResponse($issuer, $target, $nameid, $attributes) { #$nameid = 'hans@surfnet.nl'; - $issueInstant = SimpleSAML_Utilities::generateTimestamp(); - $notBefore = SimpleSAML_Utilities::generateTimestamp(time() - 30); - $assertionExpire = SimpleSAML_Utilities::generateTimestamp(time() + 60 * 5); + $issueInstant = SimpleSAML\Utils\Time::generateTimestamp(); + $notBefore = SimpleSAML\Utils\Time::generateTimestamp(time() - 30); + $assertionExpire = SimpleSAML\Utils\Time::generateTimestamp(time() + 60 * 5); $assertionID = SimpleSAML_Utils_Random::generateID(); $nameidFormat = 'http://schemas.xmlsoap.org/claims/UPN'; $result =