mirror of https://github.com/zlatinb/muwire
show fetched certificates in a table
parent
8e6517e7d8
commit
0f762968ae
|
@ -17,6 +17,8 @@ import com.muwire.core.filecert.UICreateCertificateEvent;
|
||||||
import com.muwire.core.filecert.UIFetchCertificatesEvent;
|
import com.muwire.core.filecert.UIFetchCertificatesEvent;
|
||||||
import com.muwire.core.filecert.UIImportCertificateEvent;
|
import com.muwire.core.filecert.UIImportCertificateEvent;
|
||||||
|
|
||||||
|
import net.i2p.util.ConcurrentHashSet;
|
||||||
|
|
||||||
public class CertificateManager {
|
public class CertificateManager {
|
||||||
private final Core core;
|
private final Core core;
|
||||||
private final FileManager fileManager;
|
private final FileManager fileManager;
|
||||||
|
@ -100,7 +102,7 @@ public class CertificateManager {
|
||||||
private final InfoHash infoHash;
|
private final InfoHash infoHash;
|
||||||
private volatile CertificateFetchStatus status;
|
private volatile CertificateFetchStatus status;
|
||||||
private volatile int totalCertificates;
|
private volatile int totalCertificates;
|
||||||
private Set<Certificate> certificates;
|
private final Set<Certificate> certificates = new ConcurrentHashSet<>();
|
||||||
|
|
||||||
CertificateRequest(Persona user, InfoHash infoHash) {
|
CertificateRequest(Persona user, InfoHash infoHash) {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
|
|
|
@ -175,14 +175,14 @@ class ResultByFile {
|
||||||
|
|
||||||
class Certificate {
|
class Certificate {
|
||||||
constructor(xmlNode) {
|
constructor(xmlNode) {
|
||||||
this.issuer = xmlNode.getElementsByTagName("Issuer")[0].childNodes[0].nodeVlue
|
this.issuer = xmlNode.getElementsByTagName("Issuer")[0].childNodes[0].nodeValue
|
||||||
this.name = xmlNode.getElementsByTagName("Name")[0].childNodes[0].nodeVlue
|
this.name = xmlNode.getElementsByTagName("Name")[0].childNodes[0].nodeValue
|
||||||
this.comment = null
|
this.comment = null
|
||||||
try {
|
try {
|
||||||
this.comment = xmlNode.getElementsByTagName("Comment")[0].childNodes[0].nodeVlue
|
this.comment = xmlNode.getElementsByTagName("Comment")[0].childNodes[0].nodeValue
|
||||||
} catch(ignore) {}
|
} catch(ignore) {}
|
||||||
this.timestamp = xmlNode.getElementsByTagName("Timestamp")[0].childNodes[0].nodeVlue
|
this.timestamp = xmlNode.getElementsByTagName("Timestamp")[0].childNodes[0].nodeValue
|
||||||
this.base64 = xmlNode.getElementsByTagName("Base64")[0].childNodes[0].nodeVlue
|
this.base64 = xmlNode.getElementsByTagName("Base64")[0].childNodes[0].nodeValue
|
||||||
}
|
}
|
||||||
|
|
||||||
renderRow() {
|
renderRow() {
|
||||||
|
@ -209,7 +209,7 @@ class CertificateResponse {
|
||||||
var i
|
var i
|
||||||
this.certificates = []
|
this.certificates = []
|
||||||
for (i = 0; i < certNodes.length; i++) {
|
for (i = 0; i < certNodes.length; i++) {
|
||||||
certificates.push( new Certificate(certNodes[i]))
|
this.certificates.push( new Certificate(certNodes[i]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,15 +242,16 @@ class CertificateFetch {
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTable() {
|
updateTable() {
|
||||||
|
var block = document.getElementById("certificates-" + this.divId)
|
||||||
|
|
||||||
var xmlhttp = new XMLHttpRequest()
|
var xmlhttp = new XMLHttpRequest()
|
||||||
xmlhttp.onreadystatechange = function() {
|
xmlhttp.onreadystatechange = function() {
|
||||||
if (this.readyState == 4 && this.status == 200) {
|
if (this.readyState == 4 && this.status == 200) {
|
||||||
var response = new CertificateResponse(this.responseXML)
|
var response = new CertificateResponse(this.responseXML)
|
||||||
var block = document.getElementById("certificates-" + this.divId)
|
|
||||||
block.innerHTML = response.renderTable()
|
block.innerHTML = response.renderTable()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xmlhttp.open("GET", "/MuWire/Certificate", true)
|
xmlhttp.open("GET", "/MuWire/Certificate?user=" + this.senderB64 + "&infoHash=" + this.fileInfoHash, true)
|
||||||
xmlhttp.send()
|
xmlhttp.send()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -606,6 +607,9 @@ function viewCertificatesByFile(fileSenderB64, count) {
|
||||||
var fetch = new CertificateFetch(fileSenderB64, infoHash)
|
var fetch = new CertificateFetch(fileSenderB64, infoHash)
|
||||||
certificateFetches.set(fetch.divId, fetch)
|
certificateFetches.set(fetch.divId, fetch)
|
||||||
|
|
||||||
|
var xmlhttp = new XMLHttpRequest()
|
||||||
|
xmlhttp.onreadystatechange = function() {
|
||||||
|
if (this.readyState == 4 && this.status == 200) {
|
||||||
var linkSpan = document.getElementById("certificates-link-" + fetch.divId)
|
var linkSpan = document.getElementById("certificates-link-" + fetch.divId)
|
||||||
var hideLink = "<a href='#' onclick='window.hideCertificatesByFile(\"" + fileSenderB64 + "\",\"" + count + "\");return false;'>" + _t("Hide Certificates") + "</a>"
|
var hideLink = "<a href='#' onclick='window.hideCertificatesByFile(\"" + fileSenderB64 + "\",\"" + count + "\");return false;'>" + _t("Hide Certificates") + "</a>"
|
||||||
linkSpan.innerHTML = hideLink
|
linkSpan.innerHTML = hideLink
|
||||||
|
@ -613,6 +617,11 @@ function viewCertificatesByFile(fileSenderB64, count) {
|
||||||
var fetchSpan = document.getElementById("certificates-" + fetch.divId)
|
var fetchSpan = document.getElementById("certificates-" + fetch.divId)
|
||||||
fetchSpan.innerHTML = _t("Fetching Certificates")
|
fetchSpan.innerHTML = _t("Fetching Certificates")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
xmlhttp.open("POST", "/MuWire/Certificate", true)
|
||||||
|
xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
||||||
|
xmlhttp.send("action=fetch&user=" + fileSenderB64 + "&infoHash=" + infoHash)
|
||||||
|
}
|
||||||
|
|
||||||
function hideCertificatesByFile(fileSenderB64, count) {
|
function hideCertificatesByFile(fileSenderB64, count) {
|
||||||
var id = fileSenderB64 + "_" + infoHash
|
var id = fileSenderB64 + "_" + infoHash
|
||||||
|
@ -631,6 +640,10 @@ function viewCertificatesBySender(fileInfoHash, count) {
|
||||||
var fetch = new CertificateFetch(senderB64, fileInfoHash)
|
var fetch = new CertificateFetch(senderB64, fileInfoHash)
|
||||||
certificateFetches.set(fetch.divId, fetch)
|
certificateFetches.set(fetch.divId, fetch)
|
||||||
|
|
||||||
|
|
||||||
|
var xmlhttp = new XMLHttpRequest()
|
||||||
|
xmlhttp.onreadystatechange = function() {
|
||||||
|
if (this.readyState == 4 && this.status == 200) {
|
||||||
var linkSpan = document.getElementById("certificates-link-" + fetch.divId)
|
var linkSpan = document.getElementById("certificates-link-" + fetch.divId)
|
||||||
var hideLink = "<a href='#' onclick='window.hideCertificatesBySender(\"" + fileInfoHash + "\",\"" + count + "\");return false;'>" +
|
var hideLink = "<a href='#' onclick='window.hideCertificatesBySender(\"" + fileInfoHash + "\",\"" + count + "\");return false;'>" +
|
||||||
_t("Hide Certificates") + "</a>"
|
_t("Hide Certificates") + "</a>"
|
||||||
|
@ -638,6 +651,13 @@ function viewCertificatesBySender(fileInfoHash, count) {
|
||||||
|
|
||||||
var fetchSpan = document.getElementById("certificates-" + fetch.divId)
|
var fetchSpan = document.getElementById("certificates-" + fetch.divId)
|
||||||
fetchSpan.innerHTML = _t("Fetching Certificates")
|
fetchSpan.innerHTML = _t("Fetching Certificates")
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xmlhttp.open("POST", "/MuWire/Certificate", true)
|
||||||
|
xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
||||||
|
xmlhttp.send("action=fetch&user=" + senderB64 + "&infoHash=" + fileInfoHash)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function hideCertificatesBySender(fileInfoHash, count) {
|
function hideCertificatesBySender(fileInfoHash, count) {
|
||||||
|
|
Loading…
Reference in New Issue