org.springframework.security.access.vote.AuthenticatedVoter.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(11.0k)|赞(0)|评价(0)|浏览(113)

本文整理了Java中org.springframework.security.access.vote.AuthenticatedVoter.<init>()方法的一些代码示例,展示了AuthenticatedVoter.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AuthenticatedVoter.<init>()方法的具体详情如下:
包路径:org.springframework.security.access.vote.AuthenticatedVoter
类名称:AuthenticatedVoter
方法名:<init>

AuthenticatedVoter.<init>介绍

暂无

代码示例

代码示例来源:origin: spring-projects/spring-security

/**
 * Creates the default {@link AccessDecisionVoter} instances used if an
 * {@link AccessDecisionManager} was not specified.
 *
 * @param http the builder to use
 */
@Override
@SuppressWarnings("rawtypes")
final List<AccessDecisionVoter<? extends Object>> getDecisionVoters(H http) {
  List<AccessDecisionVoter<? extends Object>> decisionVoters = new ArrayList<AccessDecisionVoter<? extends Object>>();
  decisionVoters.add(new RoleVoter());
  decisionVoters.add(new AuthenticatedVoter());
  return decisionVoters;
}

代码示例来源:origin: spring-projects/spring-security

@Test
public void testFullyWorks() {
  AuthenticatedVoter voter = new AuthenticatedVoter();
  List<ConfigAttribute> def = SecurityConfig.createList(
      AuthenticatedVoter.IS_AUTHENTICATED_FULLY);
  assertThat(AccessDecisionVoter.ACCESS_DENIED).isEqualTo(
      voter.vote(createAnonymous(), null, def));
  assertThat(AccessDecisionVoter.ACCESS_DENIED).isEqualTo(
      voter.vote(createRememberMe(), null, def));
  assertThat(AccessDecisionVoter.ACCESS_GRANTED).isEqualTo(
      voter.vote(createFullyAuthenticated(), null, def));
}

代码示例来源:origin: spring-projects/spring-security

@Test
public void testRememberMeWorks() {
  AuthenticatedVoter voter = new AuthenticatedVoter();
  List<ConfigAttribute> def = SecurityConfig.createList(
      AuthenticatedVoter.IS_AUTHENTICATED_REMEMBERED);
  assertThat(AccessDecisionVoter.ACCESS_DENIED).isEqualTo(
      voter.vote(createAnonymous(), null, def));
  assertThat(AccessDecisionVoter.ACCESS_GRANTED).isEqualTo(
      voter.vote(createRememberMe(), null, def));
  assertThat(AccessDecisionVoter.ACCESS_GRANTED).isEqualTo(
      voter.vote(createFullyAuthenticated(), null, def));
}

代码示例来源:origin: spring-projects/spring-security

@Test
  public void testSupports() {
    AuthenticatedVoter voter = new AuthenticatedVoter();
    assertThat(voter.supports(String.class)).isTrue();
    assertThat(voter.supports(new SecurityConfig(
        AuthenticatedVoter.IS_AUTHENTICATED_ANONYMOUSLY))).isTrue();
    assertThat(voter.supports(
        new SecurityConfig(AuthenticatedVoter.IS_AUTHENTICATED_FULLY))).isTrue();
    assertThat(voter.supports(new SecurityConfig(
        AuthenticatedVoter.IS_AUTHENTICATED_REMEMBERED))).isTrue();
    assertThat(voter.supports(new SecurityConfig("FOO"))).isFalse();
  }
}

代码示例来源:origin: spring-projects/spring-security

@Test
public void testAnonymousWorks() {
  AuthenticatedVoter voter = new AuthenticatedVoter();
  List<ConfigAttribute> def = SecurityConfig.createList(
      AuthenticatedVoter.IS_AUTHENTICATED_ANONYMOUSLY);
  assertThat(AccessDecisionVoter.ACCESS_GRANTED).isEqualTo(
      voter.vote(createAnonymous(), null, def));
  assertThat(AccessDecisionVoter.ACCESS_GRANTED).isEqualTo(
      voter.vote(createRememberMe(), null, def));
  assertThat(AccessDecisionVoter.ACCESS_GRANTED).isEqualTo(
      voter.vote(createFullyAuthenticated(), null, def));
}

代码示例来源:origin: spring-projects/spring-security

@Test
public void testSetterRejectsNull() {
  AuthenticatedVoter voter = new AuthenticatedVoter();
  try {
    voter.setAuthenticationTrustResolver(null);
    fail("Expected IAE");
  }
  catch (IllegalArgumentException expected) {
  }
}

代码示例来源:origin: spring-projects/spring-security

decisionVoters.add(new AuthenticatedVoter());
return new AffirmativeBased(decisionVoters);

代码示例来源:origin: geoserver/geoserver

roleVoter.setRolePrefix("");
voters.add(roleVoter);
voters.add(new AuthenticatedVoter());
AffirmativeBased accessDecisionManager = new AffirmativeBased(voters);
accessDecisionManager.setAllowIfAllAbstainDecisions(

代码示例来源:origin: org.springframework.security/spring-security-config

/**
 * Creates the default {@link AccessDecisionVoter} instances used if an
 * {@link AccessDecisionManager} was not specified.
 *
 * @param http the builder to use
 */
@Override
@SuppressWarnings("rawtypes")
final List<AccessDecisionVoter<? extends Object>> getDecisionVoters(H http) {
  List<AccessDecisionVoter<? extends Object>> decisionVoters = new ArrayList<AccessDecisionVoter<? extends Object>>();
  decisionVoters.add(new RoleVoter());
  decisionVoters.add(new AuthenticatedVoter());
  return decisionVoters;
}

代码示例来源:origin: org.springframework.security/spring-security-config

/**
 * Allows subclasses to provide a custom {@link AccessDecisionManager}. The default is
 * a {@link AffirmativeBased} with the following voters:
 *
 * <ul>
 * <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());
  }
  decisionVoters.add(new RoleVoter());
  decisionVoters.add(new AuthenticatedVoter());
  return new AffirmativeBased(decisionVoters);
}

代码示例来源:origin: org.springframework.security/spring-security-javaconfig

/**
 * Creates the default {@link AccessDecisionVoter} instances used if an
 * {@link AccessDecisionManager} was not specified using
 * {@link #accessDecisionManager(AccessDecisionManager)}.
 */
@Override
@SuppressWarnings("rawtypes")
final List<AccessDecisionVoter> getDecisionVoters() {
  List<AccessDecisionVoter> decisionVoters = new ArrayList<AccessDecisionVoter>();
  decisionVoters.add(new RoleVoter());
  decisionVoters.add(new AuthenticatedVoter());
  return decisionVoters;
}

代码示例来源:origin: stackoverflow.com

@Configuration
@EnableGlobalMethodSecurity(securedEnabled = true)
public class MethodSecurityConfig extends GlobalMethodSecurityConfiguration {

  @SuppressWarnings("rawtypes")
  @Override
  protected AccessDecisionManager accessDecisionManager() {
    List<AccessDecisionVoter> voters = new ArrayList<>();
    voters.add(new AdminPermitVoter());
    voters.add(new RoleVoter());
    voters.add(new AuthenticatedVoter());
    return new AffirmativeBased(voters);
  }

}

代码示例来源:origin: apache/servicemix-bundles

/**
 * Creates the default {@link AccessDecisionVoter} instances used if an
 * {@link AccessDecisionManager} was not specified.
 *
 * @param http the builder to use
 */
@Override
@SuppressWarnings("rawtypes")
final List<AccessDecisionVoter<? extends Object>> getDecisionVoters(H http) {
  List<AccessDecisionVoter<? extends Object>> decisionVoters = new ArrayList<AccessDecisionVoter<? extends Object>>();
  decisionVoters.add(new RoleVoter());
  decisionVoters.add(new AuthenticatedVoter());
  return decisionVoters;
}

代码示例来源:origin: stackoverflow.com

@Override
protected void configure(HttpSecurity http) throws Exception {
  http
    .authorizeRequests()
      .accessDecisionManager(accessDecisionManager())
      .anyRequest()
      .permitAll()
    [...other configs...]
 }

@Bean(name = "accessDecisionManager")
public AccessDecisionManager accessDecisionManager() {
  List<AccessDecisionVoter> voters = new ArrayList<>();
  voters.add(new AdminPermitVoter());
  voters.add(new WebExpressionVoter());
  voters.add(new RoleVoter());
  voters.add(new AuthenticatedVoter());
  return new AffirmativeBased(voters);
}

代码示例来源:origin: spring-projects/spring-flex

private void configureDefaultAccessDecisionManager() {
  AffirmativeBased adm = new AffirmativeBased();
  List<AccessDecisionVoter> voters = new ArrayList<AccessDecisionVoter>();
  voters.add(new RoleVoter());
  voters.add(new AuthenticatedVoter());
  adm.setDecisionVoters(voters);
  setAccessDecisionManager(adm);
}

代码示例来源:origin: org.springframework.security/spring-security-javaconfig

/**
 * Allows subclasses to provide a custom {@link AccessDecisionManager}. The default is a {@link AffirmativeBased}
 * with the following voters:
 *
 * <ul>
 *     <li>{@link PreInvocationAuthorizationAdviceVoter}</li>
 *     <li>{@link RoleVoter} </li>
 *     <li>{@link AuthenticatedVoter} </li>
 * </ul>
 *
 * @return
 */
@SuppressWarnings("rawtypes")
protected AccessDecisionManager accessDecisionManager() {
  List<AccessDecisionVoter> decisionVoters = new ArrayList<AccessDecisionVoter>();
  ExpressionBasedPreInvocationAdvice expressionAdvice = new ExpressionBasedPreInvocationAdvice();
  expressionAdvice.setExpressionHandler(getExpressionHandler());
  decisionVoters.add(new PreInvocationAuthorizationAdviceVoter(
      expressionAdvice));
  decisionVoters.add(new RoleVoter());
  decisionVoters.add(new AuthenticatedVoter());
  return new AffirmativeBased(decisionVoters);
}

代码示例来源:origin: apache/servicemix-bundles

/**
 * Allows subclasses to provide a custom {@link AccessDecisionManager}. The default is
 * a {@link AffirmativeBased} with the following voters:
 *
 * <ul>
 * <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());
  }
  decisionVoters.add(new RoleVoter());
  decisionVoters.add(new AuthenticatedVoter());
  return new AffirmativeBased(decisionVoters);
}

代码示例来源:origin: org.motechproject/motech-platform-web-security

AuthenticatedVoter authVoter = new AuthenticatedVoter();
  voters.add(authVoter);
} else {

代码示例来源:origin: org.codehaus.fabric3/fabric3-spring-security

@Init
public void init() throws SecurityInitException {
  if (getDecisionVoters() == null || getDecisionVoters().isEmpty()) {
    List<AccessDecisionVoter> voters = new ArrayList<AccessDecisionVoter>();
    RoleVoter roleVoter = new RoleVoter();
    voters.add(roleVoter);
    AuthenticatedVoter authenticatedVoter = new AuthenticatedVoter();
    voters.add(authenticatedVoter);
    setDecisionVoters(voters);
  }
  if ("affirmative".equals(managerType)) {
    AffirmativeBased affirmativeBased = new AffirmativeBased();
    affirmativeBased.setDecisionVoters(getDecisionVoters());
    delegate = affirmativeBased;
  } else if ("consensus".equals(managerType)) {
    ConsensusBased consensusBased = new ConsensusBased();
    consensusBased.setDecisionVoters(getDecisionVoters());
    delegate = consensusBased;
  } else if ("unanimous".equals(managerType)) {
    UnanimousBased unanimousBased = new UnanimousBased();
    unanimousBased.setDecisionVoters(getDecisionVoters());
    delegate = unanimousBased;
  } else {
    throw new SecurityInitException("Unknown access decision manager type: " + managerType);
  }
}

代码示例来源:origin: stackoverflow.com

return new UnanimousBased(Arrays.asList(new ScopeVoter(), new RoleVoter(), new AuthenticatedVoter()));

相关文章

微信公众号

最新文章

更多