mirror of https://github.com/zlatinb/muwire
wip on importing certificates
parent
0f762968ae
commit
c169a7613f
|
@ -130,6 +130,13 @@ class CertificateManager {
|
|||
return false
|
||||
}
|
||||
|
||||
public boolean isImported(Certificate certificate) {
|
||||
Set<Certificate> forInfoHash = byInfoHash.get(certificate.infoHash)
|
||||
if (forInfoHash == null)
|
||||
return false
|
||||
forInfoHash.contains(certificate)
|
||||
}
|
||||
|
||||
Set<Certificate> getByInfoHash(InfoHash infoHash) {
|
||||
Set<Certificate> rv = new HashSet<>()
|
||||
if (byInfoHash.containsKey(infoHash))
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.muwire.webui;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
@ -17,6 +18,7 @@ import com.muwire.core.filecert.UICreateCertificateEvent;
|
|||
import com.muwire.core.filecert.UIFetchCertificatesEvent;
|
||||
import com.muwire.core.filecert.UIImportCertificateEvent;
|
||||
|
||||
import net.i2p.data.Base64;
|
||||
import net.i2p.util.ConcurrentHashSet;
|
||||
|
||||
public class CertificateManager {
|
||||
|
|
|
@ -10,6 +10,7 @@ import javax.servlet.http.HttpServlet;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.muwire.core.Core;
|
||||
import com.muwire.core.InfoHash;
|
||||
import com.muwire.core.Persona;
|
||||
import com.muwire.core.filecert.Certificate;
|
||||
|
@ -21,6 +22,7 @@ import net.i2p.data.DataHelper;
|
|||
public class CertificateServlet extends HttpServlet {
|
||||
|
||||
private CertificateManager certificateManager;
|
||||
private Core core;
|
||||
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
|
@ -62,6 +64,7 @@ public class CertificateServlet extends HttpServlet {
|
|||
sb.append("<Comment>").append(Util.escapeHTMLinXML(certificate.getComment().getName())).append("</Comment>");
|
||||
sb.append("<Timestamp>").append(DataHelper.formatTime(certificate.getTimestamp())).append("</Timestamp>");
|
||||
sb.append("<Base64>").append(certificate.toBase64()).append("</Base64>");
|
||||
sb.append("<Imported>").append(core.getCertificateManager().isImported(certificate)).append("</Imported>");
|
||||
sb.append("</Certificate>");
|
||||
}
|
||||
sb.append("</Certificates>");
|
||||
|
@ -129,6 +132,7 @@ public class CertificateServlet extends HttpServlet {
|
|||
@Override
|
||||
public void init(ServletConfig config) throws ServletException {
|
||||
certificateManager = (CertificateManager) config.getServletContext().getAttribute("certificateManager");
|
||||
core = (Core) config.getServletContext().getAttribute("core");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -183,6 +183,7 @@ class Certificate {
|
|||
} catch(ignore) {}
|
||||
this.timestamp = xmlNode.getElementsByTagName("Timestamp")[0].childNodes[0].nodeValue
|
||||
this.base64 = xmlNode.getElementsByTagName("Base64")[0].childNodes[0].nodeValue
|
||||
this.imported = xmlNode.getElementsByTagName("Imported")[0].childNodes[0].nodeValue
|
||||
}
|
||||
|
||||
renderRow() {
|
||||
|
@ -195,6 +196,12 @@ class Certificate {
|
|||
html += "<td>" + this.name + "</td>"
|
||||
html += "<td>" + commentPresent + "</td>"
|
||||
html += "<td>" + this.timestamp + "</td>"
|
||||
|
||||
if (this.imported == "true")
|
||||
html += "<td>" + _t("Imported") + "</td>"
|
||||
else
|
||||
html += "<td>" + _t("Import") + "</td>"
|
||||
|
||||
html += "</tr>"
|
||||
return html
|
||||
}
|
||||
|
@ -221,7 +228,7 @@ class CertificateResponse {
|
|||
html += " "
|
||||
html += _t("Certificates") + " " + this.certificates.length + "/" + this.total
|
||||
|
||||
var headers = [_t("Issuer"), _t("Name"), _t("Comment"), _t("Timestamp")]
|
||||
var headers = [_t("Issuer"), _t("Name"), _t("Comment"), _t("Timestamp"), _t("Import")]
|
||||
html += "<br/>"
|
||||
html += "<table><thead><tr><th>" + headers.join("</th><th>") + "</th></thead><tbody>"
|
||||
var i
|
||||
|
|
Loading…
Reference in New Issue