transforms, Constants.ALGO_ID_DIGEST_SHA1);
}
{
Transforms transforms = new Transforms(doc);
XPathContainer xpathC = new XPathContainer(doc);
xpathC.setXPath("self::text()");
transforms.addTransform(Transforms.TRANSFORM_XPATH,
xpathC.getElementPlusReturns());
sig.addDocument("#object-1", transforms,
Constants.ALGO_ID_DIGEST_SHA1, null,
"http://www.w3.org/2000/09/xmldsig#Object");
}
/*
{
Transforms transforms = new Transforms(doc);
XPathContainer xpathC = new XPathContainer(doc);
//J-
xpathC.setXPathNamespaceContext("ds", Constants.SignatureSpecNS);
xpathC.setXPath("\n"
+ " ancestor-or-self::ds:SignedInfo " + "\n"
+ " and " + "\n"
+ " count(ancestor-or-self::ds:Reference | " + "\n"
+ " here()/ancestor::ds:Reference[1]) > " + "\n"
+ " count(ancestor-or-self::ds:Reference) " + "\n"
+ " or " + "\n"
+ " count(ancestor-or-self::node() | " + "\n"
+ " id('notaries')) = " + "\n"
+ " count(ancestor-or-self::node()) " + "\n");
//J+
transforms.addTransform(Transforms.TRANSFORM_XPATH,
xpathC.getElementPlusReturns());
sig.addDocument("", transforms, Constants.ALGO_ID_DIGEST_SHA1, null,
"http://www.w3.org/2000/09/xmldsig#Object");
}
*/
{
Transforms transforms = new Transforms(doc);
transforms.addTransform(Transforms.TRANSFORM_BASE64_DECODE);
sig.addDocument("#object-2", transforms,
Constants.ALGO_ID_DIGEST_SHA1, null,
"http://www.w3.org/2000/09/xmldsig#Object");
}
sig.addDocument("#manifest-1", null, Constants.ALGO_ID_DIGEST_SHA1, null,
"http://www.w3.org/2000/09/xmldsig#Manifest");
sig.addDocument("#signature-properties-1", null,
Constants.ALGO_ID_DIGEST_SHA1, null,
"http://www.w3.org/2000/09/xmldsig#SignatureProperties");
{
Transforms transforms = new Transforms(doc);
transforms.addTransform(Transforms.TRANSFORM_ENVELOPED_SIGNATURE);
sig.addDocument("", transforms, Constants.ALGO_ID_DIGEST_SHA1);
}
{
Transforms transforms = new Transforms(doc);
transforms.addTransform(Transforms.TRANSFORM_ENVELOPED_SIGNATURE);
transforms.addTransform(Transforms.TRANSFORM_C14N_WITH_COMMENTS);
sig.addDocument("", transforms, Constants.ALGO_ID_DIGEST_SHA1);
}
{
Transforms transforms = new Transforms(doc);
transforms.addTransform(Transforms.TRANSFORM_ENVELOPED_SIGNATURE);
sig.addDocument("#xpointer(/)", transforms,
Constants.ALGO_ID_DIGEST_SHA1);
}
{
Transforms transforms = new Transforms(doc);
transforms.addTransform(Transforms.TRANSFORM_ENVELOPED_SIGNATURE);
transforms.addTransform(Transforms.TRANSFORM_C14N_WITH_COMMENTS);
sig.addDocument("#xpointer(/)", transforms,
Constants.ALGO_ID_DIGEST_SHA1);
}
{
sig.addDocument("#object-3", null, Constants.ALGO_ID_DIGEST_SHA1,
null, "http://www.w3.org/2000/09/xmldsig#Object");
}
{
Transforms transforms = new Transforms(doc);
transforms.addTransform(Transforms.TRANSFORM_C14N_WITH_COMMENTS);
sig.addDocument("#object-3", transforms,
Constants.ALGO_ID_DIGEST_SHA1, null,
"http://www.w3.org/2000/09/xmldsig#Object");
}
{
sig.addDocument("#xpointer(id('object-3'))", null,
Constants.ALGO_ID_DIGEST_SHA1, null,
"http://www.w3.org/2000/09/xmldsig#Object");
}
{
Transforms transforms = new Transforms(doc);
transforms.addTransform(Transforms.TRANSFORM_C14N_WITH_COMMENTS);
sig.addDocument("#xpointer(id('object-3'))", transforms,
Constants.ALGO_ID_DIGEST_SHA1, null,
"http://www.w3.org/2000/09/xmldsig#Object");
}
{
sig.addDocument("#manifest-reference-1", null,
Constants.ALGO_ID_DIGEST_SHA1, "reference-1",
"http://www.w3.org/2000/09/xmldsig#Reference");
}
{
sig.addDocument("#reference-1", null,
Constants.ALGO_ID_DIGEST_SHA1, "reference-2",
"http://www.w3.org/2000/09/xmldsig#Reference");
}
{
sig.addDocument("#reference-2", null,
Constants.ALGO_ID_DIGEST_SHA1, null,
"http://www.w3.org/2000/09/xmldsig#Reference");
}
/*
* Add KeyInfo and sign()
*/
{
Transforms retrievalTransforms = new Transforms(doc);
XPathContainer xpathC = new XPathContainer(doc);
xpathC.setXPathNamespaceContext("ds", Constants.SignatureSpecNS);
xpathC.setXPath("ancestor-or-self::ds:X509Data");
retrievalTransforms.addTransform(Transforms.TRANSFORM_XPATH,
xpathC.getElement());
sig.getKeyInfo().add(
new RetrievalMethod(
doc, "#object-4", retrievalTransforms,
"http://www.w3.org/2000/09/xmldsig#X509Data"));