@Test public void testUnexpected() throws Exception { Privilege p = new Privilege() { @Override public boolean implies(Privilege p) { return false; } }; Privilege job1 = create(new KeyValue("SERVER", "server"), new KeyValue("JOB", "job1")); assertFalse(job1.implies(null)); assertFalse(job1.implies(p)); assertFalse(job1.equals(null)); assertFalse(job1.equals(p)); }
@Override public boolean implies(Privilege p) { if (!(p instanceof SqoopWildcardPrivilege)) { return false; } SqoopWildcardPrivilege wp = (SqoopWildcardPrivilege)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(SqoopActionConstant.NAME) && !(otherPart.getKey().equalsIgnoreCase(SqoopActionConstant.NAME))) { 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(SqoopActionConstant.ALL)) { return false; } } return true; }
SqoopWildcardPrivilege implements Privilege { @Override public boolean implies(Privilege p) { if (!(p instanceof SqoopWildcardPrivilege)) { return false; } SqoopWildcardPrivilege wp = (SqoopWildcardPrivilege)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(SqoopActionConstant.NAME) && !(otherPart.getKey().equalsIgnoreCase(SqoopActionConstant.NAME))) { 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(SqoopActionConstant.ALL)) { return false; } } return true; } }
SqoopWildcardPrivilege implements Privilege { @Override public boolean implies(Privilege p) { if (!(p instanceof SqoopWildcardPrivilege)) { return false; } SqoopWildcardPrivilege wp = (SqoopWildcardPrivilege)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(SqoopActionConstant.NAME) && !(otherPart.getKey().equalsIgnoreCase(SqoopActionConstant.NAME))) { 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(SqoopActionConstant.ALL)) { return false; } } return true; } SqoopWildcardPrivilege(String permission); }
SqoopWildcardPrivilege implements Privilege { @Override public boolean implies(Privilege p) { if (!(p instanceof SqoopWildcardPrivilege)) { return false; } SqoopWildcardPrivilege wp = (SqoopWildcardPrivilege)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(SqoopActionConstant.NAME) && !(otherPart.getKey().equalsIgnoreCase(SqoopActionConstant.NAME))) { 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(SqoopActionConstant.ALL)) { return false; } } return true; } SqoopWildcardPrivilege(String permission); @Override boolean implies(Privilege p); }
SqoopWildcardPrivilege implements Privilege { @Override public boolean implies(Privilege p) { if (!(p instanceof SqoopWildcardPrivilege)) { return false; } SqoopWildcardPrivilege wp = (SqoopWildcardPrivilege)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(SqoopActionConstant.NAME) && !(otherPart.getKey().equalsIgnoreCase(SqoopActionConstant.NAME))) { 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(SqoopActionConstant.ALL)) { return false; } } return true; } SqoopWildcardPrivilege(String permission); @Override boolean implies(Privilege p);  }