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


Java AccessDecisionVoter类代码示例

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


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

示例1: decide

import org.springframework.security.access.AccessDecisionVoter; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void decide(Authentication authentication, Object object,Collection<ConfigAttribute> configAttributes)throws AccessDeniedException, InsufficientAuthenticationException {
	if((authentication.getPrincipal() instanceof IUser)){
		IUser loginUser=(IUser)authentication.getPrincipal();
		if(loginUser.isAdministrator())return;			
	}
	int result=10;
	for (AccessDecisionVoter<Object> voter : getDecisionVoters()) {
		result = voter.vote(authentication, object, configAttributes);
		if(result==AccessDecisionVoter.ACCESS_ABSTAIN){
			continue;
		}
		if(result==AccessDecisionVoter.ACCESS_DENIED){
			throw new AccessDeniedException("Access is denied");
		}
		if(result==AccessDecisionVoter.ACCESS_GRANTED){
			break;
		}
	}
	if(result==AccessDecisionVoter.ACCESS_ABSTAIN && configAttributes.size()>0){
		throw new AccessDeniedException("Access is denied");
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:24,代码来源:UrlAccessDecisionManager.java

示例2: decide

import org.springframework.security.access.AccessDecisionVoter; //导入依赖的package包/类
public boolean decide(Authentication authentication,Collection<ConfigAttribute> configAttributes){
	if((authentication.getPrincipal() instanceof IUser)){
		IUser loginUser=(IUser)authentication.getPrincipal();
		if(loginUser.isAdministrator())return true;			
	}
	int result=10;
	for (AccessDecisionVoter<Object> voter : decisionVoters) {
		result = voter.vote(authentication,null, configAttributes);
		if(result==AccessDecisionVoter.ACCESS_ABSTAIN){
			continue;
		}
		if(result==AccessDecisionVoter.ACCESS_DENIED){
			return false;
		}
		if(result==AccessDecisionVoter.ACCESS_GRANTED){
			break;
		}
	}
	if(result==AccessDecisionVoter.ACCESS_ABSTAIN && configAttributes.size()>0){
		return false;
	}else{
		return true;
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:25,代码来源:ComponentAccessDecisionManager.java

示例3: userHasProperties

import org.springframework.security.access.AccessDecisionVoter; //导入依赖的package包/类
/**
 * Ensures that a user who has all the properties is granted ACCESS_GRANTED
 */
@Test
public void userHasProperties()
{

	final Map<String, String> properties = CollectionUtil.newMap();
	properties.put("USERNAME", "username");
	properties.put("PASSWORD", "password");
	userDetails.setProperties(properties);

	final int decision = decisionVoter.vote(token, this,
			CollectionUtil.<ConfigAttribute> newList());

	assertThat(new Integer(decision), is(new Integer(
			AccessDecisionVoter.ACCESS_GRANTED)));

}
 
开发者ID:openfurther,项目名称:further-open-core,代码行数:20,代码来源:UTestUserHasPropertiesVoter.java

示例4: configureUrlAuthorization

import org.springframework.security.access.AccessDecisionVoter; //导入依赖的package包/类
@Override
protected void configureUrlAuthorization(
		ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry expressionInterceptUrlRegistry)
{
	@SuppressWarnings("rawtypes")
	List<AccessDecisionVoter> listOfVoters = new ArrayList<AccessDecisionVoter>();
	listOfVoters.add(new WebExpressionVoter());
	listOfVoters.add(new MolgenisAccessDecisionVoter());
	expressionInterceptUrlRegistry.accessDecisionManager(new AffirmativeBased(listOfVoters));

	expressionInterceptUrlRegistry.antMatchers("/").permitAll()
	// DAS datasource uses the database, unauthenticated users can
	// not see any data
			.antMatchers("/das/**").permitAll()

			.antMatchers("/myDas/**").permitAll()

			.antMatchers("/annotators/**").authenticated()

			.antMatchers("/charts/**").authenticated();
}
 
开发者ID:dennishendriksen,项目名称:molgenis-lifelines,代码行数:22,代码来源:WebAppSecurityConfig.java

示例5: accessDecisionManager

import org.springframework.security.access.AccessDecisionVoter; //导入依赖的package包/类
@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);
}
 
开发者ID:melthaw,项目名称:spring-backend-boilerplate,代码行数:9,代码来源:OpenApiSecurityConfigurer.java

示例6: accessDecisionManager

import org.springframework.security.access.AccessDecisionVoter; //导入依赖的package包/类
@Description("ConsensusBased AccessDecisionManager for Authorization voting")
    @Bean
    public AccessDecisionManager accessDecisionManager(
            CustomWebSecurityExpressionHandler customWebSecurityExpressionHandler) {
        List<AccessDecisionVoter<? extends Object>> decisionVoters
                = Arrays.asList(
//                new AuthenticatedVoter(),
//                new RoleVoter(),
                new WebExpressionVoter(){{
                    setExpressionHandler(customWebSecurityExpressionHandler);
                }}
        );
        return new ConsensusBased(decisionVoters);
    }
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:15,代码来源:CustomAuthorizationConfig.java

示例7: accessDecisionManager2

import org.springframework.security.access.AccessDecisionVoter; //导入依赖的package包/类
public AccessDecisionManager accessDecisionManager2(
        CustomWebSecurityExpressionHandler customWebSecurityExpressionHandler) {
    List<AccessDecisionVoter<? extends Object>> decisionVoters
            = Arrays.asList(
            new AuthenticatedVoter(),
            new RoleVoter(),
            new WebExpressionVoter(){{
                setExpressionHandler(customWebSecurityExpressionHandler);
            }}
    );
    return new UnanimousBased(decisionVoters);
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:13,代码来源:CustomAuthorizationConfig.java

示例8: accessDecisionManager

import org.springframework.security.access.AccessDecisionVoter; //导入依赖的package包/类
@Description("AccessDecisionManager for Authorization voting")
@Bean
public AccessDecisionManager accessDecisionManager(
        CustomWebSecurityExpressionHandler customWebSecurityExpressionHandler) {
    List<AccessDecisionVoter<? extends Object>> decisionVoters
            = Arrays.asList(
            new WebExpressionVoter(){{
                setExpressionHandler(customWebSecurityExpressionHandler);
            }}
    );
    return new ConsensusBased(decisionVoters);
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:13,代码来源:CustomAuthorizationConfig.java

示例9: accessDecisionManager

import org.springframework.security.access.AccessDecisionVoter; //导入依赖的package包/类
@Description("ConsensusBased AccessDecisionManager for Authorization voting")
@Bean
public AccessDecisionManager accessDecisionManager(
        CustomWebSecurityExpressionHandler customWebSecurityExpressionHandler) {
    List<AccessDecisionVoter<? extends Object>> decisionVoters
            = Arrays.asList(
            new WebExpressionVoter(){{
                setExpressionHandler(customWebSecurityExpressionHandler);
            }}
    );
    return new ConsensusBased(decisionVoters);
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:13,代码来源:CustomAuthorizationConfig.java

示例10: shellAccessDecisionManager

import org.springframework.security.access.AccessDecisionVoter; //导入依赖的package包/类
@Bean
public AccessDecisionManager shellAccessDecisionManager() {
	List<AccessDecisionVoter<?>> voters = new ArrayList<AccessDecisionVoter<?>>();
	RoleVoter voter = new RoleVoter();
	voter.setRolePrefix("");
	voters.add(voter);
	return new UnanimousBased(voters);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:CrshAutoConfigurationTests.java

示例11: checkUrlAccessExpression

import org.springframework.security.access.AccessDecisionVoter; //导入依赖的package包/类
private void checkUrlAccessExpression() {
   log.debug("check if URL access expressions are allowed");
   String[] names = context.getBeanDefinitionNames();
   for (String name : names) {
      if (context.getBean(name) instanceof AbstractAccessDecisionManager) {
         for (AccessDecisionVoter v : ((AbstractAccessDecisionManager) context.getBean(name)).getDecisionVoters()) {
            if (v instanceof WebExpressionVoter) {
               log.debug("parse urlAccess as EL expression");
               urlAccessExpression = true;
               return;
            }
         }
      }
   }

   log.debug("parse urlAccess as simple expression");
   urlAccessExpression = false;
}
 
开发者ID:Wolfgang-Winter,项目名称:cibet,代码行数:19,代码来源:SpringSecurityActuator.java

示例12: filterInvocationInterceptor

import org.springframework.security.access.AccessDecisionVoter; //导入依赖的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

示例13: accessDecisionManager

import org.springframework.security.access.AccessDecisionVoter; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:FINRAOS,项目名称:herd,代码行数:17,代码来源:AppSpringModuleConfig.java

示例14: accessDecisionManager

import org.springframework.security.access.AccessDecisionVoter; //导入依赖的package包/类
/***
 * 对应的方法决策器
 */
@Override
protected AccessDecisionManager accessDecisionManager() {
	AccessDecisionManager decisionManager = super.accessDecisionManager();
	@SuppressWarnings("unchecked")
	List<AccessDecisionVoter<? extends Object>> decisionVoters = (List<AccessDecisionVoter<? extends Object>>)ReflectUtils.getFieldValue(decisionManager, "decisionVoters");
	decisionVoters.add(new MethodWebExpressionVoter());
	return decisionManager;
}
 
开发者ID:wayshall,项目名称:onetwo,代码行数:12,代码来源:MethodBasedSecurityConfig.java

示例15: getAffirmativeBased

import org.springframework.security.access.AccessDecisionVoter; //导入依赖的package包/类
/**
 * Gets the affirmative based.
 *
 * @return the affirmative based
 */
@Bean(name = "httpRequestAccessDecisionManager")
public AffirmativeBased getAffirmativeBased() {
  List<AccessDecisionVoter<? extends Object>> decisionVoters = new ArrayList<>();
  decisionVoters.add(getRoleVoter());

  AffirmativeBased based = new AffirmativeBased(decisionVoters);
  based.setAllowIfAllAbstainDecisions(false);
  return based;
}
 
开发者ID:psi-probe,项目名称:psi-probe,代码行数:15,代码来源:ProbeSecurityConfig.java


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