You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openaz.apache.org by co...@apache.org on 2015/05/05 14:23:35 UTC
[37/54] [abbrv] [partial] incubator-openaz git commit: Do an eclipse
based "cleanup" on the project
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/38b6d318/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionRFC822NameMatch.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionRFC822NameMatch.java b/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionRFC822NameMatch.java
index 209f99d..81c65e4 100644
--- a/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionRFC822NameMatch.java
+++ b/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionRFC822NameMatch.java
@@ -43,20 +43,16 @@ import com.att.research.xacmlatt.pdp.policy.ExpressionResult;
import com.att.research.xacmlatt.pdp.policy.FunctionArgument;
/**
- * FunctionDefinitionRFC822NameMatch extends {@link com.att.research.xacmlatt.pdp.std.functions.FunctionDefinitionHomogeneousSimple} to
- * implement the XACML RFC822Name match predicate as functions taking one <code>String</code> and one <code>RFC822Name</code> arguments
- * and returning a single <code>Boolean</code> value.
- *
- * In the first implementation of XACML we had separate files for each XACML Function.
- * This release combines multiple Functions in fewer files to minimize code duplication.
- * This file supports the following XACML codes:
- * rfc822Name-match
- *
- *
+ * FunctionDefinitionRFC822NameMatch extends
+ * {@link com.att.research.xacmlatt.pdp.std.functions.FunctionDefinitionHomogeneousSimple} to implement the
+ * XACML RFC822Name match predicate as functions taking one <code>String</code> and one
+ * <code>RFC822Name</code> arguments and returning a single <code>Boolean</code> value. In the first
+ * implementation of XACML we had separate files for each XACML Function. This release combines multiple
+ * Functions in fewer files to minimize code duplication. This file supports the following XACML codes:
+ * rfc822Name-match
*/
public class FunctionDefinitionRFC822NameMatch extends FunctionDefinitionBase<Boolean, RFC822Name> {
-
/**
* Constructor
*
@@ -68,65 +64,79 @@ public class FunctionDefinitionRFC822NameMatch extends FunctionDefinitionBase<Bo
super(idIn, DataTypes.DT_BOOLEAN, DataTypes.DT_RFC822NAME, false);
}
-
@Override
public ExpressionResult evaluate(EvaluationContext evaluationContext, List<FunctionArgument> arguments) {
if (arguments == null || arguments.size() != 2) {
- return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, getShortFunctionId() + " Expected 2 arguments, got " +
- ((arguments == null) ? "null" : arguments.size()) ));
+ return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR,
+ getShortFunctionId()
+ + " Expected 2 arguments, got "
+ + ((arguments == null) ? "null" : arguments
+ .size())));
}
// get the string to search for
- ConvertedArgument<String> stringArgument = new ConvertedArgument<String>(arguments.get(0), DataTypes.DT_STRING, false);
- if ( ! stringArgument.isOk()) {
- Status decoratedStatus = new StdStatus(stringArgument.getStatus().getStatusCode(), stringArgument.getStatus().getStatusMessage() + " at arg index 0" );
+ ConvertedArgument<String> stringArgument = new ConvertedArgument<String>(arguments.get(0),
+ DataTypes.DT_STRING, false);
+ if (!stringArgument.isOk()) {
+ Status decoratedStatus = new StdStatus(stringArgument.getStatus().getStatusCode(), stringArgument
+ .getStatus().getStatusMessage() + " at arg index 0");
return ExpressionResult.newError(getFunctionStatus(decoratedStatus));
}
String searchTermString = stringArgument.getValue();
// get the RFC822Name to match with
- ConvertedArgument<RFC822Name> rfc822Argument = new ConvertedArgument<RFC822Name>(arguments.get(1), DataTypes.DT_RFC822NAME, false);
- if ( ! rfc822Argument.isOk()) {
- Status decoratedStatus = new StdStatus(rfc822Argument.getStatus().getStatusCode(), rfc822Argument.getStatus().getStatusMessage() + " at arg index 1" );
+ ConvertedArgument<RFC822Name> rfc822Argument = new ConvertedArgument<RFC822Name>(
+ arguments.get(1),
+ DataTypes.DT_RFC822NAME,
+ false);
+ if (!rfc822Argument.isOk()) {
+ Status decoratedStatus = new StdStatus(rfc822Argument.getStatus().getStatusCode(), rfc822Argument
+ .getStatus().getStatusMessage() + " at arg index 1");
return ExpressionResult.newError(getFunctionStatus(decoratedStatus));
}
RFC822Name rfc822Name = rfc822Argument.getValue();
-
/*
* Now perform the match.
*/
/*
- * According to the spec the string must be one of the following 3 things:
- * - a name with an '@' in it = a full name that must exactly match the whole RFC name (domain part is ignore case)
- * - a domain name (without an '@' and not starting with a '.') = must match whole RFC domain name (ignore case)
- * - a partial domain name (without an '@') starting with a '.' = the last part of the RFC domain name (ignore case)
+ * According to the spec the string must be one of the following 3 things: - a name with an '@' in it
+ * = a full name that must exactly match the whole RFC name (domain part is ignore case) - a domain
+ * name (without an '@' and not starting with a '.') = must match whole RFC domain name (ignore case)
+ * - a partial domain name (without an '@') starting with a '.' = the last part of the RFC domain name
+ * (ignore case)
*/
String[] searchTerms = searchTermString.split("@");
if (searchTerms.length > 2) {
- return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, getShortFunctionId() +
- " String contained more than 1 '@' in '" + searchTermString + "'" ));
+ return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR,
+ getShortFunctionId()
+ + " String contained more than 1 '@' in '"
+ + searchTermString + "'"));
}
if (searchTerms.length == 2 || searchTermString.endsWith("@")) {
// this is an exact match
if (searchTerms[0] == null || searchTerms[0].length() == 0) {
- return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, getShortFunctionId() +
- " String missing local part in '" + searchTermString + "'" ));
+ return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR,
+ getShortFunctionId()
+ + " String missing local part in '"
+ + searchTermString + "'"));
}
if (searchTerms.length < 2 || searchTerms[1] == null || searchTerms[1].length() == 0) {
- return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, getShortFunctionId() +
- " String missing domain part in '" + searchTermString + "'" ));
+ return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR,
+ getShortFunctionId()
+ + " String missing domain part in '"
+ + searchTermString + "'"));
}
// args are ok, so check both against RFC name
- if (searchTerms[0].equals(rfc822Name.getLocalName()) &&
- searchTerms[1].toLowerCase().equals(rfc822Name.getCanonicalDomainName())) {
+ if (searchTerms[0].equals(rfc822Name.getLocalName())
+ && searchTerms[1].toLowerCase().equals(rfc822Name.getCanonicalDomainName())) {
return ER_TRUE;
} else {
return ER_FALSE;
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/38b6d318/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionRegexpMatch.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionRegexpMatch.java b/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionRegexpMatch.java
index cc8174c..014f902 100644
--- a/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionRegexpMatch.java
+++ b/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionRegexpMatch.java
@@ -30,7 +30,6 @@
*/
package com.att.research.xacmlatt.pdp.std.functions;
-
import java.util.List;
import com.att.research.xacml.api.DataType;
@@ -45,27 +44,20 @@ import com.att.research.xacmlatt.pdp.policy.FunctionArgument;
/**
* FunctionDefinitionRegexMatch implements {@link com.att.research.xacmlatt.pdp.policy.FunctionDefinition} to
- * implement the XACML 'type'-regex-match predicates as functions taking two arguments, the first of <code>String</code>,
- * representing a regular expression, and the second of the type for that specific predicate,
- * and returning a <code>Boolean</code> for whether the regular expression matches the string representation of the second argument.
- *
- * In the first implementation of XACML we had separate files for each XACML Function.
- * This release combines multiple Functions in fewer files to minimize code duplication.
- * This file supports the following XACML codes:
- * string-regexp-match
- * anyURI-regexp-match
- * x500Name-regexp-match
- * rfc822Name-regexp-match (in sub-class {@link com.att.research.xacmlatt.pdp.policy.FunctionDefinition.FunctionDefinitionRegexpMatchRFC822} )
- * ipAddress-regexp-match
- * dnsName-regexp-match
- *
- *
+ * implement the XACML 'type'-regex-match predicates as functions taking two arguments, the first of
+ * <code>String</code>, representing a regular expression, and the second of the type for that specific
+ * predicate, and returning a <code>Boolean</code> for whether the regular expression matches the string
+ * representation of the second argument. In the first implementation of XACML we had separate files for each
+ * XACML Function. This release combines multiple Functions in fewer files to minimize code duplication. This
+ * file supports the following XACML codes: string-regexp-match anyURI-regexp-match x500Name-regexp-match
+ * rfc822Name-regexp-match (in sub-class
+ * {@link com.att.research.xacmlatt.pdp.policy.FunctionDefinition.FunctionDefinitionRegexpMatchRFC822} )
+ * ipAddress-regexp-match dnsName-regexp-match
*
* @param <I> the java class for the data type of the function Input arguments
*/
public class FunctionDefinitionRegexpMatch<I> extends FunctionDefinitionBase<Boolean, I> {
-
/**
* Constructor - need dataTypeArgs input because of java Generic type-erasure during compilation.
*
@@ -76,32 +68,36 @@ public class FunctionDefinitionRegexpMatch<I> extends FunctionDefinitionBase<Boo
super(idIn, DataTypes.DT_BOOLEAN, dataTypeArgsIn, false);
}
-
@Override
public ExpressionResult evaluate(EvaluationContext evaluationContext, List<FunctionArgument> arguments) {
if (arguments == null || arguments.size() != 2) {
- return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " Expected 2 arguments, got " +
- ((arguments == null) ? "null" : arguments.size()) ));
+ return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR,
+ this.getShortFunctionId()
+ + " Expected 2 arguments, got "
+ + ((arguments == null) ? "null" : arguments
+ .size())));
}
// get the regular expression
FunctionArgument regexpArgument = arguments.get(0);
- ConvertedArgument<String> convertedArgument = new ConvertedArgument<String>(regexpArgument, DataTypes.DT_STRING, false);
- if ( ! convertedArgument.isOk()) {
+ ConvertedArgument<String> convertedArgument = new ConvertedArgument<String>(regexpArgument,
+ DataTypes.DT_STRING,
+ false);
+ if (!convertedArgument.isOk()) {
return ExpressionResult.newError(getFunctionStatus(convertedArgument.getStatus()));
}
// String regexpValue = (String)regexpArgument.getValue().getValue();
- String regexpValue = convertedArgument.getValue();
-
+ String regexpValue = convertedArgument.getValue();
// now get the element to match
FunctionArgument elementArgument = arguments.get(1);
- ConvertedArgument<I> convertedElement = new ConvertedArgument<I>(elementArgument, this.getDataTypeArgs(), false);
- if ( ! convertedElement.isOk()) {
+ ConvertedArgument<I> convertedElement = new ConvertedArgument<I>(elementArgument,
+ this.getDataTypeArgs(), false);
+ if (!convertedElement.isOk()) {
return ExpressionResult.newError(getFunctionStatus(convertedElement.getStatus()));
}
@@ -115,7 +111,8 @@ public class FunctionDefinitionRegexpMatch<I> extends FunctionDefinitionBase<Boo
if (e.getCause() != null) {
message = e.getCause().getMessage();
}
- return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " " + message));
+ return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this
+ .getShortFunctionId() + " " + message));
}
// ConvertedArgument checks for null value, so do not need to do again here
@@ -128,8 +125,4 @@ public class FunctionDefinitionRegexpMatch<I> extends FunctionDefinitionBase<Boo
}
-
-
-
-
}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/38b6d318/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionSet.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionSet.java b/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionSet.java
index 4e3acb6..6490c89 100644
--- a/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionSet.java
+++ b/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionSet.java
@@ -45,88 +45,80 @@ import com.att.research.xacmlatt.pdp.policy.FunctionArgument;
/**
* FunctionDefinitionSet implements {@link com.att.research.xacmlatt.pdp.policy.FunctionDefinition} to
- * implement the XACML Set predicates as functions taking two arguments of <code>Bag</code> the same primitive type
- * and returning either a <code>Boolean</code> or a <code>Bag</code> of the same primitive type.
+ * implement the XACML Set predicates as functions taking two arguments of <code>Bag</code> the same primitive
+ * type and returning either a <code>Boolean</code> or a <code>Bag</code> of the same primitive type.
* <P>
- * The ipAddress, dnsName and xPathExpression do not have set functions defined for them in section 10.2.8 of the Release 3 XACML spec.
- *
- * In the first implementation of XACML we had separate files for each XACML Function.
- * This release combines multiple Functions in fewer files to minimize code duplication.
- * This file supports the following XACML codes:
- * string-bag
- * boolean-bag
- * integer-bag
- * double-bag
- * time-bag
- * date-bag
- * dateTime-bag
- * anyURI-bag
- * hexBinary-bag
- * base64Binary-bag
- * dayTimeDuration-bag (version 1 and3)
- * yearMonthDuration-bag (version 1 and 3)
- * x500Name-bag
- * rfc822Name-bag
- *
- *
+ * The ipAddress, dnsName and xPathExpression do not have set functions defined for them in section 10.2.8 of
+ * the Release 3 XACML spec. In the first implementation of XACML we had separate files for each XACML
+ * Function. This release combines multiple Functions in fewer files to minimize code duplication. This file
+ * supports the following XACML codes: string-bag boolean-bag integer-bag double-bag time-bag date-bag
+ * dateTime-bag anyURI-bag hexBinary-bag base64Binary-bag dayTimeDuration-bag (version 1 and3)
+ * yearMonthDuration-bag (version 1 and 3) x500Name-bag rfc822Name-bag
*
* @param <I> the java class for the data type of the function Input arguments
* @param <O> the java class for the data type of the function Output
*/
-public class FunctionDefinitionSet<O,I> extends FunctionDefinitionBase<O, I> {
+public class FunctionDefinitionSet<O, I> extends FunctionDefinitionBase<O, I> {
/**
* List of comparison operations.
- *
- *
*/
- public enum OPERATION {INTERSECTION, AT_LEAST_ONE_MEMBER_OF, UNION, SUBSET, SET_EQUALS };
+ public enum OPERATION {
+ INTERSECTION,
+ AT_LEAST_ONE_MEMBER_OF,
+ UNION,
+ SUBSET,
+ SET_EQUALS
+ };
// the operation for this instance of the class
private OPERATION operation;
-
/**
* Constructor - need dataType input because of java Generic type-erasure during compilation.
*
* @param idIn
* @param dataTypeArgsIn
*/
- public FunctionDefinitionSet(Identifier idIn, DataType<O> dataTypeIn, DataType<I> dataTypeArgsIn, OPERATION opIn) {
- super(idIn, dataTypeIn, dataTypeArgsIn, ((opIn == OPERATION.INTERSECTION || opIn == OPERATION.UNION) ? true : false) );
+ public FunctionDefinitionSet(Identifier idIn, DataType<O> dataTypeIn, DataType<I> dataTypeArgsIn,
+ OPERATION opIn) {
+ super(idIn, dataTypeIn, dataTypeArgsIn, ((opIn == OPERATION.INTERSECTION || opIn == OPERATION.UNION)
+ ? true : false));
operation = opIn;
}
-
@Override
public ExpressionResult evaluate(EvaluationContext evaluationContext, List<FunctionArgument> arguments) {
if (arguments == null || arguments.size() != 2) {
- return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " Expected 2 arguments, got " +
- ((arguments == null) ? "null" : arguments.size()) ));
+ return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR,
+ this.getShortFunctionId()
+ + " Expected 2 arguments, got "
+ + ((arguments == null) ? "null" : arguments
+ .size())));
}
// get first bag
FunctionArgument bagArgument = arguments.get(0);
ConvertedArgument<Bag> convertedBagArgument = new ConvertedArgument<Bag>(bagArgument, null, true);
- if ( ! convertedBagArgument.isOk()) {
+ if (!convertedBagArgument.isOk()) {
return ExpressionResult.newError(getFunctionStatus(convertedBagArgument.getStatus()));
}
Bag bag1 = convertedBagArgument.getBag();
- List<AttributeValue<?>> list1 = (List<AttributeValue<?>>) bag1.getAttributeValueList();
+ List<AttributeValue<?>> list1 = bag1.getAttributeValueList();
// get second bag
bagArgument = arguments.get(1);
convertedBagArgument = new ConvertedArgument<Bag>(bagArgument, null, true);
- if ( ! convertedBagArgument.isOk()) {
+ if (!convertedBagArgument.isOk()) {
return ExpressionResult.newError(getFunctionStatus(convertedBagArgument.getStatus()));
}
Bag bag2 = convertedBagArgument.getBag();
- List<AttributeValue<?>> list2 = (List<AttributeValue<?>>) bag2.getAttributeValueList();
+ List<AttributeValue<?>> list2 = bag2.getAttributeValueList();
// arguments are ready BUT they have NOT had duplicates removed
@@ -136,7 +128,6 @@ public class FunctionDefinitionSet<O,I> extends FunctionDefinitionBase<O, I> {
Bag outBag;
List<AttributeValue<?>> outList;
-
switch (operation) {
case INTERSECTION:
outList = new ArrayList<AttributeValue<?>>();
@@ -161,12 +152,13 @@ public class FunctionDefinitionSet<O,I> extends FunctionDefinitionBase<O, I> {
expressionResult = ExpressionResult.newBag(outBag);
return expressionResult;
-
case AT_LEAST_ONE_MEMBER_OF:
// look for elements from the first list in the second.
- // duplicates do not matter because if the element is not there it does not matter that we look for it again,
+ // duplicates do not matter because if the element is not there it does not matter that we look
+ // for it again,
// and if it is there we stop the first time we see it.
- // If the first bag is empty, this should fail because no element from the first set can be found in the second set
+ // If the first bag is empty, this should fail because no element from the first set can be found
+ // in the second set
// (because there IS no element in first set).
for (AttributeValue<?> element : list1) {
if (list2.contains(element)) {
@@ -183,13 +175,13 @@ public class FunctionDefinitionSet<O,I> extends FunctionDefinitionBase<O, I> {
if (outList.contains(element)) {
continue;
}
- outList.add((AttributeValue<?>) element);
+ outList.add(element);
}
for (AttributeValue<?> element : list2) {
if (outList.contains(element)) {
continue;
}
- outList.add((AttributeValue<?>) element);
+ outList.add(element);
}
// now have the intersection; put it in a bag
@@ -203,33 +195,33 @@ public class FunctionDefinitionSet<O,I> extends FunctionDefinitionBase<O, I> {
expressionResult = ExpressionResult.newBag(outBag);
return expressionResult;
-
case SUBSET:
// all elements from list 1 must exist in list 2.
// duplicates do not matter because if an element is not found the first time we stop immediately,
// and if it is found the first time it will also be found for the duplicate.
- // If the first set is empty we return TRUE because all elements (i.e. none) in the first set are in the second.
+ // If the first set is empty we return TRUE because all elements (i.e. none) in the first set are
+ // in the second.
for (AttributeValue<?> element : list1) {
- if ( ! list2.contains(element)) {
+ if (!list2.contains(element)) {
return ER_FALSE;
}
}
// all elements in list1 were found
return ER_TRUE;
-
case SET_EQUALS:
- // we cannot do a direct one-to-one compare because the lists may contain duplicates. Also they may not be ordered the same.
+ // we cannot do a direct one-to-one compare because the lists may contain duplicates. Also they
+ // may not be ordered the same.
// So we ask:
- // are all elements in list 1 in list 2 (ignoring duplicates)
- // are all elements in list 2 in list 1 (ignoring duplicates)
+ // are all elements in list 1 in list 2 (ignoring duplicates)
+ // are all elements in list 2 in list 1 (ignoring duplicates)
for (AttributeValue<?> element : list1) {
- if ( ! list2.contains(element)) {
+ if (!list2.contains(element)) {
return ER_FALSE;
}
}
for (AttributeValue<?> element : list2) {
- if ( ! list1.contains(element)) {
+ if (!list1.contains(element)) {
return ER_FALSE;
}
}
@@ -238,10 +230,9 @@ public class FunctionDefinitionSet<O,I> extends FunctionDefinitionBase<O, I> {
}
// all cases should have been covered by above - should never get here
- return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " Could not evaluate Set function " + operation));
+ return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this
+ .getShortFunctionId() + " Could not evaluate Set function " + operation));
}
-
-
}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/38b6d318/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionStringConversion.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionStringConversion.java b/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionStringConversion.java
index 2bdce61..c8158a8 100644
--- a/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionStringConversion.java
+++ b/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionStringConversion.java
@@ -45,44 +45,22 @@ import com.att.research.xacmlatt.pdp.policy.ExpressionResult;
import com.att.research.xacmlatt.pdp.policy.FunctionArgument;
/**
- * FunctionDefinitionNumberTypeConversion extends {@link com.att.research.xacmlatt.pdp.std.functions.FunctionDefinitionHomogeneousSimple} to
- * implement the XACML predicates for converting <code>String</code> to <code>DataType<?></code> and vice versa.
- *
- * In the first implementation of XACML we had separate files for each XACML Function.
- * This release combines multiple Functions in fewer files to minimize code duplication.
- * This file supports the following XACML codes:
- * boolean-from-string
- * string-from-boolean
- * integer-from-string
- * string-from-integer
- * double-from-string
- * string-from-double
- * time-from-string
- * string-from-time
- * date-from-string
- * string-from-date
- * dateTime-from-string
- * string-from-dateTime
- * anyURI-from-string
- * string-from-anyURI
- * dayTimeDuration-from-string
- * string-from-dayTimeDuration
- * yearMonthDuration-from-string
- * string-from-yearMonthDuration
- * x500Name-from-string
- * string-from-x500Name
- * rfc822Name-from-string
- * string-from-rfc822Name
- * ipAddress-from-string
- * string-from-ipAddress
- * dnsName-from-string
- * string-from-dnsName
- *
+ * FunctionDefinitionNumberTypeConversion extends
+ * {@link com.att.research.xacmlatt.pdp.std.functions.FunctionDefinitionHomogeneousSimple} to implement the
+ * XACML predicates for converting <code>String</code> to <code>DataType<?></code> and vice versa. In the
+ * first implementation of XACML we had separate files for each XACML Function. This release combines multiple
+ * Functions in fewer files to minimize code duplication. This file supports the following XACML codes:
+ * boolean-from-string string-from-boolean integer-from-string string-from-integer double-from-string
+ * string-from-double time-from-string string-from-time date-from-string string-from-date dateTime-from-string
+ * string-from-dateTime anyURI-from-string string-from-anyURI dayTimeDuration-from-string
+ * string-from-dayTimeDuration yearMonthDuration-from-string string-from-yearMonthDuration
+ * x500Name-from-string string-from-x500Name rfc822Name-from-string string-from-rfc822Name
+ * ipAddress-from-string string-from-ipAddress dnsName-from-string string-from-dnsName
*
* @param <O> the java class for the data type of the function Output
* @param <I> the java class for the data type of the function Input argument
*/
-public class FunctionDefinitionStringConversion<O,I> extends FunctionDefinitionHomogeneousSimple<O, I> {
+public class FunctionDefinitionStringConversion<O, I> extends FunctionDefinitionHomogeneousSimple<O, I> {
public FunctionDefinitionStringConversion(Identifier idIn, DataType<O> outputType, DataType<I> argType) {
super(idIn, outputType, argType, 1);
@@ -90,8 +68,8 @@ public class FunctionDefinitionStringConversion<O,I> extends FunctionDefinitionH
@Override
public ExpressionResult evaluate(EvaluationContext evaluationContext, List<FunctionArgument> arguments) {
- List<I> convertedArguments = new ArrayList<I>();
- Status status = this.validateArguments(arguments, convertedArguments);
+ List<I> convertedArguments = new ArrayList<I>();
+ Status status = this.validateArguments(arguments, convertedArguments);
/*
* If the function arguments are not correct, just return an error status immediately
@@ -107,14 +85,16 @@ public class FunctionDefinitionStringConversion<O,I> extends FunctionDefinitionH
// converting TO String
try {
String output = this.getDataTypeArgs().toStringValue(convertedArguments.get(0));
- return ExpressionResult.newSingle(new StdAttributeValue<String>(this.getDataTypeId(), output));
+ return ExpressionResult
+ .newSingle(new StdAttributeValue<String>(this.getDataTypeId(), output));
} catch (Exception e) {
String message = e.getMessage();
if (e.getCause() != null) {
message = e.getCause().getMessage();
}
// untested - not clear how this could happen
- return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " " + message));
+ return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR,
+ this.getShortFunctionId() + " " + message));
}
} else {
// converting FROM String to object of DataType
@@ -126,7 +106,8 @@ public class FunctionDefinitionStringConversion<O,I> extends FunctionDefinitionH
if (e.getCause() != null) {
message = e.getCause().getMessage();
}
- return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_SYNTAX_ERROR, this.getShortFunctionId() + " " + message ));
+ return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_SYNTAX_ERROR, this
+ .getShortFunctionId() + " " + message));
}
}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/38b6d318/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionStringEqualIgnoreCase.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionStringEqualIgnoreCase.java b/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionStringEqualIgnoreCase.java
index 42d557c..21717c0 100644
--- a/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionStringEqualIgnoreCase.java
+++ b/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionStringEqualIgnoreCase.java
@@ -34,27 +34,23 @@ import com.att.research.xacml.api.Identifier;
import com.att.research.xacml.std.datatypes.DataTypes;
/**
- * FunctionDefinitionStringEqualIgnoreCase extends {@link FunctionDefinitionEquality} for
- * <code>String</code> arguments by testing for equality without regard to case.
- *
- * The specification actually says that the strings are first converted to lower case using the string-normalize-to-lower-case function.
- * This code ASSUMES that
+ * FunctionDefinitionStringEqualIgnoreCase extends {@link FunctionDefinitionEquality} for <code>String</code>
+ * arguments by testing for equality without regard to case. The specification actually says that the strings
+ * are first converted to lower case using the string-normalize-to-lower-case function. This code ASSUMES that
* <UL>
- * <LI> the normalize function just calls the Java toLowerCase() function, and
- * <LI> the Java VM is consistent in that equalsIgnoreCase provides the same result as calling toLowerCase on each string and doing a compare.
+ * <LI>the normalize function just calls the Java toLowerCase() function, and
+ * <LI>the Java VM is consistent in that equalsIgnoreCase provides the same result as calling toLowerCase on
+ * each string and doing a compare.
* </UL>
- *
- * In the first implementation of XACML we had separate files for each XACML Function.
- * This release combines multiple Functions in fewer files to minimize code duplication.
- * This file supports the following XACML codes:
- * string-equal-ignore-case
- *
- *
+ * In the first implementation of XACML we had separate files for each XACML Function. This release combines
+ * multiple Functions in fewer files to minimize code duplication. This file supports the following XACML
+ * codes: string-equal-ignore-case
*/
public class FunctionDefinitionStringEqualIgnoreCase extends FunctionDefinitionEquality<String> {
/**
- * ASSUMES that equalsIgnoreCase provides the same result as calling string-normalize-to-lower-case on both strings and then comparing.
+ * ASSUMES that equalsIgnoreCase provides the same result as calling string-normalize-to-lower-case on
+ * both strings and then comparing.
*/
@Override
protected boolean isEqual(String s1, String s2) {
@@ -62,9 +58,11 @@ public class FunctionDefinitionStringEqualIgnoreCase extends FunctionDefinitionE
}
/**
- * Creates a new <code>FunctionDefinitionStringEqualIgnoreCase</code> with the given <code>Identifier</code>.
+ * Creates a new <code>FunctionDefinitionStringEqualIgnoreCase</code> with the given
+ * <code>Identifier</code>.
*
- * @param idIn the <code>Identifier</code> for the new <code>FunctionDefinitionStringEqualIgnoreCase</code>
+ * @param idIn the <code>Identifier</code> for the new
+ * <code>FunctionDefinitionStringEqualIgnoreCase</code>
*/
public FunctionDefinitionStringEqualIgnoreCase(Identifier idIn) {
super(idIn, DataTypes.DT_STRING);
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/38b6d318/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionStringFunctions.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionStringFunctions.java b/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionStringFunctions.java
index 18bf5f8..8a3dcdc 100644
--- a/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionStringFunctions.java
+++ b/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionStringFunctions.java
@@ -30,7 +30,6 @@
*/
package com.att.research.xacmlatt.pdp.std.functions;
-
import java.math.BigInteger;
import java.util.List;
@@ -48,71 +47,67 @@ import com.att.research.xacmlatt.pdp.policy.ExpressionResult;
import com.att.research.xacmlatt.pdp.policy.FunctionArgument;
/**
- * FunctionDefinitionStringFunctions implements {@link com.att.research.xacmlatt.pdp.policy.FunctionDefinition} to
- * implement the XACML String Functions predicates except for the conversions between <code>String</code> and <code>DataType</code>
- * which are contained in <code>FunctionDefinitionStringConversion</code>.
- * The functions in this file do not have a lot in common except that the return data type is known and the input argument types are
- * either known or of the generic type.
- *
- * In the first implementation of XACML we had separate files for each XACML Function.
- * This release combines multiple Functions in fewer files to minimize code duplication.
- * This file supports the following XACML codes:
- * string-concatenate
- * string-starts-with
- * anyURI-starts-with
- * string-ends-with
- * anyURI-ends-with
- * string-contains
- * anyURI-contains
- * string-substring
- * anyURI-substring
- *
- *
+ * FunctionDefinitionStringFunctions implements
+ * {@link com.att.research.xacmlatt.pdp.policy.FunctionDefinition} to implement the XACML String Functions
+ * predicates except for the conversions between <code>String</code> and <code>DataType</code> which are
+ * contained in <code>FunctionDefinitionStringConversion</code>. The functions in this file do not have a lot
+ * in common except that the return data type is known and the input argument types are either known or of the
+ * generic type. In the first implementation of XACML we had separate files for each XACML Function. This
+ * release combines multiple Functions in fewer files to minimize code duplication. This file supports the
+ * following XACML codes: string-concatenate string-starts-with anyURI-starts-with string-ends-with
+ * anyURI-ends-with string-contains anyURI-contains string-substring anyURI-substring
*
* @param <I> the java class for the data type of the function Input arguments
- * @param <O> the java class for the data type of the function Output -
- * needed because different functions within this class have different output types
+ * @param <O> the java class for the data type of the function Output - needed because different functions
+ * within this class have different output types
*/
public class FunctionDefinitionStringFunctions<O, I> extends FunctionDefinitionBase<O, I> {
/**
* List of String operations.
- *
- *
*/
- public enum OPERATION {CONCATENATE, STARTS_WITH, ENDS_WITH, CONTAINS, SUBSTRING };
+ public enum OPERATION {
+ CONCATENATE,
+ STARTS_WITH,
+ ENDS_WITH,
+ CONTAINS,
+ SUBSTRING
+ };
// operation to be used in this instance of the StringFunctions class
private final OPERATION operation;
-
/**
* Constructor - need dataTypeArgs input because of java Generic type-erasure during compilation.
*
* @param idIn
* @param dataTypeArgsIn
*/
- public FunctionDefinitionStringFunctions(Identifier idIn, DataType<O> dataTypeIn, DataType<I> dataTypeArgsIn, OPERATION op) {
+ public FunctionDefinitionStringFunctions(Identifier idIn, DataType<O> dataTypeIn,
+ DataType<I> dataTypeArgsIn, OPERATION op) {
super(idIn, dataTypeIn, dataTypeArgsIn, false);
this.operation = op;
}
-
@SuppressWarnings("incomplete-switch")
@Override
public ExpressionResult evaluate(EvaluationContext evaluationContext, List<FunctionArgument> arguments) {
- if (arguments == null ||
- (operation == OPERATION.CONCATENATE && arguments.size() < 2) ||
- (operation == OPERATION.SUBSTRING && arguments.size() != 3) ||
- (operation != OPERATION.SUBSTRING && operation != OPERATION.CONCATENATE && arguments.size() != 2) ) {
- return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " Expected " +
- ((operation == OPERATION.SUBSTRING) ? 3 : (operation == OPERATION.CONCATENATE ? "2 or more " : 2)) + " arguments, got " +
- ((arguments == null) ? "null" : arguments.size()) ));
+ if (arguments == null
+ || (operation == OPERATION.CONCATENATE && arguments.size() < 2)
+ || (operation == OPERATION.SUBSTRING && arguments.size() != 3)
+ || (operation != OPERATION.SUBSTRING && operation != OPERATION.CONCATENATE && arguments.size() != 2)) {
+ return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR,
+ this.getShortFunctionId()
+ + " Expected "
+ + ((operation == OPERATION.SUBSTRING)
+ ? 3 : (operation == OPERATION.CONCATENATE
+ ? "2 or more " : 2))
+ + " arguments, got "
+ + ((arguments == null) ? "null" : arguments
+ .size())));
}
-
-
ExpressionResult expressionResult = null;
String firstArgumentAsString = null;
@@ -121,106 +116,131 @@ public class FunctionDefinitionStringFunctions<O, I> extends FunctionDefinitionB
Integer secondArgumentAsInteger = null;
Integer thirdArgumentAsInteger = null;
- // most of the functions take 2 args, but SUBSTRING takes 3 AND concatenate takes 2 or more
+ // most of the functions take 2 args, but SUBSTRING takes 3 AND concatenate takes 2 or more
if (operation == OPERATION.CONCATENATE) {
StringBuilder builder = new StringBuilder();
for (int i = 0; i < arguments.size(); i++) {
FunctionArgument functionArgument = arguments.get(i);
- ConvertedArgument<I> convertedArgument = new ConvertedArgument<I>(functionArgument, this.getDataTypeArgs(), false);
- if ( ! convertedArgument.isOk()) {
+ ConvertedArgument<I> convertedArgument = new ConvertedArgument<I>(functionArgument,
+ this.getDataTypeArgs(),
+ false);
+ if (!convertedArgument.isOk()) {
return ExpressionResult.newError(getFunctionStatus(convertedArgument.getStatus()));
}
try {
- String argumentAsString = this.getDataTypeArgs().toStringValue( convertedArgument.getValue());
+ String argumentAsString = this.getDataTypeArgs().toStringValue(convertedArgument
+ .getValue());
builder.append(argumentAsString);
} catch (DataTypeException e) {
String message = e.getMessage();
if (e.getCause() != null) {
message = e.getCause().getMessage();
}
- return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " " + message ));
+ return ExpressionResult
+ .newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this
+ .getShortFunctionId() + " " + message));
}
}
- AttributeValue<String> stringResult = new StdAttributeValue<String>(XACML.ID_DATATYPE_STRING,
- builder.toString() );
+ AttributeValue<String> stringResult = new StdAttributeValue<String>(XACML.ID_DATATYPE_STRING,
+ builder.toString());
expressionResult = ExpressionResult.newSingle(stringResult);
return expressionResult;
} else if (operation == OPERATION.SUBSTRING) {
// first arg is of generic type
FunctionArgument functionArgument = arguments.get(0);
- ConvertedArgument<I> convertedArgument0 = new ConvertedArgument<I>(functionArgument, this.getDataTypeArgs(), false);
- if ( ! convertedArgument0.isOk()) {
+ ConvertedArgument<I> convertedArgument0 = new ConvertedArgument<I>(functionArgument,
+ this.getDataTypeArgs(), false);
+ if (!convertedArgument0.isOk()) {
return ExpressionResult.newError(getFunctionStatus(convertedArgument0.getStatus()));
}
try {
- firstArgumentAsString = this.getDataTypeArgs().toStringValue( convertedArgument0.getValue());
+ firstArgumentAsString = this.getDataTypeArgs().toStringValue(convertedArgument0.getValue());
} catch (DataTypeException e) {
String message = e.getMessage();
if (e.getCause() != null) {
message = e.getCause().getMessage();
}
- return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " " + message ));
+ return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR,
+ this.getShortFunctionId() + " " + message));
}
functionArgument = arguments.get(1);
- ConvertedArgument<BigInteger> convertedArgumentInt = new ConvertedArgument<BigInteger>(functionArgument, DataTypes.DT_INTEGER, false);
- if ( ! convertedArgumentInt.isOk()) {
+ ConvertedArgument<BigInteger> convertedArgumentInt = new ConvertedArgument<BigInteger>(
+ functionArgument,
+ DataTypes.DT_INTEGER,
+ false);
+ if (!convertedArgumentInt.isOk()) {
return ExpressionResult.newError(getFunctionStatus(convertedArgumentInt.getStatus()));
}
secondArgumentAsInteger = convertedArgumentInt.getValue().intValue();
if (secondArgumentAsInteger < 0 || secondArgumentAsInteger > firstArgumentAsString.length()) {
- return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " " +
- "Start point '" + secondArgumentAsInteger + "' out of range 0-" + firstArgumentAsString.length() +
- " for string='" + firstArgumentAsString + "'"));
+ return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR,
+ this.getShortFunctionId() + " "
+ + "Start point '"
+ + secondArgumentAsInteger
+ + "' out of range 0-"
+ + firstArgumentAsString.length()
+ + " for string='" + firstArgumentAsString
+ + "'"));
}
-
functionArgument = arguments.get(2);
- convertedArgumentInt = new ConvertedArgument<BigInteger>(functionArgument, DataTypes.DT_INTEGER, false);
- if ( ! convertedArgumentInt.isOk()) {
+ convertedArgumentInt = new ConvertedArgument<BigInteger>(functionArgument, DataTypes.DT_INTEGER,
+ false);
+ if (!convertedArgumentInt.isOk()) {
return ExpressionResult.newError(getFunctionStatus(convertedArgumentInt.getStatus()));
}
thirdArgumentAsInteger = convertedArgumentInt.getValue().intValue();
// special case: -1 means "to end of string"
if (thirdArgumentAsInteger < -1 || thirdArgumentAsInteger > firstArgumentAsString.length()) {
- return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " " +
- "End point '" + thirdArgumentAsInteger + "' out of range 0-" + firstArgumentAsString.length() +
- " for string='" + firstArgumentAsString + "'"));
+ return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR,
+ this.getShortFunctionId() + " "
+ + "End point '" + thirdArgumentAsInteger
+ + "' out of range 0-"
+ + firstArgumentAsString.length()
+ + " for string='" + firstArgumentAsString
+ + "'"));
}
if (thirdArgumentAsInteger != -1 && thirdArgumentAsInteger < secondArgumentAsInteger) {
- return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " " +
- "End point '" + thirdArgumentAsInteger + "' less than start point '" + secondArgumentAsString + "'" +
- " for string='" + firstArgumentAsString + "'"));
+ return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR,
+ this.getShortFunctionId() + " "
+ + "End point '" + thirdArgumentAsInteger
+ + "' less than start point '"
+ + secondArgumentAsString + "'"
+ + " for string='" + firstArgumentAsString
+ + "'"));
}
} else {
// expect 2 args, one String and one of Generic type
FunctionArgument functionArgument = arguments.get(0);
- ConvertedArgument<String> convertedArgument0 = new ConvertedArgument<String>(functionArgument, DataTypes.DT_STRING, false);
- if ( ! convertedArgument0.isOk()) {
+ ConvertedArgument<String> convertedArgument0 = new ConvertedArgument<String>(functionArgument,
+ DataTypes.DT_STRING,
+ false);
+ if (!convertedArgument0.isOk()) {
return ExpressionResult.newError(getFunctionStatus(convertedArgument0.getStatus()));
}
firstArgumentAsString = convertedArgument0.getValue();
-
functionArgument = arguments.get(1);
- ConvertedArgument<I> convertedArgument1 = new ConvertedArgument<I>(functionArgument, this.getDataTypeArgs(), false);
- if ( ! convertedArgument1.isOk()) {
+ ConvertedArgument<I> convertedArgument1 = new ConvertedArgument<I>(functionArgument,
+ this.getDataTypeArgs(), false);
+ if (!convertedArgument1.isOk()) {
return ExpressionResult.newError(getFunctionStatus(convertedArgument1.getStatus()));
}
try {
- secondArgumentAsString = this.getDataTypeArgs().toStringValue( convertedArgument1.getValue());
+ secondArgumentAsString = this.getDataTypeArgs().toStringValue(convertedArgument1.getValue());
} catch (DataTypeException e) {
String message = e.getMessage();
if (e.getCause() != null) {
message = e.getCause().getMessage();
}
- return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " " + message +
- " " + message ));
+ return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR,
+ this.getShortFunctionId() + " " + message
+ + " " + message));
}
-
}
// arguments are ready - do the operation
@@ -233,7 +253,6 @@ public class FunctionDefinitionStringFunctions<O, I> extends FunctionDefinitionB
return ER_FALSE;
}
-
case ENDS_WITH:
if (secondArgumentAsString.endsWith(firstArgumentAsString)) {
return ER_TRUE;
@@ -256,18 +275,14 @@ public class FunctionDefinitionStringFunctions<O, I> extends FunctionDefinitionB
} else {
substring = firstArgumentAsString.substring(secondArgumentAsInteger, thirdArgumentAsInteger);
}
- AttributeValue<String> stringResult = new StdAttributeValue<String>(XACML.ID_DATATYPE_STRING, substring);
+ AttributeValue<String> stringResult = new StdAttributeValue<String>(XACML.ID_DATATYPE_STRING,
+ substring);
expressionResult = ExpressionResult.newSingle(stringResult);
break;
}
-
return expressionResult;
}
-
-
-
-
}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/38b6d318/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionStringNormalize.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionStringNormalize.java b/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionStringNormalize.java
index 5c24d8b..0abbc3b 100644
--- a/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionStringNormalize.java
+++ b/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionStringNormalize.java
@@ -46,33 +46,28 @@ import com.att.research.xacmlatt.pdp.policy.ExpressionResult;
import com.att.research.xacmlatt.pdp.policy.FunctionArgument;
/**
- * FunctionDefinitionStringNormalize extends {@link com.att.research.xacmlatt.pdp.std.functions.FunctionDefinitionHomogeneousSimple} to
- * implement the XACML String normalization predicates as functions taking one <code>String</code> arg and returning a single value of the same type.
- *
- * In the first implementation of XACML we had separate files for each XACML Function.
- * This release combines multiple Functions in fewer files to minimize code duplication.
- * This file supports the following XACML codes:
- * string-normalize-space
- * string-normalize-to-lower-case
- *
- *
+ * FunctionDefinitionStringNormalize extends
+ * {@link com.att.research.xacmlatt.pdp.std.functions.FunctionDefinitionHomogeneousSimple} to implement the
+ * XACML String normalization predicates as functions taking one <code>String</code> arg and returning a
+ * single value of the same type. In the first implementation of XACML we had separate files for each XACML
+ * Function. This release combines multiple Functions in fewer files to minimize code duplication. This file
+ * supports the following XACML codes: string-normalize-space string-normalize-to-lower-case
*/
public class FunctionDefinitionStringNormalize extends FunctionDefinitionHomogeneousSimple<String, String> {
/**
* List of string normalization operations.
- *
- *
*/
- public enum OPERATION {SPACE, LOWER_CASE };
+ public enum OPERATION {
+ SPACE,
+ LOWER_CASE
+ };
// operation to be used in this instance of the Arightmetic class
private final OPERATION operation;
-
// result variables used by all functions
- AttributeValue<String> result;
-
+ AttributeValue<String> result;
/**
* Constructor
@@ -81,8 +76,9 @@ public class FunctionDefinitionStringNormalize extends FunctionDefinitionHomogen
* @param dataTypeArgsIn
* @param op
*/
- public FunctionDefinitionStringNormalize(Identifier idIn, OPERATION op) {
- // for Arithmetic functions, the output type is the same as the input type (no mixing of Ints and Doubles!)
+ public FunctionDefinitionStringNormalize(Identifier idIn, OPERATION op) {
+ // for Arithmetic functions, the output type is the same as the input type (no mixing of Ints and
+ // Doubles!)
super(idIn, DataTypes.DT_STRING, DataTypeString.newInstance(), 1);
// save the operation and data type to be used in this instance
@@ -90,11 +86,10 @@ public class FunctionDefinitionStringNormalize extends FunctionDefinitionHomogen
}
-
@Override
public ExpressionResult evaluate(EvaluationContext evaluationContext, List<FunctionArgument> arguments) {
List<String> convertedArguments = new ArrayList<String>();
- Status status = this.validateArguments(arguments, convertedArguments);
+ Status status = this.validateArguments(arguments, convertedArguments);
/*
* If the function arguments are not correct, just return an error status immediately
@@ -110,10 +105,11 @@ public class FunctionDefinitionStringNormalize extends FunctionDefinitionHomogen
switch (operation) {
case SPACE:
- result = new StdAttributeValue<String>(XACML.ID_DATATYPE_STRING, convertedArguments.get(0).trim() );
+ result = new StdAttributeValue<String>(XACML.ID_DATATYPE_STRING, convertedArguments.get(0).trim());
break;
case LOWER_CASE:
- result = new StdAttributeValue<String>(XACML.ID_DATATYPE_STRING, convertedArguments.get(0).toLowerCase() );
+ result = new StdAttributeValue<String>(XACML.ID_DATATYPE_STRING, convertedArguments.get(0)
+ .toLowerCase());
break;
}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/38b6d318/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionTimeInRange.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionTimeInRange.java b/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionTimeInRange.java
index 5a66616..e20c34a 100644
--- a/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionTimeInRange.java
+++ b/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionTimeInRange.java
@@ -47,22 +47,14 @@ import com.att.research.xacmlatt.pdp.policy.FunctionArgument;
/**
* FunctionDefinitionTimeInRange implements {@link com.att.research.xacmlatt.pdp.policy.FunctionDefinition} to
* implement the XACML time-in-range predicates as a function taking three arguments of type <code>Time</code>
- * and returning a <code>Boolean</code>.
- *
- * In the first implementation of XACML we had separate files for each XACML Function.
- * This release combines multiple Functions in fewer files to minimize code duplication.
- * This file supports the following XACML codes:
- * time-in-range
- *
- *
+ * and returning a <code>Boolean</code>. In the first implementation of XACML we had separate files for each
+ * XACML Function. This release combines multiple Functions in fewer files to minimize code duplication. This
+ * file supports the following XACML codes: time-in-range
*
* @param <I> the java class for the data type of the function Input arguments.
*/
public class FunctionDefinitionTimeInRange<I> extends FunctionDefinitionHomogeneousSimple<Boolean, I> {
-
-
-
/**
* Constructor - need dataType input because of java Generic type-erasure during compilation.
*
@@ -73,12 +65,11 @@ public class FunctionDefinitionTimeInRange<I> extends FunctionDefinitionHomogene
super(idIn, DataTypes.DT_BOOLEAN, dataTypeArgsIn, 3);
}
-
@Override
public ExpressionResult evaluate(EvaluationContext evaluationContext, List<FunctionArgument> arguments) {
- List<I> convertedArguments = new ArrayList<I>();
- Status status = this.validateArguments(arguments, convertedArguments);
+ List<I> convertedArguments = new ArrayList<I>();
+ Status status = this.validateArguments(arguments, convertedArguments);
/*
* If the function arguments are not correct, just return an error status immediately
@@ -91,24 +82,25 @@ public class FunctionDefinitionTimeInRange<I> extends FunctionDefinitionHomogene
int compareResultHigh;
try {
- compareResultLow = ((ISO8601Time) convertedArguments.get(1)).compareTo((ISO8601Time)convertedArguments.get(0));
- compareResultHigh = ((ISO8601Time)convertedArguments.get(2)).compareTo((ISO8601Time)convertedArguments.get(0));
+ compareResultLow = ((ISO8601Time)convertedArguments.get(1))
+ .compareTo((ISO8601Time)convertedArguments.get(0));
+ compareResultHigh = ((ISO8601Time)convertedArguments.get(2))
+ .compareTo((ISO8601Time)convertedArguments.get(0));
} catch (Exception e) {
String message = e.getMessage();
if (e.getCause() != null) {
message = e.getCause().getMessage();
}
- return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " " + message));
+ return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this
+ .getShortFunctionId() + " " + message));
}
// is arg 0 within the inclusive range of the other two?
- if (compareResultLow <=0 && compareResultHigh >= 0) {
+ if (compareResultLow <= 0 && compareResultHigh >= 0) {
return ER_TRUE;
} else {
return ER_FALSE;
}
}
-
-
}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/38b6d318/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionURIStringConcatenate.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionURIStringConcatenate.java b/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionURIStringConcatenate.java
index 2f91085..92fa9d7 100644
--- a/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionURIStringConcatenate.java
+++ b/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionURIStringConcatenate.java
@@ -46,24 +46,17 @@ import com.att.research.xacmlatt.pdp.policy.ExpressionResult;
import com.att.research.xacmlatt.pdp.policy.FunctionArgument;
/**
- * FunctionDefinitionURIStringConcatenate extends {@link FunctionDefinitionHomogeneousSimple} to
- * implement the XACML uri-string-concatenate predicate as a function taking one <code>URI</code> and one or more <code>String</code> arguments
- * and returning a single <code>URI</code> value.
- *
- * THIS FUNCTION IS DEPRECATED IN 3.0 BUT NOT REMOVED.
- * To provide backward compatibility for previously built XACML policies we include it in our R3 version.
- *
- * In the first implementation of XACML we had separate files for each XACML Function.
- * This release combines multiple Functions in fewer files to minimize code duplication.
- * This file supports the following XACML codes:
- * uri-string-concatenate
- *
- *
+ * FunctionDefinitionURIStringConcatenate extends {@link FunctionDefinitionHomogeneousSimple} to implement the
+ * XACML uri-string-concatenate predicate as a function taking one <code>URI</code> and one or more
+ * <code>String</code> arguments and returning a single <code>URI</code> value. THIS FUNCTION IS DEPRECATED IN
+ * 3.0 BUT NOT REMOVED. To provide backward compatibility for previously built XACML policies we include it in
+ * our R3 version. In the first implementation of XACML we had separate files for each XACML Function. This
+ * release combines multiple Functions in fewer files to minimize code duplication. This file supports the
+ * following XACML codes: uri-string-concatenate
*/
@Deprecated
public class FunctionDefinitionURIStringConcatenate extends FunctionDefinitionBase<URI, URI> {
-
/**
* Constructor
*
@@ -75,19 +68,23 @@ public class FunctionDefinitionURIStringConcatenate extends FunctionDefinitionBa
super(idIn, DataTypes.DT_ANYURI, DataTypes.DT_ANYURI, false);
}
-
@Override
public ExpressionResult evaluate(EvaluationContext evaluationContext, List<FunctionArgument> arguments) {
if (arguments == null || arguments.size() < 2) {
- return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, getShortFunctionId() + " Expected 2 or more arguments, got " +
- ((arguments == null) ? "null" : arguments.size()) ));
+ return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR,
+ getShortFunctionId()
+ + " Expected 2 or more arguments, got "
+ + ((arguments == null) ? "null" : arguments
+ .size())));
}
// get the string to search for
- ConvertedArgument<URI> uriArgument = new ConvertedArgument<URI>(arguments.get(0), DataTypes.DT_ANYURI, false);
- if ( ! uriArgument.isOk()) {
- Status decoratedStatus = new StdStatus(uriArgument.getStatus().getStatusCode(), uriArgument.getStatus().getStatusMessage() + " at arg index 0" );
+ ConvertedArgument<URI> uriArgument = new ConvertedArgument<URI>(arguments.get(0),
+ DataTypes.DT_ANYURI, false);
+ if (!uriArgument.isOk()) {
+ Status decoratedStatus = new StdStatus(uriArgument.getStatus().getStatusCode(), uriArgument
+ .getStatus().getStatusMessage() + " at arg index 0");
return ExpressionResult.newError(getFunctionStatus(decoratedStatus));
}
String uriString = uriArgument.getValue().toString();
@@ -97,17 +94,20 @@ public class FunctionDefinitionURIStringConcatenate extends FunctionDefinitionBa
for (int i = 1; i < arguments.size(); i++) {
- ConvertedArgument<String> stringArgument = new ConvertedArgument<String>(arguments.get(i), DataTypes.DT_STRING, false);
- if ( ! stringArgument.isOk()) {
- Status decoratedStatus = new StdStatus(stringArgument.getStatus().getStatusCode(), stringArgument.getStatus().getStatusMessage() + " at arg index " + i );
+ ConvertedArgument<String> stringArgument = new ConvertedArgument<String>(arguments.get(i),
+ DataTypes.DT_STRING,
+ false);
+ if (!stringArgument.isOk()) {
+ Status decoratedStatus = new StdStatus(stringArgument.getStatus().getStatusCode(),
+ stringArgument.getStatus().getStatusMessage()
+ + " at arg index " + i);
return ExpressionResult.newError(getFunctionStatus(decoratedStatus));
}
- stringValues[i-1] = stringArgument.getValue();
+ stringValues[i - 1] = stringArgument.getValue();
}
-
// add each of the strings onto the URI
for (int i = 0; i < stringValues.length; i++) {
uriString += stringValues[i];
@@ -121,8 +121,9 @@ public class FunctionDefinitionURIStringConcatenate extends FunctionDefinitionBa
if (e.getCause() != null) {
message = e.getCause().getMessage();
}
- return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_SYNTAX_ERROR, getShortFunctionId() +
- " Final string '" + uriString + "' not URI, " + message));
+ return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_SYNTAX_ERROR,
+ getShortFunctionId() + " Final string '"
+ + uriString + "' not URI, " + message));
}
return ExpressionResult.newSingle(new StdAttributeValue<URI>(XACML.ID_DATATYPE_ANYURI, resultURI));
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/38b6d318/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionX500NameMatch.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionX500NameMatch.java b/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionX500NameMatch.java
index e76c102..eeca0ea 100644
--- a/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionX500NameMatch.java
+++ b/openaz-xacml-pdp/src/main/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionX500NameMatch.java
@@ -44,18 +44,15 @@ import com.att.research.xacmlatt.pdp.policy.ExpressionResult;
import com.att.research.xacmlatt.pdp.policy.FunctionArgument;
/**
- * FunctionDefinitionX500NameMatch extends {@link com.att.research.xacmlatt.pdp.std.functions.FunctionDefinitionHomogeneousSimple} to
- * implement the XACML X500Name match predicate as functions taking two <code>X500Name</code> arguments and returning a single <code>Boolean</code> value.
- *
- * In the first implementation of XACML we had separate files for each XACML Function.
- * This release combines multiple Functions in fewer files to minimize code duplication.
- * This file supports the following XACML codes:
- * x500Name-match
- *
- *
+ * FunctionDefinitionX500NameMatch extends
+ * {@link com.att.research.xacmlatt.pdp.std.functions.FunctionDefinitionHomogeneousSimple} to implement the
+ * XACML X500Name match predicate as functions taking two <code>X500Name</code> arguments and returning a
+ * single <code>Boolean</code> value. In the first implementation of XACML we had separate files for each
+ * XACML Function. This release combines multiple Functions in fewer files to minimize code duplication. This
+ * file supports the following XACML codes: x500Name-match
*/
-public class FunctionDefinitionX500NameMatch extends FunctionDefinitionHomogeneousSimple<Boolean, X500Principal> {
-
+public class FunctionDefinitionX500NameMatch extends
+ FunctionDefinitionHomogeneousSimple<Boolean, X500Principal> {
/**
* Constructor
@@ -68,11 +65,10 @@ public class FunctionDefinitionX500NameMatch extends FunctionDefinitionHomogeneo
super(idIn, DataTypes.DT_BOOLEAN, DataTypes.DT_X500NAME, 2);
}
-
@Override
public ExpressionResult evaluate(EvaluationContext evaluationContext, List<FunctionArgument> arguments) {
- List<X500Principal> convertedArguments = new ArrayList<X500Principal>();
- Status status = this.validateArguments(arguments, convertedArguments);
+ List<X500Principal> convertedArguments = new ArrayList<X500Principal>();
+ Status status = this.validateArguments(arguments, convertedArguments);
/*
* If the function arguments are not correct, just return an error status immediately
@@ -86,9 +82,8 @@ public class FunctionDefinitionX500NameMatch extends FunctionDefinitionHomogeneo
*/
/*
- * The spec writer's comments at:
- * https://lists.oasis-open.org/archives/xacml/200906/msg00019.html
- * say that the first sequence must exactly match the END of the second sequence.
+ * The spec writer's comments at: https://lists.oasis-open.org/archives/xacml/200906/msg00019.html say
+ * that the first sequence must exactly match the END of the second sequence.
*/
String[] searchFor = convertedArguments.get(0).getName().split(",");
@@ -103,13 +98,12 @@ public class FunctionDefinitionX500NameMatch extends FunctionDefinitionHomogeneo
for (int i = 0; i < searchFor.length; i++) {
String searchForTerm = searchFor[searchFor.length - i - 1];
String searchInTerm = searchIn[searchIn.length - i - 1];
- if (searchForTerm == null || searchInTerm == null ||
- ! searchForTerm.trim().equals(searchInTerm.trim())) {
+ if (searchForTerm == null || searchInTerm == null
+ || !searchForTerm.trim().equals(searchInTerm.trim())) {
return ER_FALSE;
}
}
-
return ER_TRUE;
}