75 ## self.__proxy = NetworkAccessManagerProxy(self) |
75 ## self.__proxy = NetworkAccessManagerProxy(self) |
76 ## self.__proxy.setWebPage(self) |
76 ## self.__proxy.setWebPage(self) |
77 ## self.__proxy.setPrimaryNetworkAccessManager( |
77 ## self.__proxy.setPrimaryNetworkAccessManager( |
78 ## WebBrowserWindow.networkManager()) |
78 ## WebBrowserWindow.networkManager()) |
79 ## self.setNetworkAccessManager(self.__proxy) |
79 ## self.setNetworkAccessManager(self.__proxy) |
80 |
80 ## |
81 self.__sslConfiguration = None |
81 ## self.__sslConfiguration = None |
82 ## self.__proxy.finished.connect(self.__managerFinished) |
82 ## self.__proxy.finished.connect(self.__managerFinished) |
83 ## |
83 ## |
84 ## self.__adBlockedEntries = [] |
84 ## self.__adBlockedEntries = [] |
85 ## self.loadStarted.connect(self.__loadStarted) |
85 ## self.loadStarted.connect(self.__loadStarted) |
86 self.featurePermissionRequested.connect( |
86 self.featurePermissionRequested.connect( |
387 ## if agent == "": |
387 ## if agent == "": |
388 ## # no global agent string specified -> use default one |
388 ## # no global agent string specified -> use default one |
389 ## agent = QWebPage.userAgentForUrl(self, url) |
389 ## agent = QWebPage.userAgentForUrl(self, url) |
390 ## return agent |
390 ## return agent |
391 ## |
391 ## |
392 # TODO: SSL |
392 ## def hasValidSslInfo(self): |
393 ## def __managerFinished(self, reply): |
393 ## """ |
394 ## """ |
394 ## Public method to check, if the page has a valid SSL certificate. |
395 ## Private slot to handle a finished reply. |
395 ## |
396 ## |
396 ## @return flag indicating a valid SSL certificate (boolean) |
397 ## This slot is used to get SSL related information for a reply. |
|
398 ## |
|
399 ## @param reply reference to the finished reply (QNetworkReply) |
|
400 ## """ |
|
401 ## try: |
|
402 ## frame = reply.request().originatingObject() |
|
403 ## except AttributeError: |
|
404 ## frame = None |
|
405 ## |
|
406 ## mainFrameRequest = frame == self.mainFrame() |
|
407 ## |
|
408 ## if mainFrameRequest and \ |
|
409 ## self.__sslConfiguration is not None and \ |
|
410 ## reply.url() == self.mainFrame().url(): |
|
411 ## self.__sslConfiguration = None |
|
412 ## |
|
413 ## if reply.error() == QNetworkReply.NoError and \ |
|
414 ## mainFrameRequest and \ |
|
415 ## self.__sslConfiguration is None and \ |
|
416 ## reply.url().scheme().lower() == "https" and \ |
|
417 ## reply.url() == self.mainFrame().url(): |
|
418 ## self.__sslConfiguration = reply.sslConfiguration() |
|
419 ## self.__sslConfiguration.url = QUrl(reply.url()) |
|
420 ## |
|
421 ## if reply.error() == QNetworkReply.NoError and \ |
|
422 ## mainFrameRequest and \ |
|
423 ## reply.url() == self.mainFrame().url(): |
|
424 ## modified = reply.header(QNetworkRequest.LastModifiedHeader) |
|
425 ## if modified and modified.isValid(): |
|
426 ## manager = WebBrowserWindow.bookmarksManager() |
|
427 ## from .Bookmarks.BookmarkNode import BookmarkNode |
|
428 ## for bookmark in manager.bookmarksForUrl(reply.url()): |
|
429 ## manager.setTimestamp(bookmark, BookmarkNode.TsModified, |
|
430 ## modified) |
|
431 |
|
432 ## def getSslCertificate(self): |
|
433 ## """ |
|
434 ## Public method to get a reference to the SSL certificate. |
|
435 ## |
|
436 ## @return amended SSL certificate (QSslCertificate) |
|
437 ## """ |
397 ## """ |
438 ## if self.__sslConfiguration is None: |
398 ## if self.__sslConfiguration is None: |
439 ## return None |
399 ## return False |
440 ## |
400 ## |
441 ## sslInfo = self.__sslConfiguration.peerCertificate() |
401 ## certList = self.__sslConfiguration.peerCertificateChain() |
442 ## sslInfo.url = QUrl(self.__sslConfiguration.url) |
402 ## if not certList: |
443 ## return sslInfo |
403 ## return False |
444 ## |
404 ## |
445 ## def getSslCertificateChain(self): |
405 ## certificateDict = Globals.toDict( |
446 ## """ |
406 ## Preferences.Prefs.settings.value("Ssl/CaCertificatesDict")) |
447 ## Public method to get a reference to the SSL certificate chain. |
407 ## for server in certificateDict: |
448 ## |
408 ## localCAList = QSslCertificate.fromData(certificateDict[server]) |
449 ## @return SSL certificate chain (list of QSslCertificate) |
409 ## for cert in certList: |
450 ## """ |
410 ## if cert in localCAList: |
451 ## if self.__sslConfiguration is None: |
411 ## return True |
452 ## return [] |
412 ## |
453 ## |
413 ## for cert in certList: |
454 ## chain = self.__sslConfiguration.peerCertificateChain() |
414 ## if cert.isBlacklisted(): |
455 ## return chain |
415 ## return False |
456 ## |
416 ## |
457 ## def getSslConfiguration(self): |
417 ## return True |
458 ## """ |
|
459 ## Public method to return a reference to the current SSL configuration. |
|
460 ## |
|
461 ## @return reference to the SSL configuration in use (QSslConfiguration) |
|
462 ## """ |
|
463 ## return self.__sslConfiguration |
|
464 ## |
|
465 ## def showSslInfo(self, pos): |
|
466 ## """ |
|
467 ## Public slot to show some SSL information for the loaded page. |
|
468 ## |
|
469 ## @param pos position to show the info at (QPoint) |
|
470 ## """ |
|
471 ## if SSL_AVAILABLE and self.__sslConfiguration is not None: |
|
472 ## from E5Network.E5SslInfoWidget import E5SslInfoWidget |
|
473 ## widget = E5SslInfoWidget( |
|
474 ## self.mainFrame().url(), self.__sslConfiguration, self.view()) |
|
475 ## widget.showAt(pos) |
|
476 ## else: |
|
477 ## E5MessageBox.warning( |
|
478 ## self.view(), |
|
479 ## self.tr("SSL Info"), |
|
480 ## self.tr("""This site does not contain SSL information.""")) |
|
481 ## |
|
482 def hasValidSslInfo(self): |
|
483 """ |
|
484 Public method to check, if the page has a valid SSL certificate. |
|
485 |
|
486 @return flag indicating a valid SSL certificate (boolean) |
|
487 """ |
|
488 if self.__sslConfiguration is None: |
|
489 return False |
|
490 |
|
491 certList = self.__sslConfiguration.peerCertificateChain() |
|
492 if not certList: |
|
493 return False |
|
494 |
|
495 certificateDict = Globals.toDict( |
|
496 Preferences.Prefs.settings.value("Ssl/CaCertificatesDict")) |
|
497 for server in certificateDict: |
|
498 localCAList = QSslCertificate.fromData(certificateDict[server]) |
|
499 for cert in certList: |
|
500 if cert in localCAList: |
|
501 return True |
|
502 |
|
503 for cert in certList: |
|
504 if cert.isBlacklisted(): |
|
505 return False |
|
506 |
|
507 return True |
|
508 |
418 |
509 ## @classmethod |
419 ## @classmethod |
510 ## def webPluginFactory(cls): |
420 ## def webPluginFactory(cls): |
511 ## """ |
421 ## """ |
512 ## Class method to get a reference to the web plug-in factory |
422 ## Class method to get a reference to the web plug-in factory |