Package org.apache.sentry.provider.file

Examples of org.apache.sentry.provider.file.KeyValue


      }
    }
    return null;
  }
  public static DBModelAuthorizable from(String s) {
    return from(new KeyValue(s));
  }
View Full Code Here


    List<KeyValue>parts = Lists.newArrayList();
    for (String authorizable : AUTHORIZABLE_SPLITTER.trimResults().split(wildcardString)) {
      if (authorizable.isEmpty()) {
        throw new IllegalArgumentException("Privilege '" + wildcardString + "' has an empty section");
      }
      parts.add(new KeyValue(authorizable));
    }
    if (parts.isEmpty()) {
      throw new AssertionError("Should never occur: " + wildcardString);
    }
    this.parts = ImmutableList.copyOf(parts);
View Full Code Here

      // after the number of parts contained
      // in this permission is automatically implied, so return true
      if (parts.size() - 1 < index) {
        return true;
      } else {
        KeyValue part = parts.get(index);
        // are the keys even equal
        if(!part.getKey().equalsIgnoreCase(otherPart.getKey())) {
          return false;
        }
        if (!impliesKeyValue(part, otherPart)) {
          return false;
        }
        index++;
      }
    }
    // If this permission has more parts than
    // the other parts, only imply it if
    // all of the other parts are wildcards
    for (; index < parts.size(); index++) {
      KeyValue part = parts.get(index);
      if (!part.getValue().equals(SearchConstants.ALL)) {
        return false;
      }
    }

    return true;
View Full Code Here

    List<KeyValue>parts = Lists.newArrayList();
    for (String authorizable : AUTHORIZABLE_SPLITTER.trimResults().split(wildcardString)) {
      if (authorizable.isEmpty()) {
        throw new IllegalArgumentException("Privilege '" + wildcardString + "' has an empty section");
      }
      parts.add(new KeyValue(authorizable));
    }
    if (parts.isEmpty()) {
      throw new AssertionError("Should never occur: " + wildcardString);
    }
    this.parts = ImmutableList.copyOf(parts);
View Full Code Here

      // after the number of parts contained
      // in this permission is automatically implied, so return true
      if (parts.size() - 1 < index) {
        return true;
      } else {
        KeyValue part = parts.get(index);
        // are the keys even equal
        if(!part.getKey().equalsIgnoreCase(otherPart.getKey())) {
          return false;
        }
        if (!impliesKeyValue(part, otherPart)) {
          return false;
        }
        index++;
      }
    }
    // If this permission has more parts than
    // the other parts, only imply it if
    // all of the other parts are wildcards
    for (; index < parts.size(); index++) {
      KeyValue part = parts.get(index);
      if (!part.getValue().equals(AccessConstants.ALL)) {
        return false;
      }
    }

    return true;
View Full Code Here

  private static final String ALL = SearchConstants.ALL;

  @Test
  public void testSimpleNoAction() throws Exception {
    Permission collection1 = create(new KeyValue("collection", "coll1"));
    Permission collection2 = create(new KeyValue("collection", "coll2"));
    Permission collection1Case = create(new KeyValue("colleCtIon", "coLl1"));

    assertTrue(collection1.implies(collection1));
    assertTrue(collection2.implies(collection2));
    assertTrue(collection1.implies(collection1Case));
    assertTrue(collection1Case.implies(collection1));
View Full Code Here

  }

  @Test
  public void testSimpleAction() throws Exception {
    Permission query =
      create(new KeyValue("collection", "coll1"), new KeyValue("action", "query"));
    Permission update =
      create(new KeyValue("collection", "coll1"), new KeyValue("action", "update"));
    Permission queryCase =
      create(new KeyValue("colleCtIon", "coLl1"), new KeyValue("AcTiOn", "QuERy"));

    assertTrue(query.implies(query));
    assertTrue(update.implies(update));
    assertTrue(query.implies(queryCase));
    assertTrue(queryCase.implies(query));
View Full Code Here

    assertFalse(update.implies(queryCase));
  }

  @Test
  public void testRoleShorterThanRequest() throws Exception {
    Permission collection1 = create(new KeyValue("collection", "coll1"));
    Permission query =
      create(new KeyValue("collection", "coll1"), new KeyValue("action", "query"));
    Permission update =
      create(new KeyValue("collection", "coll1"), new KeyValue("action", "update"));
    Permission all =
      create(new KeyValue("collection", "coll1"), new KeyValue("action", ALL));

    assertTrue(collection1.implies(query));
    assertTrue(collection1.implies(update));
    assertTrue(collection1.implies(all));
View Full Code Here

    assertTrue(all.implies(collection1));
  }

  @Test
  public void testCollectionAll() throws Exception {
    Permission collectionAll = create(new KeyValue("collection", ALL));
    Permission collection1 = create(new KeyValue("collection", "coll1"));
    assertTrue(collectionAll.implies(collection1));
    assertTrue(collection1.implies(collectionAll));

    Permission allUpdate =
      create(new KeyValue("collection", ALL), new KeyValue("action", "update"));
    Permission allQuery =
      create(new KeyValue("collection", ALL), new KeyValue("action", "query"));
    Permission coll1Update =
      create(new KeyValue("collection", "coll1"), new KeyValue("action", "update"));
    Permission coll1Query =
      create(new KeyValue("collection", "coll1"), new KeyValue("action", "query"));
    assertTrue(allUpdate.implies(coll1Update));
    assertTrue(allQuery.implies(coll1Query));
    assertTrue(coll1Update.implies(allUpdate));
    assertTrue(coll1Query.implies(allQuery));
    assertFalse(allUpdate.implies(coll1Query));
View Full Code Here

  }

  @Test
  public void testActionAll() throws Exception {
    Permission coll1All =
       create(new KeyValue("collection", "coll1"), new KeyValue("action", ALL));
    Permission coll1Update =
      create(new KeyValue("collection", "coll1"), new KeyValue("action", "update"));
    Permission coll1Query =
      create(new KeyValue("collection", "coll1"), new KeyValue("action", "query"));
    assertTrue(coll1All.implies(coll1All));
    assertTrue(coll1All.implies(coll1Update));
    assertTrue(coll1All.implies(coll1Query));
    assertFalse(coll1Update.implies(coll1All));
    assertFalse(coll1Query.implies(coll1All));

    // test different lengths
    Permission coll1 =
       create(new KeyValue("collection", "coll1"));
    assertTrue(coll1All.implies(coll1));
    assertTrue(coll1.implies(coll1All));
  }
View Full Code Here

TOP

Related Classes of org.apache.sentry.provider.file.KeyValue

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.