riconnection.js
Summary
Connector implementing a web service interface for a
Recovation Service using Restricted Identification as per TR-03129
Class Summary
|
RIConnection |
Class implementing a revocation service web service connector
|
function RIConnection(url, isMBS) {
this.url = url;
this.soapcon = new SOAPConnection(SOAPConnection.SOAP11);
this.verbose = true;
this.lastError = null;
this.version = "1.1";
this.isMBS = isMBS;
}
RIConnection.prototype.setVersion = function(version) {
this.version = version;
}
RIConnection.prototype.setTrustAndKeystore = function(truststore, keystore, privateKeyPIN) {
this.truststore = truststore;
this.keystore = keystore;
this.privateKeyPIN = privateKeyPIN;
}
RIConnection.prototype.getLastError = function() {
return this.lastError;
}
RIConnection.prototype.close = function() {
this.soapcon.close();
}
RIConnection.prototype.getSectorPublicKey = function(sectorID) {
this.lastError = null;
if (this.isMBS) {
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 =
<typ:GetSectorPublicKey xmlns:typ={ns}>
<sectorID>{sectorID.toString(BASE64)}</sectorID>
</typ:GetSectorPublicKey>;
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("RIConnection", GPError.DEVICE_ERROR, 0, "getSectorPublicKey failed with : " + e);
}
if (!response.hasOwnProperty("Result")) {
throw new GPError("RIConnection", GPError.DEVICE_ERROR, 0, "Returned SOAP message does not contain expected element Result");
}
}
RIConnection.prototype.getCompleteBlackList = function() {
this.lastError = null;
if (this.isMBS) {
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 = <typ:GetBlackList xmlns:typ={ns}>
<callbackIndicator>callback_not_possible</callbackIndicator>
<messageID>
</messageID>
<deltaIndicator>complete_list</deltaIndicator>
<deltaBase>
</deltaBase>
</typ:GetBlackList>;
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("RIConnection", GPError.DEVICE_ERROR, 0, "getBlackList failed with : " + e);
}
if (!response.hasOwnProperty("Result")) {
throw new GPError("RIConnection", GPError.DEVICE_ERROR, 0, "Returned SOAP message does not contain expected element Result");
}
var xml = new XML(response.Result);
var elementList = xml.elements();
var size = elementList.length();
assert(size == 2);
var returnCode = elementList[0];
print(returnCode.toString());
assert(returnCode.toString().equals("ok_list_available"));
var downloadUrl = elementList[1];
print(downloadUrl);
var xml = new XML(downloadUrl);
var elementList = xml.elements();
var conn = new URLConnection(elementList[0].toString());
if (typeof(this.truststore) != "undefined") {
conn.setTLSKeyStores(this.truststore, this.keystore, this.privateKeyPIN);
}
var bl = conn.getAsByteString();
return(bl);
}
RIConnection.prototype.getDeltaBlackLists = function(deltaBase) {
this.lastError = null;
if (this.isMBS) {
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 = <typ:GetBlackList xmlns:typ={ns} xmlns:ns1={ns1}>
<callbackIndicator>callback_not_possible</callbackIndicator>
<messageID>
</messageID>
<deltaIndicator>delta_list</deltaIndicator>
<deltaBase>
<ns1:deltaBase>{deltaBase.toString()}</ns1:deltaBase>
</deltaBase>
</typ:GetBlackList>;
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("RIConnection", GPError.DEVICE_ERROR, 0, "getBlackList failed with : " + e);
}
if (!response.hasOwnProperty("Result")) {
throw new GPError("RIConnection", GPError.DEVICE_ERROR, 0, "Returned SOAP message does not contain expected element Result");
}
var xml = new XML(response.Result);
var elementList = xml.elements();
var size = elementList.length();
assert(size == 3);
var returnCode = elementList[0];
print(returnCode.toString());
assert(returnCode.toString().equals("ok_list_available"));
var addedItemsElement = elementList[1];
var addedItemsList = addedItemsElement.elements();
var addedItemsBytes = new ByteString(addedItemsList[0], BASE64);
var removedItemsElement = elementList[2];
var removedItemsList = removedItemsElement.elements();
var removedItemsBytes = new ByteString(removedItemsList[0], BASE64);
var bl = new Array(2);
bl[0] = addedItemsBytes;
bl[1] = removedItemsBytes;
return(bl);
}
RIConnection.test = function() {
var ri = new RIConnection("https://localhost:8443/dvsd-local");
var blacklist = ri.getCompleteBlackList();
var deltaLists = ri.getDeltaBlackLists("9000");
}
Documentation generated by
JSDoc on Tue Sep 3 22:29:38 2013