121 lines
3.1 KiB
HTML
121 lines
3.1 KiB
HTML
|
|
<html>
|
||
|
|
<head>
|
||
|
|
<link href="HermesFDA.css" type="text/css" rel="stylesheet" />
|
||
|
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||
|
|
</head>
|
||
|
|
<body>
|
||
|
|
|
||
|
|
<script type="text/javascript" src="HermesFDAParams.js"></script>
|
||
|
|
<script type="text/javascript" src="HermesFDA.js"></script>
|
||
|
|
|
||
|
|
<center><h1>HermesFDA plugin test page</h1></center>
|
||
|
|
<br> <br>
|
||
|
|
<table>
|
||
|
|
<tr valign="top">
|
||
|
|
<td width="400px">
|
||
|
|
<div id="Paso1" style="text-align:center;">
|
||
|
|
<input type=button value="Empezar" onclick="ObtenerCertificados(hermesFDAPlugin)"/>
|
||
|
|
</div>
|
||
|
|
<div id="Paso2" style="display:none">
|
||
|
|
Seleccione un certificado:<br/>
|
||
|
|
<select id="Certificados" size="1"></select><br/>
|
||
|
|
<input type=button value="Firmar" onclick="ObtenerCertificados(hermesFDAPlugin)"/>
|
||
|
|
</div>
|
||
|
|
<div id="Paso3" style="display:none">
|
||
|
|
<p>Certificado:</p>
|
||
|
|
<div id="Certificado"></div>
|
||
|
|
<p>Firma:</p>
|
||
|
|
<div id="Firma"></div>
|
||
|
|
<input type=button value="Limpiar" onclick="Limpiar()"/>
|
||
|
|
</div>
|
||
|
|
</td>
|
||
|
|
<td>
|
||
|
|
<div id="hermesFDAPluginContainer"></div>
|
||
|
|
</td>
|
||
|
|
</tr>
|
||
|
|
</table>
|
||
|
|
|
||
|
|
<script>
|
||
|
|
|
||
|
|
var hermesFDAPlugin = new HermesFDAPlugin("hermesFDAPluginContainer");
|
||
|
|
|
||
|
|
hermesFDAPlugin.render();
|
||
|
|
|
||
|
|
hermesFDAPlugin.onPinReady = ObtenerCertificados;
|
||
|
|
|
||
|
|
function ObtenerCertificados(hermesFDAPlugin)
|
||
|
|
{
|
||
|
|
|
||
|
|
document.getElementById("Paso1").style.display = "none";
|
||
|
|
if (!hermesFDAPlugin.isInstalled())
|
||
|
|
{
|
||
|
|
alert("Primero tiene que instalar el plugin de firma\ndigitalpara poder firmar digitalmente");
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (!hermesFDAPlugin.isUpdated())
|
||
|
|
{
|
||
|
|
alert("Primero tiene que actualizar el plugin de firma\ndigitalpara poder firmar digitalmente");
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (hermesFDAPlugin.pinNeeded())
|
||
|
|
{
|
||
|
|
alert("Debe introducir el pin para '"+hermesFDAPlugin.pinModuleName()+"'. Debe tener por lo menos "+HFDAMinPinLength+" digitos");
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
// llenar lista de certificados
|
||
|
|
|
||
|
|
var select = document.getElementById("Certificados");
|
||
|
|
|
||
|
|
if ( select.options.length == 0)
|
||
|
|
{
|
||
|
|
hermesFDAPlugin.fillSelectWithDigitalSignatureCertificates(select);
|
||
|
|
if (select.options.length>0)
|
||
|
|
{
|
||
|
|
document.getElementById("Paso2").style.display = "block";
|
||
|
|
}
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
// mostrar certificados en base64
|
||
|
|
result = hermesFDAPlugin.getCertificate(select.value);
|
||
|
|
if (hermesFDAPlugin.lastError != '')
|
||
|
|
{
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
document.getElementById("Certificado").innerHTML = result;
|
||
|
|
// realizar firma digital
|
||
|
|
|
||
|
|
result = hermesFDAPlugin.signPkcs1(select.value,"ZRM62kxYc2mISkSnTs4MBiWQWr0=");
|
||
|
|
if (hermesFDAPlugin.lastError != '')
|
||
|
|
{
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
document.getElementById("Paso2").style.display = "none";
|
||
|
|
|
||
|
|
document.getElementById("Paso3").style.display = "block";
|
||
|
|
|
||
|
|
document.getElementById("Firma").innerHTML = result;
|
||
|
|
hermesFDAPlugin.setPin("");
|
||
|
|
}
|
||
|
|
|
||
|
|
function Limpiar()
|
||
|
|
{
|
||
|
|
document.getElementById("Paso1").style.display = "block";
|
||
|
|
document.getElementById("Paso2").style.display = "none";
|
||
|
|
document.getElementById("Paso3").style.display = "none";
|
||
|
|
|
||
|
|
document.getElementById("Certificados").innerHTML = "";
|
||
|
|
document.getElementById("Certificado").innerHTML = "";
|
||
|
|
document.getElementById("Firma").innerHTML = "";
|
||
|
|
}
|
||
|
|
|
||
|
|
</script>
|
||
|
|
|
||
|
|
</html>
|
||
|
|
</body>
|
||
|
|
|