Example usage for org.w3c.dom Node getLocalName

List of usage examples for org.w3c.dom Node getLocalName

Introduction

In this page you can find the example usage for org.w3c.dom Node getLocalName.

Prototype

public String getLocalName();

Source Link

Document

Returns the local part of the qualified name of this node.

Usage

From source file:org.apache.openaz.xacml.pdp.policy.dom.DOMMatch.java

public static boolean repair(Node nodeMatch) throws DOMStructureException {
    Element elementMatch = DOMUtil.getElement(nodeMatch);
    boolean result = false;

    NodeList children = elementMatch.getChildNodes();
    int numChildren;
    boolean sawAttributeRetrievalBase = false;
    boolean sawAttributeValue = false;

    if (children != null && (numChildren = children.getLength()) > 0) {
        for (int i = 0; i < numChildren; i++) {
            Node child = children.item(i);
            if (DOMUtil.isElement(child)) {
                if (DOMUtil.isInNamespace(child, XACML3.XMLNS)) {
                    String childName = child.getLocalName();
                    if (XACML3.ELEMENT_ATTRIBUTEVALUE.equals(childName)) {
                        if (sawAttributeValue) {
                            logger.warn("Unexpected element " + child.getNodeName());
                            elementMatch.removeChild(child);
                            result = true;
                        } else {
                            result = DOMAttributeValue.repair(child) || result;
                            sawAttributeValue = true;
                        }//from   w  w  w  .  j a v a 2  s  .  co  m
                    } else if (XACML3.ELEMENT_ATTRIBUTEDESIGNATOR.equals(childName)) {
                        if (sawAttributeRetrievalBase) {
                            logger.warn("Unexpected element " + child.getNodeName());
                            elementMatch.removeChild(child);
                            result = true;
                        } else {
                            result = DOMAttributeDesignator.repair(child) || result;
                            sawAttributeRetrievalBase = true;
                        }
                    } else if (XACML3.ELEMENT_ATTRIBUTESELECTOR.equals(childName)) {
                        if (sawAttributeRetrievalBase) {
                            logger.warn("Unexpected element " + child.getNodeName());
                            elementMatch.removeChild(child);
                            result = true;
                        } else {
                            result = DOMAttributeSelector.repair(child) || result;
                            sawAttributeRetrievalBase = true;
                        }
                    } else {
                        logger.warn("Unexpected element " + child.getNodeName());
                        elementMatch.removeChild(child);
                        result = true;
                    }
                } else {
                    logger.warn("Unexpected element " + child.getNodeName());
                    elementMatch.removeChild(child);
                    result = true;
                }
            }
        }
    }

    /*
     * We have to see exactly one of these
     */
    if (!sawAttributeRetrievalBase) {
        throw DOMUtil.newMissingElementException(nodeMatch, XACML3.XMLNS,
                XACML3.ELEMENT_ATTRIBUTEDESIGNATOR + " or " + XACML3.ELEMENT_ATTRIBUTESELECTOR);
    } else if (!sawAttributeValue) {
        throw DOMUtil.newMissingElementException(nodeMatch, XACML3.XMLNS, XACML3.ELEMENT_ATTRIBUTEVALUE);
    }
    result = DOMUtil.repairIdentifierAttribute(elementMatch, XACML3.ATTRIBUTE_MATCHID, logger) || result;

    return result;
}

From source file:org.apache.openaz.xacml.pdp.policy.dom.DOMObligationExpression.java

/**
 * Creates a new <code>ObligationExpression</code> by parsing the given <code>Node</code> representing a
 * XACML ObligationExpression element.//from   w  w w .  ja va 2 s.co  m
 *
 * @param nodeObligationExpression the <code>Node</code> representing the XACML ObligationExpression
 *            element
 * @param policy the {@link org.apache.openaz.xacml.pdp.policy.Policy} encompassing the
 *            ObligationExpression element
 * @return a new <code>ObligationExpression</code> parsed from the given <code>Node</code>
 * @throws DOMStructureException if there is an error parsing the <code>Node</code>
 */
public static ObligationExpression newInstance(Node nodeObligationExpression, Policy policy)
        throws DOMStructureException {
    Element elementObligationExpression = DOMUtil.getElement(nodeObligationExpression);
    boolean bLenient = DOMProperties.isLenient();

    DOMObligationExpression domObligationExpression = new DOMObligationExpression();

    try {
        NodeList children = elementObligationExpression.getChildNodes();
        int numChildren;
        if (children != null && (numChildren = children.getLength()) > 0) {
            for (int i = 0; i < numChildren; i++) {
                Node child = children.item(i);
                if (DOMUtil.isElement(child)) {
                    if (DOMUtil.isInNamespace(child, XACML3.XMLNS)
                            && XACML3.ELEMENT_ATTRIBUTEASSIGNMENTEXPRESSION.equals(child.getLocalName())) {
                        domObligationExpression.addAttributeAssignmentExpression(
                                DOMAttributeAssignmentExpression.newInstance(child, policy));
                    } else if (!bLenient) {
                        throw DOMUtil.newUnexpectedElementException(child, nodeObligationExpression);
                    }
                }
            }
        }

        domObligationExpression.setObligationId(DOMUtil.getIdentifierAttribute(elementObligationExpression,
                XACML3.ATTRIBUTE_OBLIGATIONID, !bLenient));

        String string = DOMUtil.getStringAttribute(elementObligationExpression, XACML3.ATTRIBUTE_FULFILLON,
                !bLenient);
        RuleEffect ruleEffectType = RuleEffect.getRuleEffect(string);
        if (ruleEffectType == null) {
            if (!bLenient) {
                throw new DOMStructureException(nodeObligationExpression, "Invalid EffectType \"" + string
                        + "\" in \"" + DOMUtil.getNodeLabel(nodeObligationExpression) + "\"");
            }
        } else {
            domObligationExpression.setRuleEffect(ruleEffectType);
        }
    } catch (DOMStructureException ex) {
        domObligationExpression.setStatus(StdStatusCode.STATUS_CODE_SYNTAX_ERROR, ex.getMessage());
        if (DOMProperties.throwsExceptions()) {
            throw ex;
        }
    }
    return domObligationExpression;
}

From source file:org.apache.openaz.xacml.pdp.policy.dom.DOMObligationExpression.java

public static boolean repair(Node nodeObligationExpression) throws DOMStructureException {
    Element elementObligationExpression = DOMUtil.getElement(nodeObligationExpression);
    boolean result = false;

    NodeList children = elementObligationExpression.getChildNodes();
    int numChildren;
    if (children != null && (numChildren = children.getLength()) > 0) {
        for (int i = 0; i < numChildren; i++) {
            Node child = children.item(i);
            if (DOMUtil.isElement(child)) {
                if (DOMUtil.isInNamespace(child, XACML3.XMLNS)
                        && XACML3.ELEMENT_ATTRIBUTEASSIGNMENTEXPRESSION.equals(child.getLocalName())) {
                    result = DOMAttributeAssignmentExpression.repair(child) || result;
                } else {
                    logger.warn("Unexpected element " + child.getNodeName());
                    elementObligationExpression.removeChild(child);
                    result = true;//from w  w  w  . ja v  a 2  s . co m
                }
            }
        }
    }

    result = DOMUtil.repairIdentifierAttribute(elementObligationExpression, XACML3.ATTRIBUTE_OBLIGATIONID,
            logger) || result;
    result = DOMUtil.repairStringAttribute(elementObligationExpression, XACML3.ATTRIBUTE_FULFILLON,
            RuleEffect.DENY.getName(), logger) || result;

    String string = DOMUtil.getStringAttribute(elementObligationExpression, XACML3.ATTRIBUTE_FULFILLON);
    RuleEffect ruleEffectType = RuleEffect.getRuleEffect(string);
    if (ruleEffectType == null) {
        logger.warn("Setting invalid RuleEffect " + string + " to " + RuleEffect.DENY.getName());
        elementObligationExpression.setAttribute(XACML3.ATTRIBUTE_FULFILLON, RuleEffect.DENY.getName());
        result = true;
    }

    return result;
}

From source file:org.apache.openaz.xacml.pdp.policy.dom.DOMObligationExpression.java

/**
 * Creates a <code>List</code> of <code>ObligationExpression</code>s by parsing the given
 * <code>Node</code> representing a XACML ObligationExpressions element.
 *
 * @param nodeObligationExpressions the <code>Node</code> representing the XACML ObligationExpressions
 *            element//  w  w w .ja  v a 2s  . c  o m
 * @param policy the <code>Policy</code> encompassing the ObligationExpressions element
 * @return a new <code>List</code> of <code>ObligationExpression</code>s parsed from the given
 *         <code>Node</code>
 * @throws DOMStructureException if there is an error parsing the <code>Node</code>
 */
public static List<ObligationExpression> newList(Node nodeObligationExpressions, Policy policy)
        throws DOMStructureException {
    Element elementObligationExpressions = DOMUtil.getElement(nodeObligationExpressions);
    boolean bLenient = DOMProperties.isLenient();

    List<ObligationExpression> listObligationExpressions = new ArrayList<ObligationExpression>();

    NodeList children = elementObligationExpressions.getChildNodes();
    int numChildren;
    if (children != null && (numChildren = children.getLength()) > 0) {
        for (int i = 0; i < numChildren; i++) {
            Node child = children.item(i);
            if (DOMUtil.isElement(child)) {
                if (DOMUtil.isInNamespace(child, XACML3.XMLNS)
                        && XACML3.ELEMENT_OBLIGATIONEXPRESSION.equals(child.getLocalName())) {
                    listObligationExpressions.add(DOMObligationExpression.newInstance(child, policy));
                } else if (!bLenient) {
                    throw DOMUtil.newUnexpectedElementException(child, elementObligationExpressions);
                }
            }
        }
    }

    if (listObligationExpressions.size() == 0 && !bLenient) {
        throw DOMUtil.newMissingElementException(elementObligationExpressions, XACML3.XMLNS,
                XACML3.ELEMENT_OBLIGATIONEXPRESSION);
    }

    return listObligationExpressions;
}

From source file:org.apache.openaz.xacml.pdp.policy.dom.DOMObligationExpression.java

public static boolean repairList(Node nodeObligationExpressions) throws DOMStructureException {
    Element elementObligationExpressions = DOMUtil.getElement(nodeObligationExpressions);
    boolean result = false;

    boolean sawObligationExpression = false;
    NodeList children = elementObligationExpressions.getChildNodes();
    int numChildren;
    if (children != null && (numChildren = children.getLength()) > 0) {
        for (int i = 0; i < numChildren; i++) {
            Node child = children.item(i);
            if (DOMUtil.isElement(child)) {
                if (DOMUtil.isInNamespace(child, XACML3.XMLNS)
                        && XACML3.ELEMENT_OBLIGATIONEXPRESSION.equals(child.getLocalName())) {
                    result = DOMObligationExpression.repair(child) || result;
                    sawObligationExpression = true;
                } else {
                    logger.warn("Unexpected element " + child.getNodeName());
                    elementObligationExpressions.removeChild(child);
                    result = true;//  ww  w  .  jav a 2 s . c o  m
                }
            }
        }
    }
    if (!sawObligationExpression) {
        throw DOMUtil.newMissingElementException(elementObligationExpressions, XACML3.XMLNS,
                XACML3.ELEMENT_OBLIGATIONEXPRESSION);
    }

    return result;
}

From source file:org.apache.openaz.xacml.pdp.policy.dom.DOMPolicy.java

/**
 * Creates a new <code>DOMPolicy</code> by parsing the given <code>Node</code> representing a XACML Policy
 * element./*from  ww w. ja v a  2s. co m*/
 *
 * @param nodePolicy the <code>Node</code> representing the Policy element
 * @param policyDefaultsParent the <code>PolicyDefaults</code> of the parent element of the Policy element
 *            or null if this is the root
 * @return a new <code>DOMPolicy</code> parsed from the given <code>Node</code>
 * @throws DOMStructureException if there is an error parsing the <code>Node</code>
 */
public static Policy newInstance(Node nodePolicy, PolicySet policySetParent,
        PolicyDefaults policyDefaultsParent) throws DOMStructureException {
    Element elementPolicy = DOMUtil.getElement(nodePolicy);
    boolean bLenient = DOMProperties.isLenient();

    Policy domPolicy = new Policy(policySetParent);

    Identifier identifier;
    Integer integer;
    Iterator<?> iterator;

    try {
        NodeList children = elementPolicy.getChildNodes();
        int numChildren;
        if (children != null && (numChildren = children.getLength()) > 0) {
            /*
             * Run through once, quickly, to set the PolicyDefaults for the new DOMPolicySet
             */
            for (int i = 0; i < numChildren; i++) {
                Node child = children.item(i);
                if (DOMUtil.isNamespaceElement(child, XACML3.XMLNS)
                        && XACML3.ELEMENT_POLICYDEFAULTS.equals(child.getLocalName())) {
                    if (domPolicy.getPolicyDefaults() != null && !bLenient) {
                        throw DOMUtil.newUnexpectedElementException(child, nodePolicy);
                    }
                    domPolicy.setPolicyDefaults(DOMPolicyDefaults.newInstance(child, policyDefaultsParent));
                }
            }
            if (domPolicy.getPolicyDefaults() == null) {
                domPolicy.setPolicyDefaults(policyDefaultsParent);
            }

            for (int i = 0; i < numChildren; i++) {
                Node child = children.item(i);
                if (DOMUtil.isElement(child) && DOMUtil.isInNamespace(child, XACML3.XMLNS)) {
                    String childName = child.getLocalName();
                    if (XACML3.ELEMENT_DESCRIPTION.equals(childName)) {
                        if (domPolicy.getDescription() != null && !bLenient) {
                            throw DOMUtil.newUnexpectedElementException(child, nodePolicy);
                        }
                        domPolicy.setDescription(child.getTextContent());
                    } else if (XACML3.ELEMENT_POLICYISSUER.equals(childName)) {
                        if (domPolicy.getPolicyIssuer() != null && !bLenient) {
                            throw DOMUtil.newUnexpectedElementException(child, nodePolicy);
                        }
                        domPolicy.setPolicyIssuer(DOMPolicyIssuer.newInstance(child));
                    } else if (XACML3.ELEMENT_POLICYDEFAULTS.equals(childName)) { //NOPMD
                        // TODO
                    } else if (XACML3.ELEMENT_TARGET.equals(childName)) {
                        if (domPolicy.getTarget() != null && !bLenient) {
                            throw DOMUtil.newUnexpectedElementException(child, nodePolicy);
                        }
                        domPolicy.setTarget(DOMTarget.newInstance(child));
                    } else if (XACML3.ELEMENT_COMBINERPARAMETERS.equals(childName)) {
                        domPolicy.addCombinerParameters(DOMCombinerParameter.newList(child));
                    } else if (XACML3.ELEMENT_RULECOMBINERPARAMETERS.equals(childName)) {
                        domPolicy.addRuleCombinerParameter(DOMRuleCombinerParameters.newInstance(child));
                    } else if (XACML3.ELEMENT_VARIABLEDEFINITION.equals(childName)) {
                        domPolicy.addVariableDefinition(DOMVariableDefinition.newInstance(child, domPolicy));
                    } else if (XACML3.ELEMENT_RULE.equals(childName)) {
                        domPolicy.addRule(DOMRule.newInstance(child, domPolicy));
                    } else if (XACML3.ELEMENT_OBLIGATIONEXPRESSIONS.equals(childName)) {
                        if ((iterator = domPolicy.getObligationExpressions()) != null && iterator.hasNext()
                                && !bLenient) {
                            throw DOMUtil.newUnexpectedElementException(child, nodePolicy);
                        }
                        domPolicy.setObligationExpressions(DOMObligationExpression.newList(child, domPolicy));
                    } else if (XACML3.ELEMENT_ADVICEEXPRESSIONS.equals(childName)) {
                        if ((iterator = domPolicy.getAdviceExpressions()) != null && iterator.hasNext()
                                && !bLenient) {
                            throw DOMUtil.newUnexpectedElementException(child, nodePolicy);
                        }
                        domPolicy.setAdviceExpressions(DOMAdviceExpression.newList(child, domPolicy));
                    } else if (!bLenient) {
                        throw DOMUtil.newUnexpectedElementException(child, nodePolicy);
                    }
                }
            }
        }
        domPolicy.setIdentifier(
                DOMUtil.getIdentifierAttribute(elementPolicy, XACML3.ATTRIBUTE_POLICYID, !bLenient));
        domPolicy.setVersion(DOMUtil.getVersionAttribute(elementPolicy, XACML3.ATTRIBUTE_VERSION, !bLenient));

        identifier = DOMUtil.getIdentifierAttribute(elementPolicy, XACML3.ATTRIBUTE_RULECOMBININGALGID,
                !bLenient);
        CombiningAlgorithm<Rule> combiningAlgorithmRule = null;
        try {
            combiningAlgorithmRule = CombiningAlgorithmFactory.newInstance()
                    .getRuleCombiningAlgorithm(identifier);
        } catch (FactoryException ex) {
            if (!bLenient) {
                throw new DOMStructureException("Failed to get CombiningAlgorithm", ex);
            }
        }
        if (combiningAlgorithmRule == null && !bLenient) {
            throw new DOMStructureException(elementPolicy, "Unknown rule combining algorithm \""
                    + identifier.toString() + "\" in \"" + DOMUtil.getNodeLabel(nodePolicy));
        } else {
            domPolicy.setRuleCombiningAlgorithm(combiningAlgorithmRule);
        }

        if ((integer = DOMUtil.getIntegerAttribute(elementPolicy,
                XACML3.ATTRIBUTE_MAXDELEGATIONDEPTH)) != null) {
            domPolicy.setMaxDelegationDepth(integer);
        }
    } catch (DOMStructureException ex) {
        domPolicy.setStatus(StdStatusCode.STATUS_CODE_SYNTAX_ERROR, ex.getMessage());
        if (DOMProperties.throwsExceptions()) {
            throw ex;
        }
    }

    return domPolicy;
}

From source file:org.apache.openaz.xacml.pdp.policy.dom.DOMPolicy.java

public static boolean repair(Node nodePolicy) throws DOMStructureException {
    Element elementPolicy = DOMUtil.getElement(nodePolicy);
    boolean result = false;

    NodeList children = elementPolicy.getChildNodes();
    int numChildren;
    boolean sawDescription = false;
    boolean sawIssuer = false;
    boolean sawTarget = false;
    boolean sawPolicyDefaults = false;
    boolean sawObligationExprs = false;
    boolean sawAdviceExprs = false;

    if (children != null && (numChildren = children.getLength()) > 0) {
        for (int i = 0; i < numChildren; i++) {
            Node child = children.item(i);
            if (DOMUtil.isElement(child) && DOMUtil.isInNamespace(child, XACML3.XMLNS)) {
                String childName = child.getLocalName();
                if (XACML3.ELEMENT_DESCRIPTION.equals(childName)) {
                    if (sawDescription) {
                        logger.warn("Unexpected element " + child.getNodeName());
                        elementPolicy.removeChild(child);
                        result = true;//from   w  w  w.ja  va2 s. c  om
                    } else {
                        sawDescription = true;
                    }
                } else if (XACML3.ELEMENT_POLICYISSUER.equals(childName)) {
                    if (sawIssuer) {
                        logger.warn("Unexpected element " + child.getNodeName());
                        elementPolicy.removeChild(child);
                        result = true;
                    } else {
                        sawDescription = true;
                        result = DOMPolicyIssuer.repair(child) || result;
                    }
                } else if (XACML3.ELEMENT_POLICYDEFAULTS.equals(childName)) {
                    if (sawPolicyDefaults) {
                        logger.warn("Unexpected element " + child.getNodeName());
                        elementPolicy.removeChild(child);
                        result = true;
                    } else {
                        sawPolicyDefaults = true;
                        result = DOMPolicyDefaults.repair(child) || result;
                    }
                } else if (XACML3.ELEMENT_TARGET.equals(childName)) {
                    if (sawTarget) {
                        logger.warn("Unexpected element " + child.getNodeName());
                        elementPolicy.removeChild(child);
                        result = true;
                    } else {
                        sawTarget = true;
                        result = DOMTarget.repair(child) || result;
                    }
                } else if (XACML3.ELEMENT_COMBINERPARAMETERS.equals(childName)) {
                    result = DOMCombinerParameter.repair(child) || result;
                } else if (XACML3.ELEMENT_RULECOMBINERPARAMETERS.equals(childName)) {
                    result = DOMRuleCombinerParameters.repair(child) || result;
                } else if (XACML3.ELEMENT_VARIABLEDEFINITION.equals(childName)) {
                    result = DOMVariableDefinition.repair(child) || result;
                } else if (XACML3.ELEMENT_RULE.equals(childName)) {
                    result = DOMRule.repair(child) || result;
                } else if (XACML3.ELEMENT_OBLIGATIONEXPRESSIONS.equals(childName)) {
                    if (sawObligationExprs) {
                        logger.warn("Unexpected element " + child.getNodeName());
                        elementPolicy.removeChild(child);
                        result = true;
                    } else {
                        sawObligationExprs = true;
                        result = DOMObligationExpression.repairList(child) || result;
                    }
                } else if (XACML3.ELEMENT_ADVICEEXPRESSIONS.equals(childName)) {
                    if (sawAdviceExprs) {
                        logger.warn("Unexpected element " + child.getNodeName());
                        elementPolicy.removeChild(child);
                        result = true;
                    } else {
                        sawAdviceExprs = true;
                        result = DOMAdviceExpression.repairList(child) || result;
                    }
                } else {
                    logger.warn("Unexpected element " + child.getNodeName());
                    elementPolicy.removeChild(child);
                    result = true;
                }
            }
        }
    }
    result = DOMUtil.repairIdentifierAttribute(elementPolicy, XACML3.ATTRIBUTE_POLICYID, logger) || result;
    result = DOMUtil.repairVersionAttribute(elementPolicy, XACML3.ATTRIBUTE_VERSION, logger) || result;
    result = DOMUtil.repairIdentifierAttribute(elementPolicy, XACML3.ATTRIBUTE_RULECOMBININGALGID,
            XACML3.ID_RULE_DENY_OVERRIDES, logger) || result;

    Identifier identifier = DOMUtil.getIdentifierAttribute(elementPolicy, XACML3.ATTRIBUTE_RULECOMBININGALGID);
    CombiningAlgorithm<Rule> combiningAlgorithmRule = null;
    try {
        combiningAlgorithmRule = CombiningAlgorithmFactory.newInstance().getRuleCombiningAlgorithm(identifier);
    } catch (FactoryException ex) {
        combiningAlgorithmRule = null;
    }
    if (combiningAlgorithmRule == null) {
        logger.warn("Setting invalid " + XACML3.ATTRIBUTE_RULECOMBININGALGID + " attribute "
                + identifier.stringValue() + " to " + XACML3.ID_RULE_DENY_OVERRIDES.stringValue());
        elementPolicy.setAttribute(XACML3.ATTRIBUTE_RULECOMBININGALGID,
                XACML3.ID_RULE_DENY_OVERRIDES.stringValue());
        result = true;
    }
    return result;
}

From source file:org.apache.openaz.xacml.pdp.policy.dom.DOMPolicyCombinerParameter.java

/**
 * Creates a new <code>TargetedCombinerParameter</code> for <code>Policy</code>s by parsing the given
 * <code>Node</code> representing a XACML PolicyCombinerParameter element.
 *
 * @param nodeCombinerParameter the <code>Node</code> representing the XACML PolicyCombinerParameter
 *            element//w  w  w .  ja  va2s .  c o m
 * @return a new <code>TargetedCombinerParameter</code> for <code>Policy</code>s parsed from the given
 *         <code>Node</code>
 * @throws DOMStructureException if there is an error parsing the <code>Node</code>
 */
public static TargetedCombinerParameter<Identifier, PolicySetChild> newInstance(Node nodeCombinerParameter)
        throws DOMStructureException {
    Element elementPolicyCombinerParameter = DOMUtil.getElement(nodeCombinerParameter);
    boolean bLenient = DOMProperties.isLenient();

    DOMPolicyCombinerParameter domPolicyCombinerParameter = new DOMPolicyCombinerParameter();

    try {
        NodeList children = elementPolicyCombinerParameter.getChildNodes();
        int numChildren;
        if (children != null && (numChildren = children.getLength()) > 0) {
            for (int i = 0; i < numChildren; i++) {
                Node child = children.item(i);
                if (DOMUtil.isElement(child)) {
                    if (DOMUtil.isInNamespace(child, XACML3.XMLNS)
                            && XACML3.ELEMENT_ATTRIBUTEVALUE.equals(child.getLocalName())) {
                        domPolicyCombinerParameter
                                .setAttributeValue(DOMAttributeValue.newInstance(child, null));
                    } else if (!bLenient) {
                        throw DOMUtil.newUnexpectedElementException(child, nodeCombinerParameter);
                    }
                }
            }
        }
        if (domPolicyCombinerParameter.getAttributeValue() == null && !bLenient) {
            throw DOMUtil.newMissingElementException(nodeCombinerParameter, XACML3.XMLNS,
                    XACML3.ELEMENT_ATTRIBUTEVALUE);
        }
        domPolicyCombinerParameter.setName(DOMUtil.getStringAttribute(elementPolicyCombinerParameter,
                XACML3.ATTRIBUTE_PARAMETERNAME, !bLenient));
        domPolicyCombinerParameter.setTargetId(DOMUtil.getIdentifierAttribute(elementPolicyCombinerParameter,
                XACML3.ATTRIBUTE_POLICYIDREF, !bLenient));

    } catch (DOMStructureException ex) {
        domPolicyCombinerParameter.setStatus(StdStatusCode.STATUS_CODE_SYNTAX_ERROR, ex.getMessage());
        if (DOMProperties.throwsExceptions()) {
            throw ex;
        }
    }

    return domPolicyCombinerParameter;

}

From source file:org.apache.openaz.xacml.pdp.policy.dom.DOMPolicyCombinerParameter.java

public static boolean repair(Node nodePolicyCombinerParameter) throws DOMStructureException {
    Element elementPolicyCombinerParameter = DOMUtil.getElement(nodePolicyCombinerParameter);
    boolean result = false;

    NodeList children = elementPolicyCombinerParameter.getChildNodes();
    int numChildren;
    boolean sawAttributeValue = false;
    if (children != null && (numChildren = children.getLength()) > 0) {
        for (int i = 0; i < numChildren; i++) {
            Node child = children.item(i);
            if (DOMUtil.isElement(child)) {
                if (DOMUtil.isInNamespace(child, XACML3.XMLNS)
                        && XACML3.ELEMENT_ATTRIBUTEVALUE.equals(child.getLocalName())) {
                    if (sawAttributeValue) {
                        logger.warn("Unexpected element " + child.getNodeName());
                        elementPolicyCombinerParameter.removeChild(child);
                        result = true;//w w w .j  a  v a2 s. c  o m
                    } else {
                        sawAttributeValue = true;
                        result = DOMAttributeValue.repair(child) || result;
                    }
                } else {
                    logger.warn("Unexpected element " + child.getNodeName());
                    elementPolicyCombinerParameter.removeChild(child);
                    result = true;
                }
            }
        }
    }
    if (!sawAttributeValue) {
        throw DOMUtil.newMissingElementException(nodePolicyCombinerParameter, XACML3.XMLNS,
                XACML3.ELEMENT_ATTRIBUTEVALUE);
    }
    result = DOMUtil.repairStringAttribute(elementPolicyCombinerParameter, XACML3.ATTRIBUTE_PARAMETERNAME,
            "parameter", logger) || result;
    result = DOMUtil.repairIdentifierAttribute(elementPolicyCombinerParameter, XACML3.ATTRIBUTE_POLICYIDREF,
            logger) || result;

    return result;
}

From source file:org.apache.openaz.xacml.pdp.policy.dom.DOMPolicyDefaults.java

/**
 * Creates a new <code>DOMPolicyDefaults</code> by parsing the given <code>Node</code> representing a
 * XACML PolicyDefaults element.//from  w w  w. j  a  v a 2s  . c om
 *
 * @param nodePolicyDefaults the <code>Node</code> representing the PolicyDefaults element.
 * @param policyDefaultsParent the <code>PolicyDefaults</code> parent for the new
 *            <code>DOMPolicyDefaults</code>
 * @return a new <code>DOMPolicyDefaults</code> parsed from the given <code>Node</code>
 * @throws DOMStructureException if the conversion is not possible
 */
public static PolicyDefaults newInstance(Node nodePolicyDefaults, PolicyDefaults policyDefaultsParent)
        throws DOMStructureException {
    Element elementPolicyDefaults = DOMUtil.getElement(nodePolicyDefaults);
    boolean bLenient = DOMProperties.isLenient();

    URI uriXPathVersion = null;

    NodeList children = elementPolicyDefaults.getChildNodes();
    int numChildren;
    if (children != null && (numChildren = children.getLength()) > 0) {
        for (int i = 0; i < numChildren; i++) {
            Node child = children.item(i);
            if (DOMUtil.isElement(child)) {
                if (DOMUtil.isInNamespace(child, XACML3.XMLNS)
                        && XACML3.ELEMENT_XPATHVERSION.equals(child.getLocalName())) {
                    uriXPathVersion = DOMUtil.getURIContent(child);
                } else if (!bLenient) {
                    throw DOMUtil.newUnexpectedElementException(child, nodePolicyDefaults);
                }
            }
        }
    }
    return new DOMPolicyDefaults(uriXPathVersion, policyDefaultsParent);
}