br.com.l2software.api.digitalsignature = {
	Proxy: function() {
		this.proxy = new br.com.l2software.api.core.CoreProxy('http://localhost:47557/func/');
	}
};


br.com.l2software.api.digitalsignature.Proxy.prototype.openCert = function(certTipo, certConfPath, certPass, tsaUrl) {
    return this.proxy.remoteCall('l2sSIGNATUREopenCert', {
		certTipo: certTipo,
		certConfPath: certConfPath,
		certPass: certPass,
                tsaUrl: tsaUrl
	});
}

br.com.l2software.api.digitalsignature.Proxy.prototype.signPDF = function(certO, srcPdf, dstPdf, callbackFlow, parametros, serverUrl) {
  if((parametros != null) && (parametros instanceof Map)){
    var listaChaves = parametros.getKeys();          
    var map = {};
    for(var idx in listaChaves){
      var name  = listaChaves[idx];
      var value = parametros.get(name);
      map[name] = value;
    }
    parametros = map;
  } 
  return this.proxy.remoteCall('l2sSIGNATUREsignPDF', {
                certO: certO, 
                srcPdf: srcPdf, 
                dstPdf: dstPdf,
                callbackFlow: callbackFlow,
                parametros: JSON.stringify(parametros),
                serverUrl: serverUrl });
}


br.com.l2software.api.digitalsignature.Proxy.prototype.signCADES = function(certO, srcFile, versao, dstFile, callbackFunc, parametros, serverUrl) {
  if((parametros != null) && (parametros instanceof Map)){
    var listaChaves = parametros.getKeys();          
    var map = {};
    for(var idx in listaChaves){
      var name  = listaChaves[idx];
      var value = parametros.get(name);
      map[name] = value;
    }
    parametros = map;
  } 
  return this.proxy.remoteCallAsync('l2sSIGNATUREsignFileCadesVersao', {
                certO: certO, 
                srcFile: srcFile, 
				versao: versao,
                dstFile: dstFile,
                callbackFlow: callbackFlow,
                parametros: JSON.stringify(parametros),
                serverUrl: serverUrl });
}