1<?php 2 3class OneLogin_Saml_Metadata 4{ 5 const VALIDITY_SECONDS = 604800; // 1 week 6 7 protected $_settings; 8 9 /** 10 * @param array|object|null $settings Setting data 11 */ 12 public function __construct($settings = null) 13 { 14 $auth = new OneLogin_Saml2_Auth($settings); 15 $this->_settings = $auth->getSettings(); 16 } 17 18 /** 19 * @return string 20 * 21 * @throws OneLogin_Saml2_Error 22 */ 23 public function getXml() 24 { 25 return $this->_settings->getSPMetadata(); 26 } 27 28 /** 29 * @return string 30 */ 31 protected function _getMetadataValidTimestamp() 32 { 33 $timestamp = time() + self::VALIDITY_SECONDS; 34 $date = new DateTime("@$timestamp", new DateTimeZone('UTC')); 35 $time = $date->format("Y-m-d\TH:i:s\Z"); 36 return $time; 37 } 38} 39