All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.att.research.xacmlatt.pdp.policy.dom.DOMPolicyIdReference Maven / Gradle / Ivy

The newest version!
/*
 *
 *          Copyright (c) 2013,2019  AT&T Knowledge Ventures
 *                     SPDX-License-Identifier: MIT
 */
package com.att.research.xacmlatt.pdp.policy.dom;

import org.w3c.dom.Node;

import com.att.research.xacml.std.StdStatusCode;
import com.att.research.xacml.std.dom.DOMIdReferenceMatch;
import com.att.research.xacml.std.dom.DOMProperties;
import com.att.research.xacml.std.dom.DOMStructureException;
import com.att.research.xacmlatt.pdp.policy.PolicyIdReference;
import com.att.research.xacmlatt.pdp.policy.PolicySet;

/**
 * DOMPolicyIdReference extends {@link com.att.research.xacmlatt.pdp.policy.PolicyIdReference} with methods for creation
 * from DOM {@link org.w3c.dom.Node}s.
 * 
 * @author car
 * @version $Revision: 1.2 $
 */
public class DOMPolicyIdReference {
	
	protected DOMPolicyIdReference() {
	}

	/**
	 * Creates a new PolicyIdReference parsed from the given Node representing a XACML PolicyIdReference element.
	 * 
	 * @param nodePolicyIdReference the Node representing the XACML PolicyIdReference element
	 * @param policySetParent PolicySet parent
	 * @return a new PolicyIdReference parsed from the given Node
	 * @throws DOMStructureException if there is an error parsing the Node
	 */
	public static PolicyIdReference newInstance(Node nodePolicyIdReference, PolicySet policySetParent) throws DOMStructureException {
		PolicyIdReference domPolicyIdReference	= new PolicyIdReference(policySetParent);
		
		try {
			domPolicyIdReference.setIdReferenceMatch(DOMIdReferenceMatch.newInstance(nodePolicyIdReference));
		} catch (DOMStructureException ex) {
			domPolicyIdReference.setStatus(StdStatusCode.STATUS_CODE_SYNTAX_ERROR, ex.getMessage());
			if (DOMProperties.throwsExceptions()) {
				throw ex;
			}
		}
		
		return domPolicyIdReference;
	}
	
	public static boolean repair(Node nodePolicyIdReference) throws DOMStructureException {
		return DOMIdReferenceMatch.repair(nodePolicyIdReference);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy