@@ -51,11 +51,13 @@ public function loadSource($source) {
5151 }
5252 $ template = NULL ;
5353 if (array_key_exists ('template ' , $ source )) $ template = $ source ['template ' ];
54+
55+ $ expireDuration = time () + min ($ this ->maxcache , $ this ->maxduration );
5456
55- $ this ->addMetadata ($ source ['src ' ], $ entity ->getMetadata1xSP (), 'shib13-sp-remote ' , $ template );
56- $ this ->addMetadata ($ source ['src ' ], $ entity ->getMetadata1xIdP (), 'shib13-idp-remote ' , $ template );
57- $ this ->addMetadata ($ source ['src ' ], $ entity ->getMetadata20SP (), 'saml20-sp-remote ' , $ template );
58- $ this ->addMetadata ($ source ['src ' ], $ entity ->getMetadata20IdP (), 'saml20-idp-remote ' , $ template );
57+ $ this ->addMetadata ($ source ['src ' ], $ entity ->getMetadata1xSP (), 'shib13-sp-remote ' , $ template, $ expireDuration );
58+ $ this ->addMetadata ($ source ['src ' ], $ entity ->getMetadata1xIdP (), 'shib13-idp-remote ' , $ template, $ expireDuration );
59+ $ this ->addMetadata ($ source ['src ' ], $ entity ->getMetadata20SP (), 'saml20-sp-remote ' , $ template, $ expireDuration );
60+ $ this ->addMetadata ($ source ['src ' ], $ entity ->getMetadata20IdP (), 'saml20-idp-remote ' , $ template, $ expireDuration );
5961 }
6062 }
6163
@@ -98,7 +100,7 @@ public function dumpMetadataStdOut() {
98100 * @param $metadata The metadata.
99101 * @param $type The metadata type.
100102 */
101- private function addMetadata ($ filename , $ metadata , $ type , $ template = NULL ) {
103+ private function addMetadata ($ filename , $ metadata , $ type , $ template = NULL , $ expireDuration ) {
102104
103105 if ($ metadata === NULL ) {
104106 return ;
@@ -115,6 +117,13 @@ private function addMetadata($filename, $metadata, $type, $template = NULL) {
115117 if (!array_key_exists ($ type , $ this ->metadata )) {
116118 $ this ->metadata [$ type ] = array ();
117119 }
120+
121+ if (!array_key_exists ('expire ' , $ metadata )) {
122+ $ metadata ['expire ' ] = $ expireDuration ;
123+ } else {
124+ if ($ expireDuration < $ metadata ['expire ' ])
125+ $ metadata ['expire ' ] = $ expireDuration ;
126+ }
118127
119128 $ this ->metadata [$ type ][] = array ('filename ' => $ filename , 'metadata ' => $ metadata );
120129 }
0 commit comments