@Test public void testActionAll() throws Exception { assertTrue(KAFKA_HOST1_ALL.implies(KAFKA_HOST1_READ)); assertTrue(KAFKA_HOST1_ALL.implies(KAFKA_HOST1_WRITE)); assertTrue(KAFKA_HOST1_TOPIC1_ALL.implies(KAFKA_HOST1_TOPIC1_READ)); assertTrue(KAFKA_HOST1_TOPIC1_ALL.implies(KAFKA_HOST1_TOPIC1_WRITE)); assertTrue(KAFKA_HOST1_CLUSTER1_ALL.implies(KAFKA_HOST1_CLUSTER1_READ)); assertTrue(KAFKA_HOST1_CLUSTER1_ALL.implies(KAFKA_HOST1_CLUSTER1_WRITE)); assertTrue(KAFKA_HOST1_GROUP1_ALL.implies(KAFKA_HOST1_GROUP1_READ)); assertTrue(KAFKA_HOST1_GROUP1_ALL.implies(KAFKA_HOST1_GROUP1_WRITE)); }
@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();  }