// 取得用户的权限
 private Set<GrantedAuthority> obtionGrantedAuthorities(com.lanyuan.entity.User user) {
   List<Resources> resources = resourcesDao.getUserResources(String.valueOf(user.getUserId()));
   Set<GrantedAuthority> authSet = new HashSet<GrantedAuthority>();
   for (Resources res : resources) {
     // TODO:ZZQ 用户可以访问的资源名称(或者说用户所拥有的权限) 注意:必须"ROLE_"开头
     // 关联代码:applicationContext-security.xml
     // 关联代码:com.huaxin.security.MySecurityMetadataSource#loadResourceDefine
     authSet.add(new SimpleGrantedAuthority("ROLE_" + res.getResKey()));
   }
   return authSet;
 }
 /**
  * @PostConstruct是Java EE 5引入的注解,
  * Spring允许开发者在受管Bean中使用它。当DI容器实例化当前受管Bean时, @PostConstruct注解的方法会被自动触发,从而完成一些初始化工作,
  *
  * <p>//加载所有资源与权限的关系
  */
 @PostConstruct
 private void loadResourceDefine() {
   //		System.err.println("-----------MySecurityMetadataSource loadResourceDefine ----------- ");
   if (resourceMap == null) {
     resourceMap = new HashMap<String, Collection<ConfigAttribute>>();
     List<Resources> menus = menuMapper.queryAll(new Resources());
     for (Resources m : menus) {
       Collection<ConfigAttribute> configAttributes = new ArrayList<ConfigAttribute>();
       // TODO:ZZQ 通过资源名称来表示具体的权限 注意:必须"ROLE_"开头
       // 关联代码:applicationContext-security.xml
       // 关联代码:com.huaxin.security.MyUserDetailServiceImpl#obtionGrantedAuthorities
       ConfigAttribute configAttribute = new SecurityConfig("ROLE_" + m.getResKey());
       configAttributes.add(configAttribute);
       resourceMap.put(m.getResUrl(), configAttributes);
     }
   }
 }