Signing a Document: Step 1. Create the Signer Object

XMLSignatureFactory factory = XMLSignatureFactory.getInstance("DOM");

DigestMethod sha1 = factory.newDigestMethod(DigestMethod.SHA1, null);
CanonicalizationMethod inclusive = factory.newCanonicalizationMethod
 (CanonicalizationMethod.INCLUSIVE, (C14NMethodParameterSpec) null);
SignatureMethod rsasha1 
 = factory.newSignatureMethod(SignatureMethod.RSA_SHA1, null);

Transform enveloped = factory.newTransform
  (Transform.ENVELOPED, (TransformParameterSpec) null));
List transforms = Collections.singletonList(enveloped);

// empty string means sign the current, complete document
Reference ref = factory.newReference("", sha1, transforms);
List references = Collections.singletonList(ref);

SignedInfo signer = factory.newSignedInfo(inclusive, rsasha1, references);

Previous | Next | Top | Cafe con Leche

Copyright 2007 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified March 12, 2007