import com.att.research.xacml.api.Attribute;
import com.att.research.xacml.api.AttributeValue;
+import com.att.research.xacml.api.DataTypeException;
import com.att.research.xacml.api.Identifier;
import com.att.research.xacml.api.XACML3;
import com.att.research.xacml.api.pip.PIPException;
try {
pipResponse = pipFinder.getMatchingAttributes(pipRequest, this);
if (pipResponse.getStatus() != null && !pipResponse.getStatus().isOk()) {
- if (logger.isInfoEnabled()) {
- logger.info("get attribute error retrieving {}: {}", pipRequest.getAttributeId().stringValue(),
- pipResponse.getStatus());
- }
+ logger.info("get attribute error retrieving {}: {}", pipRequest.getAttributeId().stringValue(),
+ pipResponse.getStatus());
pipResponse = null;
}
if (pipResponse != null && pipResponse.getAttributes().isEmpty()) {
- if (logger.isInfoEnabled()) {
- logger.info("No value for {}", pipRequest.getAttributeId().stringValue());
- }
+ logger.info("No value for {}", pipRequest.getAttributeId().stringValue());
pipResponse = null;
}
} catch (PIPException ex) {
protected String findFirstAttributeValue(PIPResponse pipResponse) {
for (Attribute attribute: pipResponse.getAttributes()) {
Iterator<AttributeValue<String>> iterAttributeValues = attribute.findValues(DataTypes.DT_STRING);
- if (iterAttributeValues != null) {
- while (iterAttributeValues.hasNext()) {
- String value = iterAttributeValues.next().getValue();
- if (value != null) {
- return value;
- }
+ while (iterAttributeValues.hasNext()) {
+ String value = iterAttributeValues.next().getValue();
+ if (value != null) {
+ return value;
}
}
}
Identifier attributeId, int value, PIPRequest pipRequest) {
AttributeValue<BigInteger> attributeValue = null;
try {
- attributeValue = DataTypes.DT_INTEGER.createAttributeValue(value);
+ attributeValue = makeInteger(value);
} catch (Exception e) {
logger.error("Failed to convert {} to integer {}", value, e);
}
Identifier attributeId, long value, PIPRequest pipRequest) {
AttributeValue<BigInteger> attributeValue = null;
try {
- attributeValue = DataTypes.DT_INTEGER.createAttributeValue(value);
+ attributeValue = makeLong(value);
} catch (Exception e) {
logger.error("Failed to convert {} to long {}", value, e);
}
String value, PIPRequest pipRequest) {
AttributeValue<String> attributeValue = null;
try {
- attributeValue = DataTypes.DT_STRING.createAttributeValue(value);
+ attributeValue = makeString(value);
} catch (Exception ex) {
logger.error("Failed to convert {} to an AttributeValue<String>", value, ex);
}
}
}
+ // these may be overridden by junit tests
+
+ protected AttributeValue<BigInteger> makeInteger(int value) throws DataTypeException {
+ return DataTypes.DT_INTEGER.createAttributeValue(value);
+ }
+
+ protected AttributeValue<BigInteger> makeLong(long value) throws DataTypeException {
+ return DataTypes.DT_INTEGER.createAttributeValue(value);
+ }
+
+ protected AttributeValue<String> makeString(String value) throws DataTypeException {
+ return DataTypes.DT_STRING.createAttributeValue(value);
+ }
+
}