com.sap.cloud.security.ams.dcn.engine.AttributeNode Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jakarta-ams Show documentation
Show all versions of jakarta-ams Show documentation
Client Library for integrating Jakarta EE applications with SAP Authorization Management Service (AMS)
The newest version!
/************************************************************************
* © 2019-2024 SAP SE or an SAP affiliate company. All rights reserved. *
************************************************************************/
package com.sap.cloud.security.ams.dcn.engine;
import com.sap.cloud.security.ams.dcl.client.el.AttributeName;
import com.sap.cloud.security.ams.dcl.client.pdp.Attributes;
import java.util.Objects;
/** Leaf {@link EvaluationNode} representing an unresolved attribute. */
public class AttributeNode extends EvaluationNode {
private final AttributeName path;
/**
* Creates a new instance representing the attribute with the given {@link AttributeName}.
*
* @param path the path of the attribute
*/
AttributeNode(AttributeName path) {
this.path = path;
}
/**
* If this node represents an attribute for which a value other than {@link
* Attributes.SpecialValue#UNKNOWN} is provided by the given {@link ValueAccessor}, then this
* method returns a new {@link ValueNode} instance created from that value. Otherwise, this method
* returns this node, i.e. the unresolved attribute is kept in the evaluation tree.
*
* @param valueAccessor accessor for attribute values
* @return resolved {@link ValueNode} or this {@link AttributeNode}
*/
@Override
public EvaluationNode evaluate(ValueAccessor valueAccessor) {
Object value = valueAccessor.attributeValue(path);
if (Attributes.SpecialValue.UNKNOWN.equals(value)) {
return this;
}
return ValueNode.create(value);
}
/**
* Converts this node to a condition object by returning its {@link AttributeName}.
*
* @return the path of the attribute
*/
@Override
public Object toCondition() {
return path;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
AttributeNode that = (AttributeNode) o;
return Objects.equals(path, that.path);
}
@Override
public int hashCode() {
return Objects.hashCode(path);
}
@Override
public String toString() {
return "Attr{" + path + '}';
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy