/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 1999-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
/**
* Purpose of this class is to enable the XML Parser to keep track of ID
* attributes. This is done by 'registering' attributes of type ID at the
* IdResolver. This is necessary if we create a document from scratch and we
* sign some resources with a URI using a fragent identifier...
* <BR />
* The problem is that if you do not validate a document, you cannot use the
* <CODE>getElementByID</CODE> functionality. So this modules uses some implicit
* knowledge on selected Schemas and DTDs to pick the right Element for a given
* ID: We know that all <CODE>@Id</CODE> attributes in an Element from the XML
* Signature namespace are of type <CODE>ID</CODE>.
*
* @author $Author: mullan $
* @see <A HREF="http://www.xml.com/lpt/a/2001/11/07/id.html">"Identity Crisis" on xml.com</A>
*/
public class IdResolver {
/** {@link java.util.logging} logging facility */
/**
* Constructor IdResolver
*
*/
private IdResolver() {
// we don't allow instantiation
}
/**
* Method registerElementById
*
* @param element the element to register
* @param idValue the value of the ID attribute
*/
synchronized (docMap) {
if (elementMap == null) {
elementMap = new WeakHashMap();
}
}
}
/**
* Method registerElementById
*
* @param element the element to register
* @param id the ID attribute
*/
}
/**
* Method getElementById
*
* @param doc the document
* @param id the value of the ID
* @return the element obtained by the id, or null if it is not found.
*/
"I could find an Element using the simple getElementByIdType method: "
+ result.getTagName());
return result;
}
"I could find an Element using the simple getElementByIdUsingDOM method: "
+ result.getTagName());
return result;
}
// this must be done so that Xalan can catch ALL namespaces
//XMLUtils.circumventBug2650(doc);
return result;
}
return null;
}
/**
* Method getElementByIdUsingDOM
*
* @param doc the document
* @param id the value of the ID
* @return the element obtained by the id, or null if it is not found.
*/
}
/**
* Method getElementByIdType
*
* @param doc the document
* @param id the value of the ID
* @return the element obtained by the id, or null if it is not found.
*/
synchronized (docMap) {
}
if (elementMap != null) {
if (weakReference != null) {
}
}
return null;
}
private static int namesLength;
static {
String namespaces[]={
"urn:oasis:names:tc:SAML:1.0:assertion",
"urn:oasis:names:tc:SAML:1.0:protocol"
};
}
return els[i];
}
}
return null;
}
do {
switch (currentNode.getNodeType()) {
case Node.DOCUMENT_FRAGMENT_NODE :
case Node.DOCUMENT_NODE :
break;
case Node.ELEMENT_NODE :
return 1;
if (parentNode != null) {
}
} else {
}
break;
}
}
return 1;
} while(true);
}
if (!el.hasAttributes()) {
return 0;
}
String s=n.getNamespaceURI();
continue;
if (index==0) {
return 1;
}
if (index!=3) {
}
}
if (index!=2) {
}
}
}
//For an element namespace search for importants
if ((elementIndex==3)&&(
} else if ((elementIndex==4)&&(
} else if ((elementIndex==5)&&(
}
return 0;
}
}