@@ -444,7 +444,7 @@ def _load_node_config(self, addr):
444
444
node_config ['Server' ]['Address' ] = self .comboNodeAddress .currentText ()
445
445
node_config ['Server' ]['LogFile' ] = self .comboNodeLogFile .currentText ()
446
446
447
- cfg = self ._load_node_auth_config (node_config ['Server' ])
447
+ cfg = self ._save_node_auth_config (node_config ['Server' ])
448
448
if cfg != None :
449
449
node_config ['Server' ] = cfg
450
450
else :
@@ -457,51 +457,67 @@ def _load_node_config(self, addr):
457
457
458
458
def _load_node_auth_settings (self , config ):
459
459
try :
460
- if config .get ('Authentication' ) == None :
461
- self .toolBox .setItemEnabled (self .NODE_PAGE_AUTH , False )
460
+ if config == None :
462
461
return
462
+
463
463
auth = config .get ('Authentication' )
464
- authtype_idx = self .comboNodeAuthType .findData (auth ['Type' ])
464
+ authtype_idx = 0
465
+ if auth != None :
466
+ if auth .get ('Type' ) != None :
467
+ authtype_idx = self .comboNodeAuthType .findData (auth ['Type' ])
468
+ else :
469
+ config ['Authentication' ] = {}
470
+ auth = config .get ('Authentication' )
471
+
465
472
self .lineNodeCACertFile .setEnabled (authtype_idx >= 0 )
466
473
self .lineNodeServerCertFile .setEnabled (authtype_idx >= 0 )
467
474
self .lineNodeCertFile .setEnabled (authtype_idx >= 0 )
468
475
self .lineNodeCertKeyFile .setEnabled (authtype_idx >= 0 )
469
476
470
477
tls = auth .get ('TLSOptions' )
471
478
if tls != None and authtype_idx >= 0 :
472
- self .lineNodeCACertFile .setText (tls ['CACert' ])
473
- self .lineNodeServerCertFile .setText (tls ['ServerCert' ])
474
- self .lineNodeCertFile .setText (tls ['ClientCert' ])
475
- self .lineNodeCertKeyFile .setText (tls ['ClientKey' ])
476
- self .checkNodeAuthSkipVerify .setChecked (tls ['SkipVerify' ])
477
-
478
- clienttype_idx = self .comboNodeAuthVerifyType .findData (tls ['ClientAuthType' ])
479
- if clienttype_idx >= 0 :
480
- self .comboNodeAuthVerifyType .setCurrentIndex (clienttype_idx )
481
- else :
482
- authtype_idx = 0
479
+ if tls .get ('CACert' ) != None :
480
+ self .lineNodeCACertFile .setText (tls ['CACert' ])
481
+ if tls .get ('ServerCert' ) != None :
482
+ self .lineNodeServerCertFile .setText (tls ['ServerCert' ])
483
+ if tls .get ('ClientCert' ) != None :
484
+ self .lineNodeCertFile .setText (tls ['ClientCert' ])
485
+ if tls .get ('ClientKey' ) != None :
486
+ self .lineNodeCertKeyFile .setText (tls ['ClientKey' ])
487
+ if tls .get ('SkipVerify' ) != None :
488
+ self .checkNodeAuthSkipVerify .setChecked (tls ['SkipVerify' ])
489
+
490
+ if tls .get ('ClientAuthType' ) != None :
491
+ clienttype_idx = self .comboNodeAuthVerifyType .findData (tls ['ClientAuthType' ])
492
+ if clienttype_idx >= 0 :
493
+ self .comboNodeAuthVerifyType .setCurrentIndex (clienttype_idx )
494
+
483
495
self .comboNodeAuthType .setCurrentIndex (authtype_idx )
484
496
# signals are connected after this method is called
485
497
self ._cb_combo_node_auth_type_changed (authtype_idx )
486
498
except Exception as e :
487
- print ("[prefs] node auth options exception:" , e )
499
+ print ("[prefs] load node auth options exception:" , e )
488
500
self ._set_status_error (str (e ))
489
501
490
- def _load_node_auth_config (self , config ):
502
+ def _save_node_auth_config (self , config ):
491
503
try :
492
- if config .get ('Authentication' ) == None :
493
- self .toolBox .setItemEnabled (self .NODE_PAGE_AUTH , False )
494
- return
495
504
auth = config .get ('Authentication' )
505
+ if auth == None :
506
+ auth = {}
507
+
496
508
auth ['Type' ] = self .NODE_AUTH [self .comboNodeAuthType .currentIndex ()]
497
509
tls = auth .get ('TLSOptions' )
498
- if tls != None :
499
- tls ['CACert' ]= self .lineNodeCACertFile .text ()
500
- tls ['ServerCert' ] = self .lineNodeServerCertFile .text ()
501
- tls ['ClientCert' ] = self .lineNodeCertFile .text ()
502
- tls ['ClientKey' ] = self .lineNodeCertKeyFile .text ()
503
- tls ['SkipVerify' ] = self .checkNodeAuthSkipVerify .isChecked ()
504
- tls ['ClientAuthType' ] = self .NODE_AUTH_VERIFY [self .comboNodeAuthVerifyType .currentIndex ()]
510
+ if tls == None :
511
+ tls = {}
512
+
513
+ tls ['CACert' ] = self .lineNodeCACertFile .text ()
514
+ tls ['ServerCert' ] = self .lineNodeServerCertFile .text ()
515
+ tls ['ClientCert' ] = self .lineNodeCertFile .text ()
516
+ tls ['ClientKey' ] = self .lineNodeCertKeyFile .text ()
517
+ tls ['SkipVerify' ] = self .checkNodeAuthSkipVerify .isChecked ()
518
+ tls ['ClientAuthType' ] = self .NODE_AUTH_VERIFY [self .comboNodeAuthVerifyType .currentIndex ()]
519
+ auth ['TLSOptions' ] = tls
520
+ config ['Authentication' ] = auth
505
521
506
522
return config
507
523
except Exception as e :
@@ -544,6 +560,14 @@ def _reset_node_settings(self):
544
560
self .checkNodeLogMicro .setChecked (False )
545
561
self .labelNodeName .setText ("" )
546
562
self .labelNodeVersion .setText ("" )
563
+ self .comboNodeAuthType .setCurrentIndex (self .AUTH_SIMPLE )
564
+ self .lineNodeCACertFile .setText ("" )
565
+ self .lineNodeServerCertFile .setText ("" )
566
+ self .lineNodeCertFile .setText ("" )
567
+ self .lineNodeCertKeyFile .setText ("" )
568
+ self .checkNodeAuthSkipVerify .setChecked (False )
569
+ self .comboNodeAuthVerifyType .setCurrentIndex (0 )
570
+ self ._cb_combo_node_auth_type_changed (0 )
547
571
548
572
def _save_settings (self ):
549
573
self ._reset_status_message ()
@@ -739,38 +763,6 @@ def _save_node_config(self, notifObject, addr):
739
763
740
764
return None
741
765
742
- def _save_node_auth_config (self , config ):
743
- try :
744
- if config .get ('Authentication' ) == None :
745
- self .toolBox .setItemEnabled (self .NODE_PAGE_AUTH , False )
746
- return
747
-
748
- auth = config ['Authentication' ]
749
- authtype_idx = self .comboNodeAuthType .findData (auth ['Type' ])
750
- self .lineNodeCACertFile .setEnabled (authtype_idx >= 0 )
751
- self .lineNodeServerCertFile .setEnabled (authtype_idx >= 0 )
752
- self .lineNodeCertFile .setEnabled (authtype_idx >= 0 )
753
- self .lineNodeCertKeyFile .setEnabled (authtype_idx >= 0 )
754
-
755
- tls = auth .get ('TLSOptions' )
756
- if tls != None and authtype_idx >= 0 :
757
- self .lineNodeCACertFile .setText (tls ['CACert' ])
758
- self .lineNodeServerCertFile .setText (tls ['ServerCert' ])
759
- self .lineNodeCertFile .setText (tls ['ClientCert' ])
760
- self .lineNodeCertKeyFile .setText (tls ['ClientKey' ])
761
- self .checkNodeAuthSkipVerify .setChecked (tls ['SkipVerify' ])
762
-
763
- clienttype_idx = self .comboNodeAuthVerifyType .findData (tls ['ClientAuthType' ])
764
- if clienttype_idx >= 0 :
765
- self .comboNodeAuthVerifyType .setCurrentIndex (clienttype_idx )
766
- else :
767
- authtype_idx = 0
768
- self .comboNodeAuthType .setCurrentIndex (authtype_idx )
769
- except Exception as e :
770
- print ("[prefs] node auth options exception:" , e )
771
- self ._set_status_error (str (e ))
772
-
773
-
774
766
def _validate_certs (self ):
775
767
try :
776
768
if self .comboAuthType .currentIndex () == PreferencesDialog .AUTH_SIMPLE :
0 commit comments