@@ -21,10 +21,11 @@ class OneLogin_Saml2_Metadata
2121 * @param array $contacts Contacts info
2222 * @param array $organization Organization ingo
2323 * @param array $attributes
24+ * @param bool $ignoreValidUntil exclude the validUntil tag from metadata
2425 *
2526 * @return string SAML Metadata XML
2627 */
27- public static function builder ($ sp , $ authnsign = false , $ wsign = false , $ validUntil = null , $ cacheDuration = null , $ contacts = array (), $ organization = array (), $ attributes = array ())
28+ public static function builder ($ sp , $ authnsign = false , $ wsign = false , $ validUntil = null , $ cacheDuration = null , $ contacts = array (), $ organization = array (), $ attributes = array (), $ ignoreValidUntil = false )
2829 {
2930
3031 if (!isset ($ validUntil )) {
@@ -144,27 +145,37 @@ public static function builder($sp, $authnsign = false, $wsign = false, $validUn
144145
145146 $ requestedAttributeStr = implode (PHP_EOL , $ requestedAttributeData );
146147 $ strAttributeConsumingService = <<<METADATA_TEMPLATE
147- <md:AttributeConsumingService index="1">
148+
149+ <md:AttributeConsumingService index="1">
148150 <md:ServiceName xml:lang="en"> {$ sp ['attributeConsumingService ' ]['serviceName ' ]}</md:ServiceName>
149151{$ attrCsDesc }{$ requestedAttributeStr }
150152 </md:AttributeConsumingService>
151153METADATA_TEMPLATE ;
152154 }
153155
156+ if ($ ignoreValidUntil ) {
157+ $ timeStr = <<<TIME_TEMPLATE
158+ cacheDuration="PT {$ cacheDuration }S";
159+ TIME_TEMPLATE ;
160+ } else {
161+ $ timeStr = <<<TIME_TEMPLATE
162+ validUntil=" {$ validUntilTime }"
163+ cacheDuration="PT {$ cacheDuration }S"
164+ TIME_TEMPLATE ;
165+ }
166+
154167 $ spEntityId = htmlspecialchars ($ sp ['entityId ' ], ENT_QUOTES );
155168 $ acsUrl = htmlspecialchars ($ sp ['assertionConsumerService ' ]['url ' ], ENT_QUOTES );
156169 $ metadata = <<<METADATA_TEMPLATE
157170<?xml version="1.0"?>
158171<md:EntityDescriptor xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"
159- validUntil=" {$ validUntilTime }"
160- cacheDuration="PT {$ cacheDuration }S"
172+ {$ timeStr }
161173 entityID=" {$ spEntityId }">
162174 <md:SPSSODescriptor AuthnRequestsSigned=" {$ strAuthnsign }" WantAssertionsSigned=" {$ strWsign }" protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol">
163175{$ sls } <md:NameIDFormat> {$ sp ['NameIDFormat ' ]}</md:NameIDFormat>
164176 <md:AssertionConsumerService Binding=" {$ sp ['assertionConsumerService ' ]['binding ' ]}"
165177 Location=" {$ acsUrl }"
166- index="1" />
167- {$ strAttributeConsumingService }
178+ index="1" /> {$ strAttributeConsumingService }
168179 </md:SPSSODescriptor> {$ strOrganization }{$ strContacts }
169180</md:EntityDescriptor>
170181METADATA_TEMPLATE ;
0 commit comments