• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Section类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.shiro.config.Ini.Section的典型用法代码示例。如果您正苦于以下问题:Java Section类的具体用法?Java Section怎么用?Java Section使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Section类属于org.apache.shiro.config.Ini包,在下文中一共展示了Section类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: usersSection

import org.apache.shiro.config.Ini.Section; //导入依赖的package包/类
private Section usersSection(ServletContext servletContext) {
    if ( !initialized ) {
        synchronized (this) {
            try {
                if ( initialized )
                    return usersSection;
                initialized = true;
                IniWebEnvironment env = (IniWebEnvironment)WebUtils.getWebEnvironment(servletContext) ; 
                usersSection = env.getIni().getSection("users") ;
            } catch (Exception ex) {
                LoggerFactory.getLogger(getClass()).error("Failed to find the shiro.ini [users] section"); 
            }
        }
    }
    return usersSection ; 
}
 
开发者ID:afs,项目名称:http-digest-auth,代码行数:17,代码来源:DigestHttpAuthenticationFilterIniPassword.java


示例2: getObject

import org.apache.shiro.config.Ini.Section; //导入依赖的package包/类
@Override
public Section getObject() throws Exception {
	Ini ini = new Ini();
	ini.load(filterChainDefinitions);
	Ini.Section section = ini.getSection(Ini.DEFAULT_SECTION_NAME);
	//由注入的资源管理对象获取所有资源数据,并且Resource的authorities的属性是EAGER的fetch类型
	List<Resource> resources = resourceManager.getAll();
	for(Resource resource : resources) {
		if(StringUtils.isEmpty(resource.getSource())) {
			continue;
		}
		for (Authority entity : resource.getAuthorities()) {
			//如果资源的值为分号分隔,则循环构造元数据。分号分隔好处是对一批相同权限的资源,不需要逐个定义
			if(resource.getSource().indexOf(";") != -1) {
				String[] sources = resource.getSource().split(";");
				for(String source : sources) {
				    putDefinitionSection(section, source, entity.getName());
				}
			} else {
			    putDefinitionSection(section, resource.getSource(), entity.getName());
			}
		}
	}
	return section;
}
 
开发者ID:shaisxx,项目名称:snaker-demo,代码行数:26,代码来源:ShiroDefinitionSectionMetaSource.java


示例3: getObject

import org.apache.shiro.config.Ini.Section; //导入依赖的package包/类
@Override
public Section getObject() throws BeansException {
	Ini ini = new Ini();
       //加载默认的url
       ini.load(filterChainDefinitions);
       Section section = ini.getSection(Ini.DEFAULT_SECTION_NAME);
       //循环数据库资源的url
       for (Resource resource : accountManager.getResources()) {
       	if(StringUtils.isNotEmpty(resource.getValue()) && StringUtils.isNotEmpty(resource.getPermission())) {
       		section.put(resource.getValue(), resource.getPermission());
       	}
       }
       
       //循环数据库组的url
       for (Group group : accountManager.getGroup(GroupType.RoleGorup)) {
       	if(StringUtils.isNotEmpty(group.getValue()) && StringUtils.isNotEmpty(group.getRole())) {
       		section.put(group.getValue(), group.getRole());
       	}
       }
       
       return section;
}
 
开发者ID:extion,项目名称:base-framework,代码行数:23,代码来源:ChainDefinitionSectionMetaSource.java


示例4: parseGroups

import org.apache.shiro.config.Ini.Section; //导入依赖的package包/类
private void parseGroups(FileSystem fileSystem, Path resourcePath) throws IOException {
  Ini ini = PolicyFiles.loadFromPath(fileSystem, resourcePath);
  Section usersSection = ini.getSection(PolicyFileConstants.USERS);
  if (usersSection == null) {
    LOGGER.warn("No section " + PolicyFileConstants.USERS + " in the " + resourcePath);
    return;
  }
  for (Entry<String, String> userEntry : usersSection.entrySet()) {
    String userName = Strings.nullToEmpty(userEntry.getKey()).trim();
    String groupNames = Strings.nullToEmpty(userEntry.getValue()).trim();
    if (userName.isEmpty()) {
      LOGGER.error("Invalid user name in the " + resourcePath);
      continue;
    }
    if (groupNames.isEmpty()) {
      LOGGER.warn("No groups available for user " + userName +
          " in the " + resourcePath);
      continue;
    }
    Set<String> groupList = Sets.newHashSet(PolicyConstants.ROLE_SPLITTER.trimResults().split(
        groupNames));
    LOGGER.debug("Got user mapping: " + userName + ", Groups: " + groupNames);
    groupMap.put(userName, groupList);
  }
}
 
开发者ID:apache,项目名称:incubator-sentry,代码行数:26,代码来源:LocalGroupMappingService.java


示例5: getObject

import org.apache.shiro.config.Ini.Section; //导入依赖的package包/类
public Section getObject() throws Exception {
	String urlPermissions = filterChainDefinitions;
	String dynamicUrlPermissions = getDynamicUrlPermissions();
	urlPermissions = urlPermissions.replace(buildPlaceHolder(), dynamicUrlPermissions);
	urlPermissions = beautifyUrlPermissionExpression(urlPermissions);
	logger.info(">>> Global URL based permission configuration :\n{}", urlPermissions);
	Ini ini = new Ini();
       ini.load(urlPermissions);
       Ini.Section section = ini.getSection(IniFilterChainResolverFactory.URLS);
       if(CollectionUtils.isEmpty(section)){
           section = ini.getSection(Ini.DEFAULT_SECTION_NAME);
       }
	return section;
}
 
开发者ID:penggle,项目名称:xproject,代码行数:15,代码来源:GlobalUrlPermissionFilterChainDefinition.java


示例6: createDefaults

import org.apache.shiro.config.Ini.Section; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
protected Map<String, ?> createDefaults(Ini ini, Section mainSection) {
    Map defaults = super.createDefaults(ini, mainSection);
    defaults.putAll(namedBeanMap);
    return defaults;
}
 
开发者ID:ops4j,项目名称:org.ops4j.pax.shiro,代码行数:8,代码来源:CdiWebIniSecurityManagerFactory.java


示例7: entrySet

import org.apache.shiro.config.Ini.Section; //导入依赖的package包/类
@Override
public Set<java.util.Map.Entry<String, String>> entrySet() {
	Section section = ini.getSection(Ini.DEFAULT_SECTION_NAME);
	if(section!=null){
		return section.entrySet();
	}else{
		return EMPTY_SECTION.entrySet();
	}
}
 
开发者ID:houdejun214,项目名称:lakeside-java,代码行数:10,代码来源:PermissionDefinitionSectionMetaSource.java


示例8: getObjectType

import org.apache.shiro.config.Ini.Section; //导入依赖的package包/类
public Class<?> getObjectType() {
	return Ini.Section.class;
}
 
开发者ID:penggle,项目名称:xproject,代码行数:4,代码来源:GlobalUrlPermissionFilterChainDefinition.java


示例9: putDefinitionSection

import org.apache.shiro.config.Ini.Section; //导入依赖的package包/类
private void putDefinitionSection(Section section, String key, String value) {
    log.debug("加载数据库权限:【key=" + key + "/tvalue=" + value + "】");
    section.put(key, MessageFormat.format(PREMISSION_FORMAT, value));
}
 
开发者ID:shaisxx,项目名称:snaker-demo,代码行数:5,代码来源:ShiroDefinitionSectionMetaSource.java


示例10: getObjectType

import org.apache.shiro.config.Ini.Section; //导入依赖的package包/类
@Override
public Class<?> getObjectType() {
	return Section.class;
}
 
开发者ID:extion,项目名称:base-framework,代码行数:5,代码来源:ChainDefinitionSectionMetaSource.java


示例11: afterPropertiesSet

import org.apache.shiro.config.Ini.Section; //导入依赖的package包/类
public void afterPropertiesSet() throws Exception {
	log.info("start detect url filter chain definitions.");
       //加载默认的url
       ini.load(filterChainDefinitions);
       Ini.Section section = ini.getSection(Ini.DEFAULT_SECTION_NAME);
       Map<String, Object> beansWithAnnotation = this.applicationContext.getBeansWithAnnotation(Controller.class);
       Iterator<Entry<String, Object>> iterator = beansWithAnnotation.entrySet().iterator();
       Map<String,Protected> urls = new LinkedHashMap<String,Protected>();
       while(iterator.hasNext()){
       	Entry<String, Object> next = iterator.next();
       	String beanName = next.getKey();
       	RequestMapping mapping = applicationContext.findAnnotationOnBean(beanName, RequestMapping.class);
       	Class<?> handlerType = applicationContext.getType(beanName);
       	Protected typeProtect = applicationContext.findAnnotationOnBean(beanName, Protected.class);
		Map<String, Protected> methodUrls = determineMethodsProtected(handlerType, mapping, typeProtect);
		urls.putAll(methodUrls);
		
		Boolean isControllerProtected = typeProtect!=null;
		boolean haveMappingSetting = (mapping!=null) && haveMappingSetting(mapping.value());
		if(isControllerProtected && haveMappingSetting){ 
			// controller 設置了protected 而且有Mapping設置
			for (String typeLevelPattern : mapping.value()) {
				if (!typeLevelPattern.startsWith("/")) {
					typeLevelPattern = "/" + typeLevelPattern;
				}
				if(!typeLevelPattern.endsWith("/")){
					typeLevelPattern = typeLevelPattern+"/";
				}
				urls.put(typeLevelPattern,typeProtect);
				urls.put(typeLevelPattern+"**",typeProtect);
			}
		}
       }
       for(String url:urls.keySet()){
         if(StringUtils.isNotEmpty(url) && !"/".equals(url)) {
       	  Protected protectAno = urls.get(url);
       	  StringBuilder auth = new StringBuilder("");
       	  if(protectAno!=null && protectAno.allowAnon()){
       		  auth.append("anon");
       	  }else if(protectAno!=null){
       		  auth.append("authc");
       		  String[] roles = protectAno.role();
       		  String[] permission = protectAno.permission();
       		  if(protectAno!=null && !isCollectionEmpty(roles)){
       			  auth.append(",roles[");
       			  for(int i=0;i<roles.length;i++){
       				  if(i>0){
       					  auth.append(",");
       				  }
       				  auth.append(roles[i]);
       			  }
       			  auth.append("]");
       		  }
       		  if(protectAno!=null && !isCollectionEmpty(permission)){
       			  auth.append(",perms[");
       			  for(int i=0;i<permission.length;i++){
       				  if(i>0){
       					  auth.append(",");
       				  }
       				  auth.append(permission[i]);
       			  }
       			  auth.append("]");
       		  }
       	  }
       	  if(protectAno == null){
       		  System.out.println();
       	  }
       	  log.info("detected url filter chain:"+url+"="+auth.toString());
       	  section.put(url,auth.toString());
         }
       }
       if(protectAll){
       	section.put("/**","authc");
       }else if(StringUtils.isNotEmpty(defaultAccess)){
       	section.put("/**",defaultAccess);
       }
       // cache the annotation information;
       this.sectionUrls = urls;
}
 
开发者ID:houdejun214,项目名称:lakeside-java,代码行数:80,代码来源:PermissionDefinitionSectionMetaSource.java



注:本文中的org.apache.shiro.config.Ini.Section类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BlockDoorBirch类代码示例发布时间:2022-05-22
下一篇:
Java ModuleGroup类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap