blacklistexplorer.js
Summary
Tool to decode and browse CMS objects
Class Summary
|
BlackListExplorer |
Class providing a simple explorer for CMS objects according to RFC 3852
containing blacklist according to TR-03129, Version 1.0. |
requires("3.6.790");
function BlackListExplorer() {
}
BlackListExplorer.FILESTR = "Open File...";
BlackListExplorer.DUMPSTR = "Dump";
BlackListExplorer.REMOVESTR = "Remove";
BlackListExplorer.loadBinaryFile = function(filename) {
var f = new java.io.FileInputStream(filename);
var flen = f.available();
var bs = java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, flen);
var len = f.read(bs);
var bb = new ByteBuffer(bs);
var data = bb.toByteString();
return data;
}
BlackListExplorer.dumpCMS = function(cms) {
print(new ASN1(cms.bin));
}
BlackListExplorer.prototype.selectFile = function() {
var filename = _scsh3.lastcvc;
if (!filename) {
filename = "";
}
var select = Dialog.prompt("Select file", filename, null, "*.bin");
if (select != null) {
_scsh3.setProperty("lastcms", select.replace(/\\/g, "/"));
var bin = BlackListExplorer.loadBinaryFile(select);
var cms = new CMSSignedData(bin);
var fn = new OutlineNode(select);
fn.cms = cms;
fn.cms.bin = bin;
fn.setContextMenu([BlackListExplorer.DUMPSTR, BlackListExplorer.REMOVESTR]);
fn.setUserObject(this);
this.node.insert(fn);
var certs = cms.getSignedDataCertificates();
var signerCertsNode = new OutlineNode("Number of signer certificates: " + certs.length);
for (i = 0; i < certs.length; i++) {
var cert = certs[i];
var certNode = new OutlineNode(cert.getSubjectDNString());
certNode.insert(new ASN1(cert.getBytes()));
signerCertsNode.insert(certNode);
}
fn.insert(signerCertsNode);
fn.insert(new OutlineNode("Content type OID: " + cms.getEContentType().toString(OID)));
var content = new ASN1(cms.getSignedContent());
var contentNode = new OutlineNode("Signed content");
contentNode.insert(content);
fn.insert(contentNode);
BlackListExplorer.dumpCMS(cms);
}
}
BlackListExplorer.prototype.actionListener = function(source, action) {
switch(action) {
case BlackListExplorer.FILESTR:
this.selectFile();
break;
case BlackListExplorer.DUMPSTR:
BlackListExplorer.dumpCMS(source.cms);
break;
case BlackListExplorer.REMOVESTR:
source.remove();
break;
}
}
BlackListExplorer.prototype.run = function() {
this.node = new OutlineNode("BlackListExplorer");
this.node.setToolTip("Right click to select file");
this.node.setUserObject(this);
this.node.setContextMenu([BlackListExplorer.FILESTR]);
this.node.show();
print("Click with the right mouse button on the \"BlackListExplorer\" entry to select a file");
}
var instance = new BlackListExplorer();
instance.run();
Documentation generated by
JSDoc on Tue Sep 3 22:29:38 2013