org.springframework.security.access.vote.RoleVoter Java Examples

The following examples show how to use org.springframework.security.access.vote.RoleVoter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SecurityConfig.java    From base-admin with MIT License 6 votes vote down vote up
@Bean
public DynamicallyUrlInterceptor dynamicallyUrlInterceptor(){
    //首次获取
    List<SysAuthorityVo> authorityVoList = sysAuthorityService.list(new SysAuthorityVo()).getData();
    myFilterInvocationSecurityMetadataSource.setRequestMap(authorityVoList);
    //初始化拦截器并添加数据源(注意:不要手动new对象,把它交给spring管理,spring默认单例)
    DynamicallyUrlInterceptor interceptor = new DynamicallyUrlInterceptor();
    interceptor.setSecurityMetadataSource(myFilterInvocationSecurityMetadataSource);

    //配置RoleVoter决策
    List<AccessDecisionVoter<? extends Object>> decisionVoters = new ArrayList<>();
    decisionVoters.add(new RoleVoter());

    //设置认证决策管理器
    interceptor.setAccessDecisionManager(new MyAccessDecisionManager(decisionVoters));
    return interceptor;
}
 
Example #2
Source File: JvueGlobalMethodSecurityConfiguration.java    From jvue-admin with MIT License 5 votes vote down vote up
@Override
public AccessDecisionManager accessDecisionManager() {

    List<AccessDecisionVoter<? extends Object>> decisionVoters =
            new ArrayList<AccessDecisionVoter<? extends Object>>();

    decisionVoters.add(jvueMethodAclVoter);// 启用自定义投票器
    decisionVoters.add(new RoleVoter());
    decisionVoters.add(new AuthenticatedVoter());

    return new AffirmativeBased(decisionVoters);
}
 
Example #3
Source File: OpenApiSecurityConfigurer.java    From spring-backend-boilerplate with Apache License 2.0 5 votes vote down vote up
@Bean
public AccessDecisionManager accessDecisionManager() {
    List<AccessDecisionVoter<? extends Object>> decisionVoters = new ArrayList<>();
    decisionVoters.add(new RoleVoter());
    decisionVoters.add(new AuthenticatedVoter());
    decisionVoters.add(webExpressionVoter());
    return new AffirmativeBased(decisionVoters);
}
 
Example #4
Source File: CustomAuthorizationConfig.java    From Spring-Security-Third-Edition with MIT License 5 votes vote down vote up
public AccessDecisionManager accessDecisionManager2(
        CustomWebSecurityExpressionHandler customWebSecurityExpressionHandler) {
    List<AccessDecisionVoter<? extends Object>> decisionVoters
            = Arrays.asList(
            new AuthenticatedVoter(),
            new RoleVoter(),
            new WebExpressionVoter(){{
                setExpressionHandler(customWebSecurityExpressionHandler);
            }}
    );
    return new UnanimousBased(decisionVoters);
}
 
Example #5
Source File: CustomAuthorizationConfig.java    From Spring-Security-Third-Edition with MIT License 5 votes vote down vote up
public AccessDecisionManager accessDecisionManager2(
        CustomWebSecurityExpressionHandler customWebSecurityExpressionHandler) {
    List<AccessDecisionVoter<? extends Object>> decisionVoters
            = Arrays.asList(
            new AuthenticatedVoter(),
            new RoleVoter(),
            new WebExpressionVoter(){{
                setExpressionHandler(customWebSecurityExpressionHandler);
            }}
    );
    return new UnanimousBased(decisionVoters);
}
 
Example #6
Source File: AppSpringModuleConfig.java    From herd with Apache License 2.0 5 votes vote down vote up
/**
 * Overridden to remove role prefix for the role voter. The application does not require any other access decision voters in the default configuration.
 */
/*
 * rawtypes must be suppressed because AffirmativeBased constructor takes in a raw typed list of AccessDecisionVoters
 */
@SuppressWarnings("rawtypes")
@Override
protected AccessDecisionManager accessDecisionManager()
{
    List<AccessDecisionVoter<?>> decisionVoters = new ArrayList<>();
    RoleVoter decisionVoter = new RoleVoter();
    decisionVoter.setRolePrefix("");
    decisionVoters.add(decisionVoter);
    return new AffirmativeBased(decisionVoters);
}
 
Example #7
Source File: WebSecurityConfig.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
public AccessDecisionManager accessDecisionManager() {
    // @formatter: off
    List<AccessDecisionVoter<? extends Object>> decisionVoters = Arrays.asList(new WebExpressionVoter(), new RoleVoter(), new AuthenticatedVoter(), new MinuteBasedVoter());
    // @formatter: on
    return new UnanimousBased(decisionVoters);
}
 
Example #8
Source File: SecurityConfig.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
public AccessDecisionManager customAccessDecisionManager() {
    List<AccessDecisionVoter<? extends Object>> decisionVoters = new ArrayList<>();
    decisionVoters.add(new RoleVoter());
    decisionVoters.add(new UsernameAccessDecisionVoter());
    AccessDecisionManager accessDecisionManager = new AffirmativeBased(decisionVoters);
    return accessDecisionManager;
}
 
Example #9
Source File: SpringAuthManager.java    From jdal with Apache License 2.0 5 votes vote down vote up
@PostConstruct
public void init() {
	if (this.accessDecisionManager == null) {
		if (log.isDebugEnabled())
			log.debug("Creating default AffirmativeBased AccesDecisionManager with RoleVoter");
		
		List<AccessDecisionVoter<? extends Object>> defaultVoters =
				new ArrayList<AccessDecisionVoter<? extends Object>>();
		defaultVoters.add(new RoleVoter());
		this.accessDecisionManager = new AffirmativeBased(defaultVoters);
	}
}
 
Example #10
Source File: SecurityBeans.java    From zhcet-web with Apache License 2.0 4 votes vote down vote up
@Bean
RoleVoter roleVoter(RoleHierarchy roleHierarchy) {
    return new RoleHierarchyVoter(roleHierarchy);
}
 
Example #11
Source File: SecurityApplicationConfiguration.java    From haven-platform with Apache License 2.0 4 votes vote down vote up
@Bean
public RoleVoter getRoleVoter() {
    return new AdminRoleVoter();
}
 
Example #12
Source File: WallRideSecurityConfiguration.java    From wallride with Apache License 2.0 4 votes vote down vote up
@Bean
public RoleVoter roleVoter() {
	return new RoleHierarchyVoter(roleHierarchy());
}
 
Example #13
Source File: MolgenisWebAppSecurityConfig.java    From molgenis with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Bean
public RoleVoter roleVoter() {
  return new RoleHierarchyVoter(roleHierarchyBean());
}
 
Example #14
Source File: MyAppSpringConfiguration.java    From dropwizard-spring-di-security-onejar-example with Apache License 2.0 4 votes vote down vote up
@Bean
public RoleVoter getRoleVoter() {
    RoleVoter roleVoter = new RoleVoter();
    roleVoter.setRolePrefix("ROLE _");
    return roleVoter;
}