@Test public void testUnexpected() throws Exception { Privilege p = new Privilege() { @Override public boolean implies(Privilege p) { return false; } }; Privilege topic1 = create(new KeyValue("HOST", "host"), new KeyValue("TOPIC", "topic1")); assertFalse(topic1.implies(null)); assertFalse(topic1.implies(p)); assertFalse(topic1.equals(null)); assertFalse(topic1.equals(p)); }
@Override public boolean implies(Privilege p) { if (!(p instanceof KafkaWildcardPrivilege)) { return false; } KafkaWildcardPrivilege wp = (KafkaWildcardPrivilege)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(KafkaActionConstant.actionName) && !(otherPart.getKey().equalsIgnoreCase(KafkaActionConstant.actionName))) { continue; } 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(KafkaActionConstant.ALL)) { return false; } } return true; }
KafkaWildcardPrivilege implements Privilege { @Override public boolean implies(Privilege p) { if (!(p instanceof KafkaWildcardPrivilege)) { return false; } KafkaWildcardPrivilege wp = (KafkaWildcardPrivilege)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(KafkaActionConstant.actionName) && !(otherPart.getKey().equalsIgnoreCase(KafkaActionConstant.actionName))) { continue; } 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(KafkaActionConstant.ALL)) { return false; } } return true; } }
KafkaWildcardPrivilege implements Privilege { @Override public boolean implies(Privilege p) { if (!(p instanceof KafkaWildcardPrivilege)) { return false; } KafkaWildcardPrivilege wp = (KafkaWildcardPrivilege)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(KafkaActionConstant.actionName) && !(otherPart.getKey().equalsIgnoreCase(KafkaActionConstant.actionName))) { continue; } 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(KafkaActionConstant.ALL)) { return false; } } return true; } KafkaWildcardPrivilege(String permission); }
KafkaWildcardPrivilege implements Privilege { @Override public boolean implies(Privilege p) { if (!(p instanceof KafkaWildcardPrivilege)) { return false; } KafkaWildcardPrivilege wp = (KafkaWildcardPrivilege)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(KafkaActionConstant.actionName) && !(otherPart.getKey().equalsIgnoreCase(KafkaActionConstant.actionName))) { continue; } 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(KafkaActionConstant.ALL)) { return false; } } return true; } KafkaWildcardPrivilege(String permission); @Override boolean implies(Privilege p); @Override String toString(); }
KafkaWildcardPrivilege implements Privilege { @Override public boolean implies(Privilege p) { if (!(p instanceof KafkaWildcardPrivilege)) { return false; } KafkaWildcardPrivilege wp = (KafkaWildcardPrivilege)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(KafkaActionConstant.actionName) && !(otherPart.getKey().equalsIgnoreCase(KafkaActionConstant.actionName))) { continue; } 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(KafkaActionConstant.ALL)) { return false; } } return true; } KafkaWildcardPrivilege(String permission); @Override boolean implies(Privilege p); @Override String toString();  }