Skip to content
Snippets Groups Projects
Commit e391cf63 authored by Jaime Perez Crespo's avatar Jaime Perez Crespo
Browse files

Move SimpleSAML_Utilities::generateTimestamp() to...

Move SimpleSAML_Utilities::generateTimestamp() to SimpleSAML\Utils\Time::generateTimestamp(). Deprecate the former.
parent 3cc3abdb
No related branches found
No related tags found
No related merge requests found
...@@ -50,7 +50,7 @@ class SimpleSAML_Bindings_Shib13_Artifact { ...@@ -50,7 +50,7 @@ class SimpleSAML_Bindings_Shib13_Artifact {
'<samlp:Request xmlns:samlp="urn:oasis:names:tc:SAML:1.0:protocol"' . '<samlp:Request xmlns:samlp="urn:oasis:names:tc:SAML:1.0:protocol"' .
' RequestID="' . SimpleSAML_Utils_Random::generateID() . '"' . ' RequestID="' . SimpleSAML_Utils_Random::generateID() . '"' .
' MajorVersion="1" MinorVersion="1"' . ' MajorVersion="1" MinorVersion="1"' .
' IssueInstant="' . SimpleSAML_Utilities::generateTimestamp() . '"' . ' IssueInstant="' . SimpleSAML\Utils\Time::generateTimestamp() . '"' .
'>'; '>';
foreach ($artifacts as $a) { foreach ($artifacts as $a) {
......
...@@ -144,7 +144,7 @@ class SimpleSAML_Metadata_MetaDataStorageHandler { ...@@ -144,7 +144,7 @@ class SimpleSAML_Metadata_MetaDataStorageHandler {
unset($srcList[$key]); unset($srcList[$key]);
SimpleSAML_Logger::warning("Dropping metadata entity " . SimpleSAML_Logger::warning("Dropping metadata entity " .
var_export($key,true) . ", expired " . var_export($key,true) . ", expired " .
SimpleSAML_Utilities::generateTimestamp($le['expire']) . SimpleSAML\Utils\Time::generateTimestamp($le['expire']) .
"."); ".");
} }
} }
......
...@@ -390,16 +390,10 @@ class SimpleSAML_Utilities { ...@@ -390,16 +390,10 @@ class SimpleSAML_Utilities {
/** /**
* This function generates a timestamp on the form used by the SAML protocols. * @deprecated This function will be removed in SSP 2.0. Please use \SimpleSAML\Utils\Time::generateTimestamp() instead.
*
* @param $instant The time the timestamp should represent.
* @return The timestamp.
*/ */
public static function generateTimestamp($instant = NULL) { public static function generateTimestamp($instant = NULL) {
if($instant === NULL) { return SimpleSAML\Utils\Time::generateTimestamp($instant);
$instant = time();
}
return gmdate('Y-m-d\TH:i:s\Z', $instant);
} }
......
<?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
...@@ -306,13 +306,13 @@ class SimpleSAML_XML_Shib13_AuthnResponse { ...@@ -306,13 +306,13 @@ class SimpleSAML_XML_Shib13_AuthnResponse {
$id = SimpleSAML_Utils_Random::generateID(); $id = SimpleSAML_Utils_Random::generateID();
$issueInstant = SimpleSAML_Utilities::generateTimestamp(); $issueInstant = SimpleSAML\Utils\Time::generateTimestamp();
// 30 seconds timeskew back in time to allow differing clocks. // 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(); $assertionid = SimpleSAML_Utils_Random::generateID();
$spEntityId = $sp->getString('entityid'); $spEntityId = $sp->getString('entityid');
......
...@@ -47,9 +47,9 @@ class sspmod_adfs_IdP_ADFS { ...@@ -47,9 +47,9 @@ class sspmod_adfs_IdP_ADFS {
public static function ADFS_GenerateResponse($issuer, $target, $nameid, $attributes) { public static function ADFS_GenerateResponse($issuer, $target, $nameid, $attributes) {
#$nameid = 'hans@surfnet.nl'; #$nameid = 'hans@surfnet.nl';
$issueInstant = SimpleSAML_Utilities::generateTimestamp(); $issueInstant = SimpleSAML\Utils\Time::generateTimestamp();
$notBefore = SimpleSAML_Utilities::generateTimestamp(time() - 30); $notBefore = SimpleSAML\Utils\Time::generateTimestamp(time() - 30);
$assertionExpire = SimpleSAML_Utilities::generateTimestamp(time() + 60 * 5); $assertionExpire = SimpleSAML\Utils\Time::generateTimestamp(time() + 60 * 5);
$assertionID = SimpleSAML_Utils_Random::generateID(); $assertionID = SimpleSAML_Utils_Random::generateID();
$nameidFormat = 'http://schemas.xmlsoap.org/claims/UPN'; $nameidFormat = 'http://schemas.xmlsoap.org/claims/UPN';
$result = $result =
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment