Package org.apache.hadoop.hbase.security.visibility.expression

Examples of org.apache.hadoop.hbase.security.visibility.expression.ExpressionNode


      throws ParseException {
    // When ! comes, the stack can be empty or top ( or top can be some exp like
    // a&
    // !!.., a!, a&b!, !a! are invalid
    if (!expStack.isEmpty()) {
      ExpressionNode top = expStack.peek();
      if (top.isSingleNode() && top != LeafExpressionNode.OPEN_PARAN_NODE) {
        throw new ParseException("Error parsing expression " + expS + " at column : " + index);
      }
      if (!top.isSingleNode() && ((NonLeafExpressionNode) top).getChildExps().size() != 1) {
        throw new ParseException("Error parsing expression " + expS + " at column : " + index);
      }
    }
    expStack.push(new NonLeafExpressionNode(Operator.NOT));
  }
View Full Code Here


  }

  public static List<Tag> createVisibilityExpTags(String visExpression,
      boolean withSerializationFormat, boolean checkAuths, Set<Integer> auths,
      VisibilityLabelOrdinalProvider ordinalProvider) throws IOException {
    ExpressionNode node = null;
    try {
      node = EXP_PARSER.parse(visExpression);
    } catch (ParseException e) {
      throw new IOException(e);
    }
    node = EXP_EXPANDER.expand(node);
    List<Tag> tags = new ArrayList<Tag>();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(baos);
    List<Integer> labelOrdinals = new ArrayList<Integer>();
    // We will be adding this tag before the visibility tags and the presence of this
    // tag indicates we are supporting deletes with cell visibility
    if (withSerializationFormat) {
      tags.add(VisibilityUtils.SORTED_ORDINAL_SERIALIZATION_FORMAT_TAG);
    }
    if (node.isSingleNode()) {
      getLabelOrdinals(node, labelOrdinals, auths, checkAuths, ordinalProvider);
      writeLabelOrdinalsToStream(labelOrdinals, dos);
      tags.add(new Tag(VISIBILITY_TAG_TYPE, baos.toByteArray()));
      baos.reset();
    } else {
View Full Code Here

  private ExpressionParser parser = new ExpressionParser();

  @Test
  public void testPositiveCases() throws Exception {
    // abc -> (abc)
    ExpressionNode node = parser.parse("abc");
    assertTrue(node instanceof LeafExpressionNode);
    assertEquals("abc", ((LeafExpressionNode) node).getIdentifier());

    // a&b|c&d -> (((a & b) | c) & )
    node = parser.parse("a&b|c&d");
View Full Code Here

    executeNegativeCase("! a");
  }

  @Test
  public void testNonAsciiCases() throws Exception {
    ExpressionNode node = parser.parse(CellVisibility.quote("\u0027") + "&"
        + CellVisibility.quote("\u002b") + "|" + CellVisibility.quote("\u002d") + "&"
        + CellVisibility.quote("\u003f"));
    assertTrue(node instanceof NonLeafExpressionNode);
    NonLeafExpressionNode nlNode = (NonLeafExpressionNode) node;
    assertEquals(Operator.AND, nlNode.getOperator());
View Full Code Here

    assertEquals("\u0027", ((LeafExpressionNode) nlNode.getChildExps().get(0)).getIdentifier());
  }

  @Test
  public void testCasesSeperatedByDoubleQuotes() throws Exception {
    ExpressionNode node = null;
    try {
      node = parser.parse("\u0027&\"|\u002b&\u003f");
      fail("Excpetion must be thrown as there are special characters without quotes");
    } catch (ParseException e) {
    }
View Full Code Here

  }

  @Override
  public List<Tag> createVisibilityExpTags(String visExpression, boolean withSerializationFormat,
      boolean checkAuths) throws IOException {
    ExpressionNode node = null;
    try {
      node = this.expressionParser.parse(visExpression);
    } catch (ParseException e) {
      throw new IOException(e);
    }
View Full Code Here

  private ExpressionParser parser = new ExpressionParser();

  @Test
  public void testPositiveCases() throws Exception {
    // abc -> (abc)
    ExpressionNode node = parser.parse("abc");
    assertTrue(node instanceof LeafExpressionNode);
    assertEquals("abc", ((LeafExpressionNode) node).getIdentifier());

    // a&b|c&d -> (((a & b) | c) & )
    node = parser.parse("a&b|c&d");
View Full Code Here

    executeNegativeCase("! a");
  }

  @Test
  public void testNonAsciiCases() throws Exception {
    ExpressionNode node = parser.parse(CellVisibility.quote("\u0027") + "&"
        + CellVisibility.quote("\u002b") + "|" + CellVisibility.quote("\u002d") + "&"
        + CellVisibility.quote("\u003f"));
    assertTrue(node instanceof NonLeafExpressionNode);
    NonLeafExpressionNode nlNode = (NonLeafExpressionNode) node;
    assertEquals(Operator.AND, nlNode.getOperator());
View Full Code Here

    assertEquals("\u0027", ((LeafExpressionNode) nlNode.getChildExps().get(0)).getIdentifier());
  }

  @Test
  public void testCasesSeperatedByDoubleQuotes() throws Exception {
    ExpressionNode node = null;
    try {
      node = parser.parse("\u0027&\"|\u002b&\u003f");
      fail("Excpetion must be thrown as there are special characters without quotes");
    } catch (ParseException e) {
    }
View Full Code Here

  }

  @Override
  public List<Tag> createVisibilityExpTags(String visExpression, boolean withSerializationFormat,
      boolean checkAuths) throws IOException {
    ExpressionNode node = null;
    try {
      node = this.expressionParser.parse(visExpression);
    } catch (ParseException e) {
      throw new IOException(e);
    }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.security.visibility.expression.ExpressionNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.