@@ -38,10 +38,11 @@ class Metadata
3838 * @param array $contacts Contacts info
3939 * @param array $organization Organization ingo
4040 * @param array $attributes
41+ * @param bool $ignoreValidUntil exclude the validUntil tag from metadata
4142 *
4243 * @return string SAML Metadata XML
4344 */
44- public static function builder ($ sp , $ authnsign = false , $ wsign = false , $ validUntil = null , $ cacheDuration = null , $ contacts = array (), $ organization = array (), $ attributes = array ())
45+ public static function builder ($ sp , $ authnsign = false , $ wsign = false , $ validUntil = null , $ cacheDuration = null , $ contacts = array (), $ organization = array (), $ attributes = array (), $ ignoreValidUntil = false )
4546 {
4647
4748 if (!isset ($ validUntil )) {
@@ -161,27 +162,37 @@ public static function builder($sp, $authnsign = false, $wsign = false, $validUn
161162
162163 $ requestedAttributeStr = implode (PHP_EOL , $ requestedAttributeData );
163164 $ strAttributeConsumingService = <<<METADATA_TEMPLATE
164- <md:AttributeConsumingService index="1">
165+
166+ <md:AttributeConsumingService index="1">
165167 <md:ServiceName xml:lang="en"> {$ sp ['attributeConsumingService ' ]['serviceName ' ]}</md:ServiceName>
166168{$ attrCsDesc }{$ requestedAttributeStr }
167169 </md:AttributeConsumingService>
168170METADATA_TEMPLATE ;
169171 }
170172
173+ if ($ ignoreValidUntil ) {
174+ $ timeStr = <<<TIME_TEMPLATE
175+ cacheDuration="PT {$ cacheDuration }S";
176+ TIME_TEMPLATE ;
177+ } else {
178+ $ timeStr = <<<TIME_TEMPLATE
179+ validUntil=" {$ validUntilTime }"
180+ cacheDuration="PT {$ cacheDuration }S"
181+ TIME_TEMPLATE ;
182+ }
183+
171184 $ spEntityId = htmlspecialchars ($ sp ['entityId ' ], ENT_QUOTES );
172185 $ acsUrl = htmlspecialchars ($ sp ['assertionConsumerService ' ]['url ' ], ENT_QUOTES );
173186 $ metadata = <<<METADATA_TEMPLATE
174187<?xml version="1.0"?>
175188<md:EntityDescriptor xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"
176- validUntil=" {$ validUntilTime }"
177- cacheDuration="PT {$ cacheDuration }S"
189+ {$ timeStr }
178190 entityID=" {$ spEntityId }">
179191 <md:SPSSODescriptor AuthnRequestsSigned=" {$ strAuthnsign }" WantAssertionsSigned=" {$ strWsign }" protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol">
180192{$ sls } <md:NameIDFormat> {$ sp ['NameIDFormat ' ]}</md:NameIDFormat>
181193 <md:AssertionConsumerService Binding=" {$ sp ['assertionConsumerService ' ]['binding ' ]}"
182194 Location=" {$ acsUrl }"
183- index="1" />
184- {$ strAttributeConsumingService }
195+ index="1" /> {$ strAttributeConsumingService }
185196 </md:SPSSODescriptor> {$ strOrganization }{$ strContacts }
186197</md:EntityDescriptor>
187198METADATA_TEMPLATE ;
0 commit comments