@Test public void testActionAll() throws Exception { Privilege coll1All = create(new KeyValue("collection", "coll1"), new KeyValue("action", ALL)); Privilege coll1Update = create(new KeyValue("collection", "coll1"), new KeyValue("action", "update")); Privilege 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)); Privilege coll1 = create(new KeyValue("collection", "coll1")); assertTrue(coll1All.implies(coll1)); assertTrue(coll1.implies(coll1All)); }
@Override public boolean implies(Privilege p) { if (!(p instanceof SearchWildcardPrivilege)) { return false; } SearchWildcardPrivilege wp = (SearchWildcardPrivilege) p; List<KeyValue> otherParts = wp.parts; if(equals(wp)) { return true; } int index = 0; for (KeyValue otherPart : otherParts) { if (parts.size() - 1 < index) { return true; } else { KeyValue part = parts.get(index); if(!part.getKey().equalsIgnoreCase(otherPart.getKey())) { return false; } if (!impliesKeyValue(part, otherPart)) { return false; } index++; } } for (; index < parts.size(); index++) { KeyValue part = parts.get(index); if (!part.getValue().equals(SearchConstants.ALL)) { return false; } } return true; }
SearchWildcardPrivilege implements Privilege { @Override public boolean implies(Privilege p) { if (!(p instanceof SearchWildcardPrivilege)) { return false; } SearchWildcardPrivilege wp = (SearchWildcardPrivilege) p; List<KeyValue> otherParts = wp.parts; if(equals(wp)) { return true; } int index = 0; for (KeyValue otherPart : otherParts) { if (parts.size() - 1 < index) { return true; } else { KeyValue part = parts.get(index); if(!part.getKey().equalsIgnoreCase(otherPart.getKey())) { return false; } if (!impliesKeyValue(part, otherPart)) { return false; } index++; } } for (; index < parts.size(); index++) { KeyValue part = parts.get(index); if (!part.getValue().equals(SearchConstants.ALL)) { return false; } } return true; } }
SearchWildcardPrivilege implements Privilege { @Override public boolean implies(Privilege p) { if (!(p instanceof SearchWildcardPrivilege)) { return false; } SearchWildcardPrivilege wp = (SearchWildcardPrivilege) p; List<KeyValue> otherParts = wp.parts; if(equals(wp)) { return true; } int index = 0; for (KeyValue otherPart : otherParts) { if (parts.size() - 1 < index) { return true; } else { KeyValue part = parts.get(index); if(!part.getKey().equalsIgnoreCase(otherPart.getKey())) { return false; } if (!impliesKeyValue(part, otherPart)) { return false; } index++; } } for (; index < parts.size(); index++) { KeyValue part = parts.get(index); if (!part.getValue().equals(SearchConstants.ALL)) { return false; } } return true; } SearchWildcardPrivilege(String wildcardString); }
SearchWildcardPrivilege implements Privilege { @Override public boolean implies(Privilege p) { if (!(p instanceof SearchWildcardPrivilege)) { return false; } SearchWildcardPrivilege wp = (SearchWildcardPrivilege) p; List<KeyValue> otherParts = wp.parts; if(equals(wp)) { return true; } int index = 0; for (KeyValue otherPart : otherParts) { if (parts.size() - 1 < index) { return true; } else { KeyValue part = parts.get(index); if(!part.getKey().equalsIgnoreCase(otherPart.getKey())) { return false; } if (!impliesKeyValue(part, otherPart)) { return false; } index++; } } for (; index < parts.size(); index++) { KeyValue part = parts.get(index); if (!part.getValue().equals(SearchConstants.ALL)) { return false; } } return true; } SearchWildcardPrivilege(String wildcardString); @Override boolean implies(Privilege p); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); }
SearchWildcardPrivilege implements Privilege { @Override public boolean implies(Privilege p) { if (!(p instanceof SearchWildcardPrivilege)) { return false; } SearchWildcardPrivilege wp = (SearchWildcardPrivilege) p; List<KeyValue> otherParts = wp.parts; if(equals(wp)) { return true; } int index = 0; for (KeyValue otherPart : otherParts) { if (parts.size() - 1 < index) { return true; } else { KeyValue part = parts.get(index); if(!part.getKey().equalsIgnoreCase(otherPart.getKey())) { return false; } if (!impliesKeyValue(part, otherPart)) { return false; } index++; } } for (; index < parts.size(); index++) { KeyValue part = parts.get(index); if (!part.getValue().equals(SearchConstants.ALL)) { return false; } } return true; } SearchWildcardPrivilege(String wildcardString); @Override boolean implies(Privilege p); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode();  }