def okPressed(self):
     self.url = unicode(self.urlBox.text().strip('/')     + '/rest')
     if not self.url.startswith('http'):
         self.url = 'http://%s' % self.url
     if self.tabWidget.currentIndex() == 0:
         self.username = unicode(self.usernameBox.text())
         self.password = unicode(self.passwordBox.text())
         self.certfile = None
         self.keyfile = None
         self.cafile = None
         self.authid = None
     else:
         self.username = None
         self.password = None
         self.authid = self.certWidget.configId()
         authtype = QgsAuthManager.instance().configProviderType(self.authid);
         if authtype == QgsAuthType.None or authtype == QgsAuthType.Unknown:
             QtGui.QMessageBox.warning(self, "Authentication needed",
                               "Please specify a valid authentication for connecting to the catalog")
             return
         if authtype == QgsAuthType.Basic:
             configbasic = QgsAuthConfigBasic()
             QgsAuthManager.instance().loadAuthenticationConfig(self.authid, configbasic, True)
             self.password = configbasic.password()
             self.username = configbasic.username()
         elif authtype in pem.nonBasicAuthTypes():
             self.certfile, self.keyfile, self.cafile = pem.getPemPkiPaths(self.authid, authtype)
         else:
             QtGui.QMessageBox.warning(self, "Unsupported authentication",
                               "The selected authentication type is not supported")
             return
 def okPressed(self):
     self.url = unicode(self.urlBox.text().strip('/')     + '/rest')
     if not self.url.startswith('http'):
         self.url = 'http://%s' % self.url
     if self.tabWidget.currentIndex() == 0:
         self.username = unicode(self.usernameBox.text())
         self.password = unicode(self.passwordBox.text())
         self.certfile = None
         self.keyfile = None
         self.cafile = None
         self.authid = None
     else:
         self.username = None
         self.password = None
         self.authid = self.certWidget.configId()
         if QGis.QGIS_VERSION_INT < 21200:
             authtype = QgsAuthManager.instance().configProviderType(self.authid);
             if authtype == QgsAuthType.None or authtype == QgsAuthType.Unknown:
                 QtGui.QMessageBox.warning(self, "Authentication needed",
                                   "Please specify a valid authentication for connecting to the catalog")
                 return
             if authtype == QgsAuthType.Basic:
                 configbasic = QgsAuthConfigBasic()
                 QgsAuthManager.instance().loadAuthenticationConfig(self.authid, configbasic, True)
                 self.password = configbasic.password()
                 self.username = configbasic.username()
             elif authtype in pem.nonBasicAuthTypes():
                 self.certfile, self.keyfile, self.cafile = pem.getPemPkiPaths(self.authid, authtype)
             else:
                 QtGui.QMessageBox.warning(self, "Unsupported authentication",
                                   "The selected authentication type is not supported")
                 return
         else:
                else:
                    QtGui.QMessageBox.warning(self, "Unsupported authentication",
                                      "The selected authentication type is not supported")
                    return
            else:
                authtype = QgsAuthManager.instance().configAuthMethodKey(self.authid)
                if not authtype or authtype == '':
                    QtGui.QMessageBox.warning(self, "Authentication needed",
                                              "Please specify a valid authentication for connecting to the catalog")
                    return
                if authtype == 'Basic':
                    amconfig = QgsAuthMethodConfig()
                    QgsAuthManager.instance().loadAuthenticationConfig(self.authid, amconfig, True)
                    self.password = amconfig.config('username')
                    self.username = amconfig.config('password')
                elif authtype in pem.nonBasicAuthTypes():
                    self.certfile, self.keyfile, self.cafile = pem.getPemPkiPaths(self.authid, authtype)
                else:
                    QtGui.QMessageBox.warning(self, "Unsupported authentication",
                                              "The selected authentication type is not supported")
                    return

        nametxt = unicode(self.nameBox.text())
        # increment only when adding a new connection or if editing a saved
        # connection and the name has changed
        if self.name is None or (self.name is not None and nametxt != self.name):
            newname = nametxt
            i = 2
            while newname in self.catalogs.keys():
                newname = nametxt + "_" + str(i)
                i += 1
                else:
                    QtGui.QMessageBox.warning(self, "Unsupported authentication",
                                      "The selected authentication type is not supported")
                    return
            else:
                authtype = QgsAuthManager.instance().configAuthMethodKey(self.authid)
                if not authtype or authtype == '':
                    QtGui.QMessageBox.warning(self, "Authentication needed",
                                              "Please specify a valid authentication for connecting to the catalog")
                    return
                if authtype == 'Basic':
                    amconfig = QgsAuthMethodConfig()
                    QgsAuthManager.instance().loadAuthenticationConfig(self.authid, amconfig, True)
                    self.password = amconfig.config('username')
                    self.username = amconfig.config('password')
                elif authtype in pem.nonBasicAuthTypes():
                    self.certfile, self.keyfile, self.cafile = pem.getPemPkiPaths(self.authid, authtype)
                else:
                    QtGui.QMessageBox.warning(self, "Unsupported authentication",
                                              "The selected authentication type is not supported")
                    return

        nametxt = unicode(self.nameBox.text())
        # increment only when adding a new connection or if editing a saved
        # connection and the name has changed
        if self.name is None or (self.name is not None and nametxt != self.name):
            newname = nametxt
            i = 2
            while newname in self.catalogs.keys():
                newname = nametxt + "_" + str(i)
                i += 1