keith-turner commented on code in PR #96:
URL: https://github.com/apache/accumulo-access/pull/96#discussion_r2677818827
##########
core/src/main/java/org/apache/accumulo/access/impl/AccessEvaluatorImpl.java:
##########
@@ -143,20 +157,29 @@ public boolean canAccess(AccessExpression expression) {
@Override
public boolean canAccess(String expression) throws
InvalidAccessExpressionException {
- return evaluate(expression.getBytes(UTF_8));
- }
-
- @Override
- public boolean canAccess(byte[] expression) throws
InvalidAccessExpressionException {
return evaluate(expression);
}
- boolean evaluate(byte[] accessExpression) throws
InvalidAccessExpressionException {
- var bytesWrapper = ParserEvaluator.lookupWrappers.get();
+ boolean evaluate(String accessExpression) throws
InvalidAccessExpressionException {
+ var charsWrapper = ParserEvaluator.lookupWrappers.get();
Predicate<Tokenizer.AuthorizationToken> atp = authToken -> {
- bytesWrapper.set(authToken.data, authToken.start, authToken.len);
- return authorizedPredicate.test(bytesWrapper);
+ var authorization = ParserEvaluator.unescape(authToken, charsWrapper);
+ if (!authorizationValidator.test(authorization, authToken.quoting)) {
+ throw new InvalidAuthorizationException(authorization.toString());
+ }
+ return authorizedPredicate.test(authorization);
+ };
+
+ // This is used once the expression is known to always be true or false.
For this case only need
+ // to validate authorizations, do not need to look them up in a set.
+ Predicate<Tokenizer.AuthorizationToken> shortCircuit = authToken -> {
+ var authorization = ParserEvaluator.unescape(authToken, charsWrapper);
+ if (!authorizationValidator.test(authorization, authToken.quoting)) {
Review Comment:
Added checks in the API entry points to fail fast if null. In this impl
code it should be null, but it if it is then NPE would indicate a bug.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]