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

Java DefaultFilterInvocationSecurityMetadataSource类代码示例

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

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



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

示例1: testgetAttributesFilter

import org.springframework.security.web.access.intercept.DefaultFilterInvocationSecurityMetadataSource; //导入依赖的package包/类
@Test
public void testgetAttributesFilter() throws Exception {
   try {
      // CibetFilterInvocationSecurityMetadataSource fs = new CibetFilterInvocationSecurityMetadataSource(
      // new DefaultFilterInvocationSecurityMetadataSource(null,
      // new LinkedHashMap<RequestKey, Collection<ConfigAttribute>>()));
      CibetFilterInvocationSecurityMetadataSource fs = new CibetFilterInvocationSecurityMetadataSource(
            new DefaultFilterInvocationSecurityMetadataSource(new LinkedHashMap()));
      fs.getAttributes("nixi");
      Assert.fail();
   } catch (ClassCastException e) {
      // Spring 3.0.3 : IllegalArgumentException
      // Spring 3.2: ClassCastException
      log.info(e.getMessage());
   }
}
 
开发者ID:Wolfgang-Winter,项目名称:cibet,代码行数:17,代码来源:CibetFilterInvocationSecurityMetadataSourceTest.java


示例2: buildSecurityMetadataSource

import org.springframework.security.web.access.intercept.DefaultFilterInvocationSecurityMetadataSource; //导入依赖的package包/类
/****
	 * 基于url匹配拦截时,转换为ExpressionBasedFilterInvocationSecurityMetadataSource
	 * @param source
	 * @return
	 */
	@Override
	@SuppressWarnings("unchecked")
	public void buildSecurityMetadataSource(){
		Assert.notNull(filterSecurityInterceptor);
		this.buildRequestMap();
		DefaultFilterInvocationSecurityMetadataSource originMetadata = (DefaultFilterInvocationSecurityMetadataSource)filterSecurityInterceptor.getSecurityMetadataSource();
		//这个内置实现不支持一个url映射到多个表达式
//		ExpressionBasedFilterInvocationSecurityMetadataSource fism = new ExpressionBasedFilterInvocationSecurityMetadataSource(requestMap, securityExpressionHandler);
		
		Map<RequestMatcher, Collection<ConfigAttribute>> originRequestMap = (Map<RequestMatcher, Collection<ConfigAttribute>>)ReflectUtils.getFieldValue(originMetadata, "requestMap", false);
		if(originRequestMap!=null && !originRequestMap.isEmpty()){
			this.requestMap.putAll(originRequestMap);
		}
		DefaultFilterInvocationSecurityMetadataSource fism = new DefaultFilterInvocationSecurityMetadataSource(requestMap);
		this.filterSecurityInterceptor.setSecurityMetadataSource(fism);
	}
 
开发者ID:wayshall,项目名称:onetwo,代码行数:22,代码来源:DatabaseSecurityMetadataSource.java


示例3: getFilterSecurityInterceptor

import org.springframework.security.web.access.intercept.DefaultFilterInvocationSecurityMetadataSource; //导入依赖的package包/类
/**
 * Gets the filter security interceptor.
 *
 * @return the filter security interceptor
 */
@Bean(name = "fsi")
public FilterSecurityInterceptor getFilterSecurityInterceptor() {
  FilterSecurityInterceptor interceptor = new FilterSecurityInterceptor();
  interceptor.setAuthenticationManager(getProviderManager());
  interceptor.setAccessDecisionManager(getAffirmativeBased());

  LinkedHashMap<RequestMatcher, Collection<ConfigAttribute>> requestMap = new LinkedHashMap<>();
  requestMap.put(new AntPathRequestMatcher("/adm/**"),
      SecurityConfig.createListFromCommaDelimitedString("ROLE_MANAGER,ROLE_MANAGER-GUI"));
  requestMap.put(new AntPathRequestMatcher("/adm/restartvm.ajax"), SecurityConfig
      .createListFromCommaDelimitedString("ROLE_POWERUSERPLUS,ROLE_MANAGER,ROLE_MANAGER-GUI"));
  requestMap.put(new AntPathRequestMatcher("/sql/**"), SecurityConfig
      .createListFromCommaDelimitedString("ROLE_POWERUSERPLUS,ROLE_MANAGER,ROLE_MANAGER-GUI"));
  requestMap.put(new AntPathRequestMatcher("/app/**"),
      SecurityConfig.createListFromCommaDelimitedString(
          "ROLE_POWERUSER,ROLE_POWERUSERPLUS,ROLE_MANAGER,ROLE_MANAGER-GUI"));
  requestMap.put(new AntPathRequestMatcher("/**"),
      SecurityConfig.createListFromCommaDelimitedString(
          "ROLE_PROBEUSER,ROLE_POWERUSER,ROLE_POWERUSERPLUS,ROLE_MANAGER,ROLE_MANAGER-GUI"));

  interceptor
      .setSecurityMetadataSource(new DefaultFilterInvocationSecurityMetadataSource(requestMap));
  return interceptor;
}
 
开发者ID:psi-probe,项目名称:psi-probe,代码行数:30,代码来源:ProbeSecurityConfig.java


示例4: createSecurityMetadataSource

import org.springframework.security.web.access.intercept.DefaultFilterInvocationSecurityMetadataSource; //导入依赖的package包/类
public static BeanDefinition createSecurityMetadataSource(Element element, ParserContext pc) {
  List<Element> filterPatterns = DomUtils.getChildElementsByTagName(element, "url");

  if (filterPatterns.isEmpty()) {
    return null;
  }

  String patternType = element.getAttribute("path-type");
  if (!StringUtils.hasText(patternType)) {
    patternType = "ant";
  }

  MatcherType matcherType = MatcherType.valueOf(patternType);

  ManagedMap<BeanDefinition, BeanDefinition> invocationDefinitionMap = new ManagedMap<BeanDefinition, BeanDefinition>();

  for (Element filterPattern : filterPatterns) {
    String path = filterPattern.getAttribute("pattern");
    if (!StringUtils.hasText(path)) {
      pc.getReaderContext().error("pattern attribute cannot be empty or null", filterPattern);
    }

    String method = filterPattern.getAttribute("httpMethod");
    if (!StringUtils.hasText(method)) {
      method = null;
    }

    String access = filterPattern.getAttribute("resources");

    if (StringUtils.hasText(access)) {
      BeanDefinition matcher = matcherType.createMatcher(path, method);
      if (access.equals("none")) {
        invocationDefinitionMap.put(matcher, BeanDefinitionBuilder.rootBeanDefinition(Collections.class).setFactoryMethod("emptyList").getBeanDefinition());
      }
      else {
        BeanDefinitionBuilder attributeBuilder = BeanDefinitionBuilder.rootBeanDefinition(SecurityConfig.class);
        attributeBuilder.addConstructorArgValue(access);
        attributeBuilder.setFactoryMethod("createListFromCommaDelimitedString");

        if (invocationDefinitionMap.containsKey(matcher)) {
          pc.getReaderContext().warning("Duplicate URL defined: " + path
                                          + ". The original attribute values will be overwritten", pc.extractSource(filterPattern));
        }

        invocationDefinitionMap.put(matcher, attributeBuilder.getBeanDefinition());
      }
    }
  }

  BeanDefinitionBuilder fidsBuilder = BeanDefinitionBuilder.rootBeanDefinition(DefaultFilterInvocationSecurityMetadataSource.class);
  fidsBuilder.addConstructorArgValue(invocationDefinitionMap);
  fidsBuilder.getRawBeanDefinition().setSource(pc.extractSource(element));

  return fidsBuilder.getBeanDefinition();
}
 
开发者ID:jungyang,项目名称:oauth-client-master,代码行数:56,代码来源:ConfigUtils.java


示例5: execute

import org.springframework.security.web.access.intercept.DefaultFilterInvocationSecurityMetadataSource; //导入依赖的package包/类
public void execute(FilterSecurityInterceptor filterSecurityInterceptor,
        Map<String, String> resourceMap) {
    Assert.notNull(filterSecurityInterceptor);
    Assert.notNull(resourceMap);

    logger.info("refresh url resource");

    LinkedHashMap<RequestMatcher, Collection<ConfigAttribute>> requestMap = null;
    requestMap = new LinkedHashMap<RequestMatcher, Collection<ConfigAttribute>>();

    for (Map.Entry<String, String> entry : resourceMap.entrySet()) {
        String key = entry.getKey();
        String value = entry.getValue();
        requestMap.put(new AntPathRequestMatcher(key),
                SecurityConfig.createListFromCommaDelimitedString(value));
    }

    FilterInvocationSecurityMetadataSource source = new DefaultFilterInvocationSecurityMetadataSource(
            requestMap);
    filterSecurityInterceptor.setSecurityMetadataSource(source);
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:22,代码来源:UrlResourcePopulator.java


示例6: testgetCibetAttributesExpression

import org.springframework.security.web.access.intercept.DefaultFilterInvocationSecurityMetadataSource; //导入依赖的package包/类
@Test
public void testgetCibetAttributesExpression() throws Exception {
   // CibetFilterInvocationSecurityMetadataSource fs = new CibetFilterInvocationSecurityMetadataSource(
   // new DefaultFilterInvocationSecurityMetadataSource(null,
   // new LinkedHashMap<RequestKey, Collection<ConfigAttribute>>()));
   CibetFilterInvocationSecurityMetadataSource fs = new CibetFilterInvocationSecurityMetadataSource(
         new DefaultFilterInvocationSecurityMetadataSource(new LinkedHashMap()));
   CibetFilterInvocation fi = new CibetFilterInvocation(req, resp, chain);
   fi.setAccessRuleExpression("hasRole('Walter')");
   Collection<ConfigAttribute> c = fs.getAttributes(fi);
   Assert.assertEquals(1, c.size());
   ConfigAttribute ca = c.iterator().next();
   Assert.assertTrue(ca instanceof CibetWebExpressionConfigAttribute);
}
 
开发者ID:Wolfgang-Winter,项目名称:cibet,代码行数:15,代码来源:CibetFilterInvocationSecurityMetadataSourceTest.java


示例7: testgetCibetAttributes

import org.springframework.security.web.access.intercept.DefaultFilterInvocationSecurityMetadataSource; //导入依赖的package包/类
@Test
public void testgetCibetAttributes() throws Exception {
   // CibetFilterInvocationSecurityMetadataSource fs = new CibetFilterInvocationSecurityMetadataSource(
   // new DefaultFilterInvocationSecurityMetadataSource(null,
   // new LinkedHashMap<RequestKey, Collection<ConfigAttribute>>()));
   CibetFilterInvocationSecurityMetadataSource fs = new CibetFilterInvocationSecurityMetadataSource(
         new DefaultFilterInvocationSecurityMetadataSource(new LinkedHashMap()));
   CibetFilterInvocation fi = new CibetFilterInvocation(req, resp, chain);
   fi.setAccessRule("ROLE_VIEH");
   Collection<ConfigAttribute> c = fs.getAttributes(fi);
   Assert.assertEquals(1, c.size());
   ConfigAttribute ca = c.iterator().next();
   Assert.assertTrue(ca instanceof SecurityConfig);
}
 
开发者ID:Wolfgang-Winter,项目名称:cibet,代码行数:15,代码来源:CibetFilterInvocationSecurityMetadataSourceTest.java


示例8: addSecureChannel

import org.springframework.security.web.access.intercept.DefaultFilterInvocationSecurityMetadataSource; //导入依赖的package包/类
private void addSecureChannel(List<Filter> filters, Protocol protocol) {
    ChannelProcessingFilter channelProcessingFilter = new ChannelProcessingFilter();
    channelProcessingFilter.setChannelDecisionManager(channelDecisionManager);

    RequestMatcher anyRequest = AnyRequestMatcher.INSTANCE;

    LinkedHashMap<RequestMatcher, Collection<ConfigAttribute>> requestMap = new LinkedHashMap<>();
    Collection<ConfigAttribute> configAtts = new ArrayList<>();

    switch (protocol) {
        case HTTP:
            configAtts.add(new SecurityConfig("ANY_CHANNEL"));
            break;
        case HTTPS:
            configAtts.add(new SecurityConfig("REQUIRES_SECURE_CHANNEL"));
            break;
        default:
    }

    requestMap.put(anyRequest, configAtts);
    FilterInvocationSecurityMetadataSource securityMetadataSource = new DefaultFilterInvocationSecurityMetadataSource(requestMap);
    channelProcessingFilter.setSecurityMetadataSource(securityMetadataSource);

    filters.add(channelProcessingFilter);
}
 
开发者ID:motech,项目名称:motech,代码行数:26,代码来源:SecurityRuleBuilder.java


示例9: refresh

import org.springframework.security.web.access.intercept.DefaultFilterInvocationSecurityMetadataSource; //导入依赖的package包/类
public void refresh() {
    if ((filterSecurityInterceptor == null) || (urlSourceFetcher == null)) {
        logger.info(
                "filterSecurityInterceptor : {}, urlSourceFetcher : {}",
                filterSecurityInterceptor, urlSourceFetcher);

        return;
    }

    logger.info("execute refresh");

    Map<String, String> resourceMap = urlSourceFetcher.getSource(null);

    LinkedHashMap<RequestMatcher, Collection<ConfigAttribute>> requestMap = null;
    requestMap = new LinkedHashMap<RequestMatcher, Collection<ConfigAttribute>>();

    for (Map.Entry<String, String> entry : resourceMap.entrySet()) {
        String key = entry.getKey();
        String value = entry.getValue();
        requestMap.put(new AntPathRequestMatcher(key),
                SecurityConfig.createListFromCommaDelimitedString(value));
    }

    FilterInvocationSecurityMetadataSource source = new DefaultFilterInvocationSecurityMetadataSource(
            requestMap);
    filterSecurityInterceptor.setSecurityMetadataSource(source);
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:28,代码来源:UrlSourceBuilder.java


示例10: addFilterSecurityInterceptor

import org.springframework.security.web.access.intercept.DefaultFilterInvocationSecurityMetadataSource; //导入依赖的package包/类
private void addFilterSecurityInterceptor(List<Filter> filters, MotechURLSecurityRule securityRule) {
    Map<RequestMatcher, Collection<ConfigAttribute>> requestMap = new LinkedHashMap<>();

    List<AccessDecisionVoter> voters = new ArrayList<>();
    Collection<ConfigAttribute> configAtts = new ArrayList<>();

    if (CollectionUtils.isEmpty(securityRule.getPermissionAccess()) && CollectionUtils.isEmpty(securityRule.getUserAccess())) {
        configAtts.add(new SecurityConfig("IS_AUTHENTICATED_FULLY"));
        AuthenticatedVoter authVoter = new AuthenticatedVoter();
        voters.add(authVoter);
    } else {
        if (!CollectionUtils.isEmpty(securityRule.getPermissionAccess())) {
            for (String permission : securityRule.getPermissionAccess()) {
                configAtts.add(new SecurityConfig(permission));
            }
        }
        if (!CollectionUtils.isEmpty(securityRule.getUserAccess())) {
            for (String userAccess : securityRule.getUserAccess()) {
                configAtts.add(new SecurityConfig(SecurityConfigConstants.USER_ACCESS_PREFIX + userAccess));
            }
        }
    }

    buildRequestMap(requestMap, configAtts, securityRule);

    FilterInvocationSecurityMetadataSource metadataSource = new DefaultFilterInvocationSecurityMetadataSource((LinkedHashMap<RequestMatcher, Collection<ConfigAttribute>>) requestMap);

    FilterSecurityInterceptor interceptor = new FilterSecurityInterceptor();
    interceptor.setSecurityMetadataSource(metadataSource);

    RoleVoter roleVoter = new RoleVoter();

    roleVoter.setRolePrefix(SecurityConfigConstants.ROLE_ACCESS_PREFIX);
    voters.add(roleVoter);

    voters.add(new MotechAccessVoter());

    AccessDecisionManager decisionManager = new AffirmativeBased(voters);

    interceptor.setAccessDecisionManager(decisionManager);
    interceptor.setAuthenticationManager(authenticationManager);

    filters.add(interceptor);
}
 
开发者ID:motech,项目名称:motech,代码行数:45,代码来源:SecurityRuleBuilder.java


示例11: getObject

import org.springframework.security.web.access.intercept.DefaultFilterInvocationSecurityMetadataSource; //导入依赖的package包/类
@Override
public FilterInvocationSecurityMetadataSource getObject() {
	logger.info("###### DefaultFilterInvocationSecurityMetadataSource has changed. ######");
	return new DefaultFilterInvocationSecurityMetadataSource(buildRequestMap());

}
 
开发者ID:rockagen,项目名称:gnext,代码行数:7,代码来源:JdbcFilterInvocationSecurityMetadataSourceFactoryBean.java


示例12: createSecurityMetadataSource

import org.springframework.security.web.access.intercept.DefaultFilterInvocationSecurityMetadataSource; //导入依赖的package包/类
public static BeanDefinition createSecurityMetadataSource(Element element, ParserContext pc) {
  List<Element> filterPatterns = DomUtils.getChildElementsByTagName(element, "url");

  if (filterPatterns.isEmpty()) {
    return null;
  }

  // TODO : add support for lowercase-comparisons
  String patternType = element.getAttribute("path-type");
  if (!StringUtils.hasText(patternType)) {
    patternType = "ant";
  }

  MatcherType matcherType = MatcherType.valueOf(patternType);

  ManagedMap<BeanDefinition, BeanDefinition> invocationDefinitionMap = new ManagedMap<BeanDefinition, BeanDefinition>();

  for (Element filterPattern : filterPatterns) {
    String path = filterPattern.getAttribute("pattern");
    if (!StringUtils.hasText(path)) {
      pc.getReaderContext().error("pattern attribute cannot be empty or null", filterPattern);
    }

    String method = filterPattern.getAttribute("httpMethod");
    if (!StringUtils.hasText(method)) {
      method = null;
    }

    String access = filterPattern.getAttribute("resources");

    if (StringUtils.hasText(access)) {
      BeanDefinition matcher = matcherType.createMatcher(path, method);
      if (access.equals("none")) {
        invocationDefinitionMap.put(matcher, BeanDefinitionBuilder.rootBeanDefinition(Collections.class).setFactoryMethod("emptyList").getBeanDefinition());
      }
      else {
        BeanDefinitionBuilder attributeBuilder = BeanDefinitionBuilder.rootBeanDefinition(SecurityConfig.class);
        attributeBuilder.addConstructorArgValue(access);
        attributeBuilder.setFactoryMethod("createListFromCommaDelimitedString");

        if (invocationDefinitionMap.containsKey(matcher)) {
          pc.getReaderContext().warning("Duplicate URL defined: " + path
                                          + ". The original attribute values will be overwritten", pc.extractSource(filterPattern));
        }

        invocationDefinitionMap.put(matcher, attributeBuilder.getBeanDefinition());
      }
    }
  }

  BeanDefinitionBuilder fidsBuilder = BeanDefinitionBuilder.rootBeanDefinition(DefaultFilterInvocationSecurityMetadataSource.class);
  fidsBuilder.addConstructorArgValue(invocationDefinitionMap);
  fidsBuilder.getRawBeanDefinition().setSource(pc.extractSource(element));

  return fidsBuilder.getBeanDefinition();
}
 
开发者ID:jungyang,项目名称:oauth-client-master,代码行数:57,代码来源:ConfigUtils.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java LogAggregationService类代码示例发布时间:2022-05-22
下一篇:
Java IjkMediaFormat类代码示例发布时间: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