@Test public void testWildcardLeftTermination() { WildcardPermission p1, p2, p3, p4; p1 = new WildcardPermission("one"); p2 = new WildcardPermission("one:*"); p3 = new WildcardPermission("one:*:*"); p4 = new WildcardPermission("one:read"); assertTrue(p1.implies(p2)); assertTrue(p1.implies(p3)); assertTrue(p1.implies(p4)); assertTrue(p2.implies(p1)); assertTrue(p2.implies(p3)); assertTrue(p2.implies(p4)); assertTrue(p3.implies(p1)); assertTrue(p3.implies(p2)); assertTrue(p3.implies(p4)); assertFalse(p4.implies(p1)); assertFalse(p4.implies(p2)); assertFalse(p4.implies(p3)); }
public boolean implies(Permission p) { if (!(p instanceof WildcardPermission)) { return false; } WildcardPermission wp = (WildcardPermission) p; List<Set<String>> otherParts = wp.getParts(); int i = 0; for (Set<String> otherPart : otherParts) { if (getParts().size() - 1 < i) { return true; } else { Set<String> part = getParts().get(i); if (!part.contains(WILDCARD_TOKEN) && !part.containsAll(otherPart)) { return false; } i++; } } for (; i < getParts().size(); i++) { Set<String> part = getParts().get(i); if (!part.contains(WILDCARD_TOKEN)) { return false; } } return true; }
WildcardPermission implements Permission, Serializable { public boolean implies(Permission p) { if (!(p instanceof WildcardPermission)) { return false; } WildcardPermission wp = (WildcardPermission) p; List<Set<String>> otherParts = wp.getParts(); int i = 0; for (Set<String> otherPart : otherParts) { if (getParts().size() - 1 < i) { return true; } else { Set<String> part = getParts().get(i); if (!part.contains(WILDCARD_TOKEN) && !part.containsAll(otherPart)) { return false; } i++; } } for (; i < getParts().size(); i++) { Set<String> part = getParts().get(i); if (!part.contains(WILDCARD_TOKEN)) { return false; } } return true; } }
WildcardPermission implements Permission, Serializable { public boolean implies(Permission p) { if (!(p instanceof WildcardPermission)) { return false; } WildcardPermission wp = (WildcardPermission) p; List<Set<String>> otherParts = wp.getParts(); int i = 0; for (Set<String> otherPart : otherParts) { if (getParts().size() - 1 < i) { return true; } else { Set<String> part = getParts().get(i); if (!part.contains(WILDCARD_TOKEN) && !part.containsAll(otherPart)) { return false; } i++; } } for (; i < getParts().size(); i++) { Set<String> part = getParts().get(i); if (!part.contains(WILDCARD_TOKEN)) { return false; } } return true; } protected  WildcardPermission();  WildcardPermission(String wildcardString);  WildcardPermission(String wildcardString, boolean caseSensitive); }
WildcardPermission implements Permission, Serializable { public boolean implies(Permission p) { if (!(p instanceof WildcardPermission)) { return false; } WildcardPermission wp = (WildcardPermission) p; List<Set<String>> otherParts = wp.getParts(); int i = 0; for (Set<String> otherPart : otherParts) { if (getParts().size() - 1 < i) { return true; } else { Set<String> part = getParts().get(i); if (!part.contains(WILDCARD_TOKEN) && !part.containsAll(otherPart)) { return false; } i++; } } for (; i < getParts().size(); i++) { Set<String> part = getParts().get(i); if (!part.contains(WILDCARD_TOKEN)) { return false; } } return true; } protected  WildcardPermission();  WildcardPermission(String wildcardString);  WildcardPermission(String wildcardString, boolean caseSensitive); boolean implies(Permission p); String toString(); boolean equals(Object o); int hashCode(); }
WildcardPermission implements Permission, Serializable { public boolean implies(Permission p) { if (!(p instanceof WildcardPermission)) { return false; } WildcardPermission wp = (WildcardPermission) p; List<Set<String>> otherParts = wp.getParts(); int i = 0; for (Set<String> otherPart : otherParts) { if (getParts().size() - 1 < i) { return true; } else { Set<String> part = getParts().get(i); if (!part.contains(WILDCARD_TOKEN) && !part.containsAll(otherPart)) { return false; } i++; } } for (; i < getParts().size(); i++) { Set<String> part = getParts().get(i); if (!part.contains(WILDCARD_TOKEN)) { return false; } } return true; } protected  WildcardPermission();  WildcardPermission(String wildcardString);  WildcardPermission(String wildcardString, boolean caseSensitive); boolean implies(Permission p); String toString(); boolean equals(Object o); int hashCode();  }