paconnection.js
Summary
Connector implementing a web service interface for obtaining Master and Defect Lists from
a Document Verifier or National Public Key Directory (NPKD) as per TR-03129
Class Summary
|
PAConnection |
Class implementing a DV or NPKD web service connector
|
function PAConnection(url, isNPKD) {
this.url = url;
this.soapcon = new SOAPConnection(SOAPConnection.SOAP11);
this.verbose = true;
this.returnCode = null;
this.version = "1.1";
this.isNPKD = isNPKD;
}
PAConnection.prototype.getReturnCode = function() {
return this.returnCode;
}
PAConnection.prototype.setVersion = function(version) {
this.version = version;
}
PAConnection.prototype.close = function() {
this.soapcon.close();
}
PAConnection.prototype.getDefectList = function() {
this.returnCode = null;
if (this.isNPKD) {
var ns = new Namespace("uri:EAC-PKI-CVCA-Protocol/" + this.version);
} else {
var ns = new Namespace("uri:EAC-PKI-DV-Protocol/" + this.version);
}
var ns1 = new Namespace("uri:eacBT/" + this.version);
var request =
<ns:GetDefectList xmlns:ns={ns} xmlns:ns1={ns1}>
<callbackIndicator>callback_not_possible</callbackIndicator>
<messageID>
</messageID>
<responseURL>
</responseURL>
</ns:GetDefectList>;
if (this.verbose) {
GPSystem.trace(request.toXMLString());
}
try {
var response = this.soapcon.call(this.url, request);
if (this.verbose) {
GPSystem.trace(response.toXMLString());
}
}
catch(e) {
GPSystem.trace("SOAP call to " + this.url + " failed : " + e);
throw new GPError("PAConnection", GPError.DEVICE_ERROR, 0, "getDefectList failed with : " + e);
}
if (!response.hasOwnProperty("Result")) {
throw new GPError("PAConnection", GPError.DEVICE_ERROR, 0, "Returned SOAP message does not contain expected element Result");
}
this.returnCode = response.Result.ns1::returnCode.toString();
var defectlist = null;
if (this.returnCode == "ok_list_available") {
defectlist = new ByteString(response.Result.ns1::defectList.ns1::binary.toString(), BASE64);
}
return defectlist;
}
PAConnection.prototype.getMasterList = function() {
this.returnCode = null;
if (this.isNPKD) {
var ns = new Namespace("uri:EAC-PKI-CVCA-Protocol/" + this.version);
} else {
var ns = new Namespace("uri:EAC-PKI-DV-Protocol/" + this.version);
}
var ns1 = new Namespace("uri:eacBT/" + this.version);
var request =
<ns:GetMasterList xmlns:ns={ns} xmlns:ns1={ns1}>
<callbackIndicator>callback_not_possible</callbackIndicator>
<messageID>
</messageID>
<responseURL>
</responseURL>
</ns:GetMasterList>;
if (this.verbose) {
GPSystem.trace(request.toXMLString());
}
try {
var response = this.soapcon.call(this.url, request);
if (this.verbose) {
GPSystem.trace(response.toXMLString());
}
}
catch(e) {
GPSystem.trace("SOAP call to " + this.url + " failed : " + e);
throw new GPError("PAConnection", GPError.DEVICE_ERROR, 0, "getMasterList failed with : " + e);
}
if (!response.hasOwnProperty("Result")) {
throw new GPError("PAConnection", GPError.DEVICE_ERROR, 0, "Returned SOAP message does not contain expected element Result");
}
this.returnCode = response.Result.ns1::returnCode.toString();
var masterlist = null;
if (this.returnCode == "ok_list_available") {
masterlist = new ByteString(response.Result.ns1::masterList.ns1::binary.toString(), BASE64);
}
return masterlist;
}
PAConnection.test = function() {
var c = new PAConnection("http://localhost:8080/se/scs");
c.verbose = true;
var defectlist = c.getDefectList();
}
Documentation generated by
JSDoc on Tue Sep 3 22:29:38 2013