@Test public void testCanNotGetAccessThroughInvalidStudent() throws Exception { helper.generateTSA(TEACHER_ID, "-1", false); helper.generateSSA("2", "3", false); studentIds.add("2"); Assert.assertFalse(validator.validate(EntityNames.STUDENT, studentIds).containsAll(studentIds)); }
@Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; }
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; }  }
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; }  @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; }  @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext();  }