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

com.att.research.xacmlatt.pdp.policy.PolicySetChild Maven / Gradle / Ivy

There is a newer version: 4.0.0
Show newest version
/*
 *
 *          Copyright (c) 2013,2019  AT&T Knowledge Ventures
 *                     SPDX-License-Identifier: MIT
 */
package com.att.research.xacmlatt.pdp.policy;

import com.att.research.xacml.api.Identifier;
import com.att.research.xacml.api.StatusCode;
import com.att.research.xacml.api.trace.Traceable;
import com.att.research.xacml.std.StdStatusCode;
import com.att.research.xacmlatt.pdp.eval.Evaluatable;
import com.att.research.xacmlatt.pdp.eval.Matchable;

/**
 * PolicySetChild extends {@link com.att.research.xacmlatt.pdp.policy.PolicyComponent} to represent XACML 3.0 Policies, PolicySets, PolicyReferences,
 * and PolicySetReferences.
 * 
 * @author car
 * @version $Revision: 1.1 $
 */
public abstract class PolicySetChild extends PolicyComponent implements Evaluatable, Matchable, Traceable {
	private Identifier		identifier;
	private PolicyDefaults	policyDefaults;
	private PolicySet parent;
	
	/**
	 * Creates a new PolicySetChild with the given given {@link com.att.research.xacml.api.StatusCode} 
	 * and String status message.
	 * 
	 * @param parentIn PolicySet parent
	 * @param statusCodeIn the StatusCode for the new PolicySetChild
	 * @param statusMessageIn the String status message for the new PolicySetChild
	 */
	protected PolicySetChild(PolicySet parentIn, StatusCode statusCodeIn, String statusMessageIn) {
		super(statusCodeIn, statusMessageIn);
		this.parent	= parentIn;
	}
	
	protected PolicySetChild(StatusCode statusCodeIn, String statusMessageIn) {
		this(null, statusCodeIn, statusMessageIn);
	}
	
	/**
	 * Creates a new PolicySetChild with the default OK StatusCode.
	 * 
	 * @param statusCodeIn the StatusCode for this PolicySetChild
	 */
	protected PolicySetChild(StatusCode statusCodeIn) {
		super(statusCodeIn);
	}
	
	protected PolicySetChild(PolicySet parentIn) {
		this.parent	= parentIn;
	}
	
	/**
	 * Creates a new PolicySetChild with the default OK status.
	 */
	protected PolicySetChild() {
		super();
	}
	
	/**
	 * Gets the Identifier for this PolicySetChild.
	 * 
	 * @return the Identifier for this PolicySetChild
	 */
	public Identifier getIdentifier() {
		return this.identifier;
	}
	
	public void setIdentifier(Identifier identifierIn) {
		this.identifier	= identifierIn;
	}
	
	/**
	 * Gets the PolicyDefaults for this PolicySetChild.
	 * 
	 * @return the PolicyDefaults for this PolicySetChild
	 */
	public PolicyDefaults getPolicyDefaults() {
		return this.policyDefaults;
	}
	
	/**
	 * Sets the PolicyDefaults for this PolicySetChild.
	 * 
	 * @param policyDefaultsIn the PolicyDefaults for this PolicySetChild
	 */
	public void setPolicyDefaults(PolicyDefaults policyDefaultsIn) {
		this.policyDefaults	= policyDefaultsIn;
	}
	
	/**
	 * Gets the parent {@link com.att.research.xacmlatt.pdp.policy.PolicySet} containing this PolicySetChild
	 * or null if this is the root.
	 *  
	 * @return the parent PolicySet of this PolicySetChild
	 */
	public PolicySet getParent() {
		return this.parent;
	}
	
	@Override
	protected boolean validateComponent() {
		if (this.getIdentifier() == null) {
			this.setStatus(StdStatusCode.STATUS_CODE_SYNTAX_ERROR, "Missing identifier");
			return false;
		} else {
			this.setStatus(StdStatusCode.STATUS_CODE_OK, null);
			return true;
		}
	}
	
	@Override
	public String getTraceId() {
		return this.getIdentifier().stringValue();
	}
	
	@Override
	public Traceable getCause() {
		return this.parent;
	}

	@Override
	public String toString() {
		StringBuilder stringBuilder	= new StringBuilder("{");
		
		stringBuilder.append("super=");
		stringBuilder.append(super.toString());
		
		Object objectToDump;
		if ((objectToDump = this.getIdentifier()) != null) {
			stringBuilder.append(",identifier=");
			stringBuilder.append(objectToDump.toString());
		}
		if ((objectToDump = this.getPolicyDefaults()) != null) {
			stringBuilder.append(",policyDefaults=");
			stringBuilder.append(objectToDump.toString());
		}
		stringBuilder.append('}');
		return stringBuilder.toString();
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy