Example usage for org.springframework.security.access.vote RoleVoter RoleVoter

List of usage examples for org.springframework.security.access.vote RoleVoter RoleVoter

Introduction

In this page you can find the example usage for org.springframework.security.access.vote RoleVoter RoleVoter.

Prototype

RoleVoter

Source Link

Usage

From source file:com.apress.prospringintegration.security.SecurityConfiguration.java

@Bean
public AffirmativeBased accessDecisionManager() {
    AffirmativeBased affirmativeBased = new AffirmativeBased();
    affirmativeBased.setAllowIfAllAbstainDecisions(true);
    affirmativeBased.setDecisionVoters(Arrays.asList((AccessDecisionVoter) new RoleVoter()));

    return affirmativeBased;
}

From source file:com.swordcode.webcore.security.server.MethodSecurityConfig.java

@SuppressWarnings("rawtypes")
@Override//from ww  w .  ja  v a  2s.  co  m
protected AccessDecisionManager accessDecisionManager() {
    List<AccessDecisionVoter> decisionVoters = new ArrayList<>();
    ExpressionBasedPreInvocationAdvice expressionAdvice = new ExpressionBasedPreInvocationAdvice();
    expressionAdvice.setExpressionHandler(getExpressionHandler());

    // If prePostEnabled
    decisionVoters.add(new PreInvocationAuthorizationAdviceVoter(expressionAdvice));

    RoleVoter rv = new RoleVoter();
    rv.setRolePrefix("");
    decisionVoters.add(rv);
    decisionVoters.add(new AuthenticatedVoter());
    return new AffirmativeBased(decisionVoters);
}

From source file:com.muk.spring.config.SpringSecurityConfig.java

@Bean(name = "camelAccessDecisionManager")
public AccessDecisionManager accessDecisionManager() {
    final List<AccessDecisionVoter<? extends Object>> voters = new ArrayList<AccessDecisionVoter<? extends Object>>();
    voters.add(new RoleVoter());

    final AffirmativeBased decisionManager = new AffirmativeBased(voters);
    decisionManager.setAllowIfAllAbstainDecisions(true);

    return decisionManager;
}

From source file:playground.app.Application.java

@Bean
public AuthorizationWebFilter authorizationFilter() {
    UnanimousBased authz = new UnanimousBased(Arrays.asList(new RoleVoter()));
    return new AuthorizationWebFilter(new ReactiveAccessDecisionManagerAdapter(authz));
}

From source file:org.lightadmin.core.config.context.LightAdminSecurityConfiguration.java

@Bean
@Autowired/*from ww  w.ja  va2s .  co m*/
public Filter filterSecurityInterceptor(AuthenticationManager authenticationManager) throws Exception {
    FilterSecurityInterceptor filter = new FilterSecurityInterceptor();
    filter.setAuthenticationManager(authenticationManager);
    filter.setAccessDecisionManager(new AffirmativeBased(Arrays
            .<AccessDecisionVoter<? extends Object>>asList((AccessDecisionVoter<Object>) new RoleVoter())));
    filter.setSecurityMetadataSource(securityMetadataSource());
    filter.afterPropertiesSet();
    return filter;
}

From source file:org.svfc57.services.AppModule.java

public static void contributeAccessDecisionManager(OrderedConfiguration<AccessDecisionVoter> configuration) {

    RoleVoter voter = new RoleVoter();
    voter.setRolePrefix("PERM_");
    // Override the default Voter "ROLE_" with our own "PERM_" 
    configuration.override("RoleVoter", voter);
}

From source file:nu.localhost.tapestry5.springsecurity.services.SecurityModule.java

public final void contributeAccessDecisionManager(
        final OrderedConfiguration<AccessDecisionVoter> configuration) {
    configuration.add("RoleVoter", new RoleVoter());
}

From source file:ch.astina.hesperid.web.services.SecurityModule.java

/**
 * Used by the AccessDecisionManager// www . ja va 2s.co  m
 */
public final void contributeAccessDecisionManager(
        final OrderedConfiguration<AccessDecisionVoter> configuration) {
    configuration.add("RoleVoter", new RoleVoter());
}

From source file:org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration.java

/**
 * Allows subclasses to provide a custom {@link AccessDecisionManager}. The default is
 * a {@link AffirmativeBased} with the following voters:
 *
 * <ul>//  ww  w. j a v  a2 s .co  m
 * <li>{@link PreInvocationAuthorizationAdviceVoter}</li>
 * <li>{@link RoleVoter}</li>
 * <li>{@link AuthenticatedVoter}</li>
 * </ul>
 *
 * @return the {@link AccessDecisionManager} to use
 */
protected AccessDecisionManager accessDecisionManager() {
    List<AccessDecisionVoter<? extends Object>> decisionVoters = new ArrayList<AccessDecisionVoter<? extends Object>>();
    ExpressionBasedPreInvocationAdvice expressionAdvice = new ExpressionBasedPreInvocationAdvice();
    expressionAdvice.setExpressionHandler(getExpressionHandler());
    if (prePostEnabled()) {
        decisionVoters.add(new PreInvocationAuthorizationAdviceVoter(expressionAdvice));
    }
    if (jsr250Enabled()) {
        decisionVoters.add(new Jsr250Voter());
    }
    RoleVoter roleVoter = new RoleVoter();
    GrantedAuthorityDefaults grantedAuthorityDefaults = getSingleBeanOrNull(GrantedAuthorityDefaults.class);
    if (grantedAuthorityDefaults != null) {
        roleVoter.setRolePrefix(grantedAuthorityDefaults.getRolePrefix());
    }
    decisionVoters.add(roleVoter);
    decisionVoters.add(new AuthenticatedVoter());
    return new AffirmativeBased(decisionVoters);
}