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

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

Introduction

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

Prototype

public void setRolePrefix(String rolePrefix) 

Source Link

Document

Allows the default role prefix of ROLE_ to be overridden.

Usage

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:com.swordcode.webcore.security.server.MethodSecurityConfig.java

@SuppressWarnings("rawtypes")
@Override/*from   w  ww  .ja  va2s  . c om*/
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: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>/*from   ww w . j a  v a 2 s  .  com*/
 * <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);
}