当前位置: 首页>>代码示例>>Java>>正文


Java FilterSecurityInterceptor.setAccessDecisionManager方法代码示例

本文整理汇总了Java中org.springframework.security.web.access.intercept.FilterSecurityInterceptor.setAccessDecisionManager方法的典型用法代码示例。如果您正苦于以下问题:Java FilterSecurityInterceptor.setAccessDecisionManager方法的具体用法?Java FilterSecurityInterceptor.setAccessDecisionManager怎么用?Java FilterSecurityInterceptor.setAccessDecisionManager使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.security.web.access.intercept.FilterSecurityInterceptor的用法示例。


在下文中一共展示了FilterSecurityInterceptor.setAccessDecisionManager方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getFilterSecurityInterceptor

import org.springframework.security.web.access.intercept.FilterSecurityInterceptor; //导入方法依赖的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

示例2: filterInvocationInterceptor

import org.springframework.security.web.access.intercept.FilterSecurityInterceptor; //导入方法依赖的package包/类
@Bean
public FilterSecurityInterceptor filterInvocationInterceptor(){
    List<AccessDecisionVoter> vote = new ArrayList<AccessDecisionVoter>(Arrays.asList(new WebExpressionVoter()));
    AffirmativeBased voters = new AffirmativeBased(vote);
    voters.setAllowIfAllAbstainDecisions(false);
    FilterSecurityInterceptor bean = new FilterSecurityInterceptor();
    bean.setAuthenticationManager(authenticationManager());
    bean.setAccessDecisionManager(voters);
    bean.setSecurityMetadataSource(securityMetadataSource);
    bean.setMessageSource(messageSource);
    return bean;
}
 
开发者ID:dovier,项目名称:coj-web,代码行数:13,代码来源:SecurityConfiguration.java

示例3: addFilterSecurityInterceptor

import org.springframework.security.web.access.intercept.FilterSecurityInterceptor; //导入方法依赖的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


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