package security.internal; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; import kernel.web.ApplicationUtil; import security.Resource; import security.Role; public class SecurityAuthoritiesHolderImpl implements SecurityAuthoritiesHolder { private Map> cache = new HashMap>(); private List getResourcesByType(String resType) { List resources=ApplicationUtil.executeSelect(Resource.class,"WHERE RES_TYPE=?",new Object[] {resType}); String roleSql="SELECT * FROM SCT_ROLE R WHERE EXISTS (SELECT ROLE_UUID FROM SCT_ROLE_RESOURCE WHERE RESOURCE_UUID=? AND ROLE_UUID=R.UUID)"; for(Resource resource:resources) { List roleList=ApplicationUtil.executeDQL(roleSql,new Object[] {resource.getId()}, Role.class); if(null==roleList || roleList.isEmpty()) continue; resource.setRoles(roleList.stream().filter(role->null!=role).collect(Collectors.toSet())); } return resources; } public Map loadAuthorities(String resType) { Map authorities = cache.get(resType); if (authorities != null) return authorities; cache.put(resType, authorities=new LinkedHashMap()); List urlResources = getResourcesByType(resType); Collections.sort(urlResources,new Comparator() { public int compare(Resource o1, Resource o2) { if (o1.getResString().length()>(); } }