@@ -194,6 +194,24 @@ def set_cert_path(self, path):
194194 """
195195 self ._paths ['cert' ] = path
196196
197+ def set_sp_cert_filename (self , filename ):
198+ """
199+ Set the filename of the SP certificate
200+ """
201+ self ._sp ['cert_filename' ] = filename
202+
203+ def set_sp_key_filename (self , filename ):
204+ """
205+ Set the filename of the SP key
206+ """
207+ self ._sp ['key_filename' ] = filename
208+
209+ def set_idp_cert_filename (self , filename ):
210+ """
211+ Set the filename of the idp certificate
212+ """
213+ self ._idp ['cert_filename' ] = filename
214+
197215 def get_lib_path (self ):
198216 """
199217 Returns lib path
@@ -214,26 +232,27 @@ def get_schemas_path(self):
214232
215233 def _load_settings_from_dict (self , settings ):
216234 """
217- Loads settings info from a settings Dict
235+ Loads settings info from a settings Dict, adds default values and validates the settings
218236
219237 :param settings: SAML Toolkit Settings
220238 :type settings: dict
221239
222240 :returns: True if the settings info is valid
223241 :rtype: boolean
224242 """
243+ self ._sp = settings .get ('sp' , {})
244+ self ._idp = settings .get ('idp' , {})
245+ self ._strict = settings .get ('strict' , True )
246+ self ._debug = settings .get ('debug' , False )
247+ self ._security = settings .get ('security' , {})
248+ self ._contacts = settings .get ('contactPerson' , {})
249+ self ._organization = settings .get ('organization' , {})
250+ self ._add_default_values ()
251+
252+ self ._errors = []
225253 errors = self .check_settings (settings )
254+
226255 if len (errors ) == 0 :
227- self ._errors = []
228- self ._sp = settings ['sp' ]
229- self ._idp = settings .get ('idp' , {})
230- self ._strict = settings .get ('strict' , True )
231- self ._debug = settings .get ('debug' , False )
232- self ._security = settings .get ('security' , {})
233- self ._contacts = settings .get ('contactPerson' , {})
234- self ._organization = settings .get ('organization' , {})
235-
236- self ._add_default_values ()
237256 return True
238257
239258 self ._errors = errors
@@ -328,6 +347,11 @@ def _add_default_values(self):
328347 self ._sp .setdefault ('x509cert' , '' )
329348 self ._sp .setdefault ('privateKey' , '' )
330349
350+ # Set the default filenames for the certificates and keys
351+ self ._idp .setdefault ('cert_filename' , 'idp.crt' )
352+ self ._sp .setdefault ('cert_filename' , 'sp.crt' )
353+ self ._sp .setdefault ('key_filename' , 'sp.key' )
354+
331355 self ._security .setdefault ('requestedAuthnContext' , True )
332356 self ._security .setdefault ('requestedAuthnContextComparison' , 'exact' )
333357 self ._security .setdefault ('failOnAuthnContextMismatch' , False )
@@ -389,7 +413,7 @@ def check_idp_settings(self, settings):
389413 if 'security' in settings :
390414 security = settings ['security' ]
391415
392- exists_x509 = bool (idp . get ( 'x509cert' ))
416+ exists_x509 = bool (self . get_idp_cert ( ))
393417 exists_fingerprint = bool (idp .get ('certFingerprint' ))
394418
395419 exists_multix509sign = 'x509certMulti' in idp and \
@@ -566,7 +590,7 @@ def get_sp_key(self):
566590 :rtype: string or None
567591 """
568592 key = self ._sp .get ('privateKey' )
569- key_file_name = self ._paths ['cert' ] + 'sp.key'
593+ key_file_name = self ._paths ['cert' ] + self . _sp [ 'key_filename' ]
570594
571595 if not key and exists (key_file_name ):
572596 with open (key_file_name ) as f :
@@ -581,7 +605,7 @@ def get_sp_cert(self):
581605 :rtype: string or None
582606 """
583607 cert = self ._sp .get ('x509cert' )
584- cert_file_name = self ._paths ['cert' ] + 'sp.crt'
608+ cert_file_name = self ._paths ['cert' ] + self . _sp [ 'cert_filename' ]
585609
586610 if not cert and exists (cert_file_name ):
587611 with open (cert_file_name ) as f :
@@ -612,7 +636,7 @@ def get_idp_cert(self):
612636 :rtype: string
613637 """
614638 cert = self ._idp .get ('x509cert' )
615- cert_file_name = self .get_cert_path () + 'idp.crt'
639+ cert_file_name = self .get_cert_path () + self . _idp [ 'cert_filename' ]
616640 if not cert and exists (cert_file_name ):
617641 with open (cert_file_name ) as f :
618642 cert = f .read ()
0 commit comments