cvcexplorer.js
Summary
Tool to decode and dump CVC certificates
Class Summary
|
CVCExplorer |
Class providing for a simple explorer for CV-Certificates according to EAC specification. |
requires("3.6.733");
load("cvc.js");
function CVCExplorer() {
}
CVCExplorer.FILESTR = "Open File...";
CVCExplorer.DUMPSTR = "Dump";
CVCExplorer.REMOVESTR = "Remove";
CVCExplorer.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;
}
CVCExplorer.dumpCertificate = function(cvc) {
print("-----8<----------8<----------8<----------8<----------8<----------8<----------8<----------8<-----");
print(cvc);
var list = cvc.getRightsAsList();
for (var i = 0; i < list.length; i++) {
print(" " + list[i]);
}
print(cvc.getASN1());
}
CVCExplorer.prototype.selectFile = function() {
var filename = _scsh3.lastcvc;
if (!filename) {
filename = "";
}
var select = Dialog.prompt("Select CVC file", filename, null, "*.cvcert");
if (select != null) {
_scsh3.setProperty("lastcvc", select.replace(/\\/g, "/"));
var bin = CVCExplorer.loadBinaryFile(select);
var cvc = new CVC(bin);
cvc.decorate();
var fn = new OutlineNode(select);
fn.cvc = cvc;
fn.setContextMenu([CVCExplorer.DUMPSTR, CVCExplorer.REMOVESTR]);
fn.setUserObject(this);
this.node.insert(fn);
fn.insert(cvc.getASN1());
CVCExplorer.dumpCertificate(cvc);
}
}
CVCExplorer.prototype.actionListener = function(source, action) {
switch(action) {
case CVCExplorer.FILESTR:
this.selectFile();
break;
case CVCExplorer.DUMPSTR:
CVCExplorer.dumpCertificate(source.cvc);
break;
case CVCExplorer.REMOVESTR:
source.remove();
break;
}
}
CVCExplorer.prototype.run = function() {
this.node = new OutlineNode("CVCExplorer");
this.node.setToolTip("Right click to select file");
this.node.setUserObject(this);
this.node.setContextMenu([CVCExplorer.FILESTR]);
this.node.show();
print("Click with the right mouse button on the \"CVCExplorer\" entry to select a file");
}
var instance = new CVCExplorer();
instance.run();
Documentation generated by
JSDoc on Tue Sep 3 22:29:38 2013