@Test public void testApplySecurityCriteria() { injector.setAccessAllAdminContext(); SecurityCriteria securityCriteria = new SecurityCriteria(); securityCriteria.setSecurityCriteria(new NeutralCriteria("key", "in", "value")); NeutralQuery query = new NeutralQuery(); query = securityCriteria.applySecurityCriteria(query); assertEquals("Should match", 1, query.getOrQueries().size()); }
public NeutralQuery applySecurityCriteria(NeutralQuery query) { if (securityCriteria != null) { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); SLIPrincipal user = (SLIPrincipal) auth.getPrincipal(); if (EntityNames.TEACHER.equals(user.getEntity().getType())) { List<String> ids = (List) securityCriteria.getValue(); if (ids.size() > inClauseSize) { throw new ResponseTooLargeException(); } } query.addOrQuery(new NeutralQuery(securityCriteria)); } return query; }
SecurityCriteria { public NeutralQuery applySecurityCriteria(NeutralQuery query) { if (securityCriteria != null) { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); SLIPrincipal user = (SLIPrincipal) auth.getPrincipal(); if (EntityNames.TEACHER.equals(user.getEntity().getType())) { List<String> ids = (List) securityCriteria.getValue(); if (ids.size() > inClauseSize) { throw new ResponseTooLargeException(); } } query.addOrQuery(new NeutralQuery(securityCriteria)); } return query; } }
SecurityCriteria { public NeutralQuery applySecurityCriteria(NeutralQuery query) { if (securityCriteria != null) { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); SLIPrincipal user = (SLIPrincipal) auth.getPrincipal(); if (EntityNames.TEACHER.equals(user.getEntity().getType())) { List<String> ids = (List) securityCriteria.getValue(); if (ids.size() > inClauseSize) { throw new ResponseTooLargeException(); } } query.addOrQuery(new NeutralQuery(securityCriteria)); } return query; }  }
SecurityCriteria { public NeutralQuery applySecurityCriteria(NeutralQuery query) { if (securityCriteria != null) { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); SLIPrincipal user = (SLIPrincipal) auth.getPrincipal(); if (EntityNames.TEACHER.equals(user.getEntity().getType())) { List<String> ids = (List) securityCriteria.getValue(); if (ids.size() > inClauseSize) { throw new ResponseTooLargeException(); } } query.addOrQuery(new NeutralQuery(securityCriteria)); } return query; }  String getCollectionName(); void setCollectionName(String collectionName); NeutralCriteria getSecurityCriteria(); void setSecurityCriteria(NeutralCriteria securityCriteria); NeutralQuery applySecurityCriteria(NeutralQuery query); void setInClauseSize(Long size); }
SecurityCriteria { public NeutralQuery applySecurityCriteria(NeutralQuery query) { if (securityCriteria != null) { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); SLIPrincipal user = (SLIPrincipal) auth.getPrincipal(); if (EntityNames.TEACHER.equals(user.getEntity().getType())) { List<String> ids = (List) securityCriteria.getValue(); if (ids.size() > inClauseSize) { throw new ResponseTooLargeException(); } } query.addOrQuery(new NeutralQuery(securityCriteria)); } return query; }  String getCollectionName(); void setCollectionName(String collectionName); NeutralCriteria getSecurityCriteria(); void setSecurityCriteria(NeutralCriteria securityCriteria); NeutralQuery applySecurityCriteria(NeutralQuery query); void setInClauseSize(Long size);  }