* @throws JDOMException if elements cannot be parsed correctly
*/
public boolean isConstrained( String url, Role role ) throws JDOMException
{
Element root = m_webxml.getRootElement();
XPath xpath;
String selector;
// Get all constraints that have our URL pattern
// (Note the crazy j: prefix to denote the 2.4 j2ee schema)
selector = "//j:web-app/j:security-constraint[j:web-resource-collection/j:url-pattern=\"" + url + "\"]";
xpath = XPath.newInstance( selector );
xpath.addNamespace( "j", J2EE_SCHEMA_24_NAMESPACE );
List<?> constraints = xpath.selectNodes( root );
// Get all constraints that match our Role pattern
selector = "//j:web-app/j:security-constraint[j:auth-constraint/j:role-name=\"" + role.getName() + "\"]";
xpath = XPath.newInstance( selector );
xpath.addNamespace( "j", J2EE_SCHEMA_24_NAMESPACE );
List<?> roles = xpath.selectNodes( root );
// If we can't find either one, we must not be constrained
if ( constraints.size() == 0 )
{
return false;