xml-security-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anderson Jonathan" <anderson_jonat...@bah.com>
Subject Verify signature references against a set of required elements?
Date Fri, 27 Feb 2004 00:42:27 GMT
Greetings,
	I'm curious - is there an efficient way to verify signature references
against a set of required elements?  I'm trying to write some code that
enforces signature "coverage," and I'm struggling to find an elegant way to
do it.  Here's what I've got so far:

List coveredElementNodes = new ArrayList();
for (int i=0; i < sig.getSignedInfo().getLength(); i++)
{
    Reference ref = sig.getSignedInfo().item(i);
    XMLSignatureInput input = ref.getContentsBeforeTransformation();
    Set nodes = input.getNodeSet();
    for (Iterator iterator = nodes.iterator(); iterator.hasNext();)
    {
        Node node = (Node) iterator.next();
        if (node.getNodeType() == Node.ELEMENT_NODE)
        {
            coveredElementNodes.add(node);
        }
    }
}

And then I simply do a coverElementNodes.contains() for every Element in the
DOM that I want to ensure has been signed.  It's ugly, it's inefficient, and
I'm curious - is there a better way?

Any and all feedback would be appreciated (including "wow, that is some ugly
code you've got there" comments).  :)  Thanks in advance.

	-Jon



Mime
View raw message