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

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


    return true;
  }

  private List<Tag> createVisibilityTags(String visibilityLabelsExp) throws IOException,
      ParseException, InvalidLabelException {
    ExpressionNode node = null;
    node = this.expressionParser.parse(visibilityLabelsExp);
    node = this.expressionExpander.expand(node);
    List<Tag> tags = new ArrayList<Tag>();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(baos);
    if (node.isSingleNode()) {
      writeLabelOrdinalsToStream(node, dos);
      tags.add(new Tag(VisibilityUtils.VISIBILITY_TAG_TYPE, baos.toByteArray()));
      baos.reset();
    } else {
      NonLeafExpressionNode nlNode = (NonLeafExpressionNode) node;
View Full Code Here


    return true;
  }

  private List<Tag> createVisibilityTags(String visibilityLabelsExp) throws IOException,
      ParseException, InvalidLabelException {
    ExpressionNode node = null;
    node = this.expressionParser.parse(visibilityLabelsExp);
    node = this.expressionExpander.expand(node);
    List<Tag> tags = new ArrayList<Tag>();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(baos);
    if (node.isSingleNode()) {
      writeLabelOrdinalsToStream(node, dos);
      tags.add(new Tag(VisibilityUtils.VISIBILITY_TAG_TYPE, baos.toByteArray()));
      baos.reset();
    } else {
      NonLeafExpressionNode nlNode = (NonLeafExpressionNode) node;
View Full Code Here

  }

  private List<Tag> createVisibilityTags(String visibilityLabelsExp, boolean addSerializationTag,
      Set<Integer> auths, String userName) throws IOException, ParseException,
      InvalidLabelException {
    ExpressionNode node = null;
    node = this.expressionParser.parse(visibilityLabelsExp);
    node = this.expressionExpander.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 (addSerializationTag) {
      tags.add(VisibilityUtils.VIS_SERIALIZATION_TAG);
    }
    if (node.isSingleNode()) {
      getLabelOrdinals(node, labelOrdinals, auths, userName);
      writeLabelOrdinalsToStream(labelOrdinals, dos);
      tags.add(new Tag(VisibilityUtils.VISIBILITY_TAG_TYPE, baos.toByteArray()));
      baos.reset();
    } else {
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

  }

  @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

      index++;
    }
    if (expStack.size() != 1) {
      throw new ParseException("Error parsing expression " + expS);
    }
    ExpressionNode top = expStack.pop();
    if (top == LeafExpressionNode.OPEN_PARAN_NODE) {
      throw new ParseException("Error parsing expression " + expS);
    }
    if (top instanceof NonLeafExpressionNode) {
      NonLeafExpressionNode nlTop = (NonLeafExpressionNode) top;
View Full Code Here

    if (expStack.size() < 2) {
      // When ) comes we expect atleast a ( node and another leaf/non leaf node
      // in stack.
      throw new ParseException();
    } else {
      ExpressionNode top = expStack.pop();
      ExpressionNode secondTop = expStack.pop();
      // The second top must be a ( node and top should not be a ). Top can be
      // any thing else
      if (top == LeafExpressionNode.OPEN_PARAN_NODE
          || secondTop != LeafExpressionNode.OPEN_PARAN_NODE) {
        throw new ParseException("Error parsing expression " + expS + " at column : " + index);
      }
      // a&(b|) is not valid.
      // The top can be a ! node but with exactly child nodes. !).. is invalid
      // Other NonLeafExpressionNode , then there should be exactly 2 child.
      // (a&) is not valid.
      if (top instanceof NonLeafExpressionNode) {
        NonLeafExpressionNode nlTop = (NonLeafExpressionNode) top;
        if ((nlTop.getOperator() == Operator.NOT && nlTop.getChildExps().size() != 1)
            || (nlTop.getOperator() != Operator.NOT && nlTop.getChildExps().size() != 2)) {
          throw new ParseException("Error parsing expression " + expS + " at column : " + index);
        }
      }
      // When (a|b)&(c|d) comes while processing the second ) there will be
      // already (a|b)& node
      // avail in the stack. The top will be c|d node. We need to take it out
      // and combine as one
      // node.
      if (!expStack.isEmpty()) {
        ExpressionNode thirdTop = expStack.peek();
        if (thirdTop instanceof NonLeafExpressionNode) {
          NonLeafExpressionNode nlThirdTop = (NonLeafExpressionNode) expStack.pop();
          nlThirdTop.addChildExp(top);
          if (nlThirdTop.getOperator() == Operator.NOT) {
            // It is a NOT node. So there may be a NonLeafExpressionNode below
            // it to which the
            // completed NOT can be added now.
            if (!expStack.isEmpty()) {
              ExpressionNode fourthTop = expStack.peek();
              if (fourthTop instanceof NonLeafExpressionNode) {
                // Its Operator will be OR or AND
                NonLeafExpressionNode nlFourthTop = (NonLeafExpressionNode) fourthTop;
                assert nlFourthTop.getOperator() != Operator.NOT;
                // Also for sure its number of children will be 1
View Full Code Here

  }

  private void processOpenParan(Stack<ExpressionNode> expStack, String expS, int index)
      throws ParseException {
    if (!expStack.isEmpty()) {
      ExpressionNode top = expStack.peek();
      // Top can not be a Label Node. a(.. is not valid. but ((a.. is fine.
      if (top instanceof LeafExpressionNode && top != LeafExpressionNode.OPEN_PARAN_NODE) {
        throw new ParseException("Error parsing expression " + expS + " at column : " + index);
      } else if (top instanceof NonLeafExpressionNode) {
        // Top is non leaf.
View Full Code Here

  private void processLabelExpNode(LeafExpressionNode node, Stack<ExpressionNode> expStack,
      String expS, int index) throws ParseException {
    if (expStack.isEmpty()) {
      expStack.push(node);
    } else {
      ExpressionNode top = expStack.peek();
      if (top == LeafExpressionNode.OPEN_PARAN_NODE) {
        expStack.push(node);
      } else if (top instanceof NonLeafExpressionNode) {
        NonLeafExpressionNode nlTop = (NonLeafExpressionNode) expStack.pop();
        nlTop.addChildExp(node);
        if (nlTop.getOperator() == Operator.NOT && !expStack.isEmpty()) {
          ExpressionNode secondTop = expStack.peek();
          if (secondTop == LeafExpressionNode.OPEN_PARAN_NODE) {
            expStack.push(nlTop);
          } else if (secondTop instanceof NonLeafExpressionNode) {
            ((NonLeafExpressionNode) secondTop).addChildExp(nlTop);
          }
View Full Code Here

  private void processANDorOROp(Operator op, Stack<ExpressionNode> expStack, String expS, int index)
      throws ParseException {
    if (expStack.isEmpty()) {
      throw new ParseException("Error parsing expression " + expS + " at column : " + index);
    }
    ExpressionNode top = expStack.pop();
    if (top.isSingleNode()) {
      if (top == LeafExpressionNode.OPEN_PARAN_NODE) {
        throw new ParseException("Error parsing expression " + expS + " at column : " + index);
      }
      expStack.push(new NonLeafExpressionNode(op, top));
    } else {
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.