コード例 #1
0
def createGeoServerCatalog(service_url = "http://localhost:8080/geoserver/rest",
                           username="******",
                           password="******",
                           authid=None,
                           authtype=None,
                           disable_ssl_certificate_validation=False):
    # if not authid use basic auth
    if not authid or not authtype:
        catalog = GSCatalog(service_url, username, password, disable_ssl_certificate_validation)
    elif QGis.QGIS_VERSION_INT < 21200:
        # if autcfg, then get certs and ca and create a PKICatalog
        certfile, keyfile, cafile = pem.getPemPkiPaths(authid, authtype)

        # set connection
        catalog = PKICatalog(service_url, keyfile, certfile, cafile)

        # set authid parameter used by uri.py functions to manage
        # uri creation with pki credential
        catalog.authid = authid
    else:
        # For QGIS > 2.12, use the new AuthCatalog and QgsNetworkAccessManager
        settings = QtCore.QSettings()
        cache_time = int(settings.value("/GeoServer/Settings/GeoServer/AuthCatalogXMLCacheTime", 180, int))
        catalog = AuthCatalog(service_url, authid, cache_time)

    return CatalogWrapper(catalog)
コード例 #2
0
 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
コード例 #3
0
def createGeoServerCatalog(service_url="http://localhost:8080/geoserver/rest",
                           username="******",
                           password="******",
                           authid=None,
                           authtype=None,
                           disable_ssl_certificate_validation=False):
    # if not authid use basic auth
    if not authid or not authtype:
        catalog = BaseCatalog(service_url, username, password,
                              disable_ssl_certificate_validation)
    elif QGis.QGIS_VERSION_INT < 21200:
        # if autcfg, then get certs and ca and create a PKICatalog
        certfile, keyfile, cafile = pem.getPemPkiPaths(authid, authtype)

        # set connection
        catalog = PKICatalog(service_url, keyfile, certfile, cafile)

        # set authid parameter used by uri.py functions to manage
        # uri creation with pki credential
        catalog.authid = authid
    else:
        # For QGIS > 2.12, use the new AuthCatalog and QgsNetworkAccessManager
        settings = QtCore.QSettings()
        cache_time = int(
            settings.value(
                "/GeoServer/Settings/GeoServer/AuthCatalogXMLCacheTime", 180,
                int))
        catalog = AuthCatalog(service_url, authid, cache_time)

    return CatalogWrapper(catalog)
コード例 #4
0
 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:
コード例 #5
0
def createGeoServerCatalog(service_url = "http://localhost:8080/geoserver/rest",
                           username="******",
                           password="******",
                           authcfg=None,
                           authtype=None,
                           disable_ssl_certificate_validation=False):
    # if not authcfg use basic auth
    if not authcfg or not authtype:
        catalog = GSCatalog(service_url, username, password, disable_ssl_certificate_validation)

    # if autcfg, then get certs and ca and create a PKICatalog
    else:
        certfile, keyfile, cafile = pem.getPemPkiPaths(authcfg, authtype)

        # set connection
        catalog = PKICatalog(service_url, keyfile, certfile, cafile)

        # set authcfg parameter used by uri.py functions to manage
        # uri creation with pki credential
        catalog.authcfg = authcfg

    return CatalogWrapper(catalog)
コード例 #6
0
                    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
            self.name = newname
コード例 #7
0
                    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
            self.name = newname