You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Carol Chamblas <ca...@gmail.com> on 2005/05/26 04:30:47 UTC
sign Files using Aladdin's eToken USB Pro
i had configured tomcat to use secure connections (https), and i've included
the root certificated from my CA in the cacerts file from JAVA_HOME.
so, i've also installed the drivers from my eToken, and when i load my page
with https, the certificated stored in my eToken is shown.
when i choose it. it ask me for the password, and after i put it, the
servlet in the other side sees the certificate without problems
the question is, how do i use or obtain the private key stored in the
eToken??
here is the code that i'm using
XMLSignature sig = *new* XMLSignature(XMLDoc, BaseURI,
XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1 );
NodeList nl = XMLDoc.getElementsByTagName("Content");
*if* (nl.getLength() < 1)
{
System.out.println("firmar::no hay nodo Content??");
*return* *false*;
}
(nl.item(0)).appendChild(sig.getElement());
{
String Id = "S" + (firmantes.size() + 1);
Transforms transforms = *new* Transforms(XMLDoc);
transforms.addTransform(Transforms.TRANSFORM_C14N_OMIT_COMMENTS);
sig.addDocument(BaseURI, transforms,
Constants.ALGO_ID_DIGEST_SHA1);
sig.setId(Id);
}
sig.addKeyInfo(cert);
sig.addKeyInfo(cert.getPublicKey());
System.out.println("Start signing");
sig.sign(privateKey);
System.out.println("Finished signing");
--
"Nada es imposible,
hasta que se demuestre lo contrario" - yo