Skip to content

Commit 5a4d237

Browse files
committed
Add issueInstant property to requests
1 parent b74fdfb commit 5a4d237

File tree

4 files changed

+68
-0
lines changed

4 files changed

+68
-0
lines changed

lib/Saml2/AuthnRequest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ class OneLogin_Saml2_AuthnRequest
2525
*/
2626
private $_id;
2727

28+
/**
29+
* SAML AuthNRequest IssueInstant.
30+
* @var string
31+
*/
32+
private $_issueInstant;
33+
2834
/**
2935
* Constructs the AuthnRequest object.
3036
*
@@ -146,6 +152,7 @@ public function __construct(OneLogin_Saml2_Settings $settings, $forceAuthn = fal
146152

147153
$this->_id = $id;
148154
$this->_authnRequest = $request;
155+
$this->_issueInstant = $issueInstant;
149156
}
150157

151158
/**
@@ -181,6 +188,16 @@ public function getId()
181188
return $this->_id;
182189
}
183190

191+
/**
192+
* Returns the AuthNRequest IssueInstant.
193+
*
194+
* @return string
195+
*/
196+
public function getIssueInstant()
197+
{
198+
return $this->_issueInstant;
199+
}
200+
184201
/**
185202
* Returns the XML that will be sent as part of the request
186203
*

lib/Saml2/LogoutRequest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ class OneLogin_Saml2_LogoutRequest
3030
*/
3131
private $_error;
3232

33+
/**
34+
* SAML LogoutRequest IssueInstant.
35+
* @var string
36+
*/
37+
private $_issueInstant;
38+
3339
/**
3440
* Constructs the Logout Request object.
3541
*
@@ -61,6 +67,7 @@ public function __construct(OneLogin_Saml2_Settings $settings, $request = null,
6167
$this->id = $id;
6268

6369
$issueInstant = OneLogin_Saml2_Utils::parseTime2SAML(time());
70+
$this->_issueInstant = $issueInstant;
6471

6572
$cert = null;
6673
if (isset($security['nameIdEncrypted']) && $security['nameIdEncrypted']) {
@@ -423,6 +430,16 @@ public function getError()
423430
return $this->_error;
424431
}
425432

433+
/**
434+
* Returns the LogoutRequest IssueInstant.
435+
*
436+
* @return string
437+
*/
438+
public function getIssueInstant()
439+
{
440+
return $this->_issueInstant;
441+
}
442+
426443
/**
427444
* Returns the XML that will be sent as part of the request
428445
* or that was received at the SP

tests/src/OneLogin/Saml2/AuthnRequestTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,4 +353,21 @@ public function testGetXML()
353353
$xml = $authnRequest->getXML();
354354
$this->assertRegExp('#^<samlp:AuthnRequest#', $xml);
355355
}
356+
357+
/**
358+
* Tests that we can get the IssueInstant attribute
359+
*
360+
* @covers OneLogin_Saml2_AuthnRequest::getIssueInstant()
361+
*/
362+
public function testGetIssueInstant()
363+
{
364+
$settingsDir = TEST_ROOT .'/settings/';
365+
include $settingsDir.'settings1.php';
366+
367+
$settings = new OneLogin_Saml2_Settings($settingsInfo);
368+
$authnRequest = new OneLogin_Saml2_AuthnRequest($settings);
369+
370+
$issueInstant = $authnRequest->getIssueInstant();
371+
$this->assertNotNull($issueInstant);
372+
}
356373
}

tests/src/OneLogin/Saml2/LogoutRequestTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,4 +893,21 @@ public function testGetIDException()
893893
$xml = $logoutRequest->getXML();
894894
$id1 = OneLogin_Saml2_LogoutRequest::getID($xml.'<garbage>');
895895
}
896+
897+
/**
898+
* Tests that we can get the IssueInstant attribute
899+
*
900+
* @covers OneLogin_Saml2_LogoutRequest::getIssueInstant()
901+
*/
902+
public function testGetIssueInstant()
903+
{
904+
$settingsDir = TEST_ROOT .'/settings/';
905+
include $settingsDir.'settings1.php';
906+
907+
$settings = new OneLogin_Saml2_Settings($settingsInfo);
908+
$logoutRequest = new OneLogin_Saml2_LogoutRequest($settings);
909+
910+
$issueInstant = $logoutRequest->getIssueInstant();
911+
$this->assertNotNull($issueInstant);
912+
}
896913
}

0 commit comments

Comments
 (0)