@@ -203,6 +203,39 @@ def __init__(self, entity_type, config=None, config_file="",
203203
204204 self .msg_cb = msg_cb
205205
206+ def reload_metadata (self , metadata_conf ):
207+ """
208+ Reload metadata configuration.
209+
210+ Load a new metadata configuration as defined by metadata_conf (by
211+ passing this to Config.load_metadata) and make this entity (as well as
212+ subordinate objects with own metadata reference) use the new metadata.
213+
214+ The structure of metadata_conf is the same as the 'metadata' entry in
215+ the configuration passed to saml2.Config.
216+
217+ param metadata_conf: Metadata configuration as passed to Config.load_metadata
218+ return: True if successfully reloaded
219+ """
220+ logger .debug ("Loading new metadata" )
221+ try :
222+ new_metadata = self .config .load_metadata (metadata_conf )
223+ except Exception as ex :
224+ logger .error ("Loading metadata failed" , exc_info = ex )
225+ return False
226+
227+ logger .debug ("Applying new metadata to main config" )
228+ ( self .metadata , self .sec .metadata , self .config .metadata ) = [new_metadata ]* 3
229+ policy = getattr (self .config , "_%s_policy" % self .entity_type , None )
230+ if policy and policy .metadata_store :
231+ logger .debug ("Applying new metadata to %s policy" , self .entity_type )
232+ policy .metadata_store = self .metadata
233+
234+ logger .debug ("Applying new metadata source_id" )
235+ self .sourceid = self .metadata .construct_source_id ()
236+
237+ return True
238+
206239 def _issuer (self , entityid = None ):
207240 """ Return an Issuer instance """
208241 if entityid :
0 commit comments