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

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

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

AffirmativeBased.<init>介绍

暂无

代码示例

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

/**
 * Creates the default {@code AccessDecisionManager}
 * @return the default {@code AccessDecisionManager}
 */
private AccessDecisionManager createDefaultAccessDecisionManager(H http) {
  AffirmativeBased result = new AffirmativeBased(getDecisionVoters(http));
  return postProcess(result);
}

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

@Bean
public ChannelSecurityInterceptor inboundChannelSecurity() {
  ChannelSecurityInterceptor channelSecurityInterceptor = new ChannelSecurityInterceptor(
      inboundMessageSecurityMetadataSource());
  MessageExpressionVoter<Object> voter = new MessageExpressionVoter<>();
  voter.setExpressionHandler(getMessageExpressionHandler());
  List<AccessDecisionVoter<? extends Object>> voters = new ArrayList<AccessDecisionVoter<? extends Object>>();
  voters.add(voter);
  AffirmativeBased manager = new AffirmativeBased(voters);
  channelSecurityInterceptor.setAccessDecisionManager(manager);
  return channelSecurityInterceptor;
}

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

@Test(expected = AccessDeniedException.class)
public void oneDenyVoteTwoAbstainVotesDeniesAccess() throws Exception {
  mgr = new AffirmativeBased(Arrays.<AccessDecisionVoter<? extends Object>> asList(
      deny, abstain, abstain));
  mgr.decide(user, new Object(), attrs);
}

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

@Test
public void oneAffirmativeVoteTwoAbstainVotesGrantsAccess() throws Exception {
  mgr = new AffirmativeBased(Arrays.<AccessDecisionVoter<? extends Object>> asList(
      grant, abstain, abstain));
  mgr.decide(user, new Object(), attrs);
}

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

@Test
public void oneDenyVoteOneAbstainVoteOneAffirmativeVoteGrantsAccess()
    throws Exception {
  mgr = new AffirmativeBased(Arrays.<AccessDecisionVoter<? extends Object>> asList(
      deny, abstain, grant));
  mgr.decide(user, new Object(), attrs);
}

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

@Test(expected = AccessDeniedException.class)
public void onlyAbstainVotesDeniesAccessWithDefault() throws Exception {
  mgr = new AffirmativeBased(Arrays.<AccessDecisionVoter<? extends Object>> asList(
      abstain, abstain, abstain));
  assertThat(!mgr.isAllowIfAllAbstainDecisions()).isTrue(); // check default
  mgr.decide(user, new Object(), attrs);
}

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

@Test
  public void testThreeAbstainVotesGrantsAccessIfAllowIfAllAbstainDecisionsIsSet()
      throws Exception {
    mgr = new AffirmativeBased(Arrays.<AccessDecisionVoter<? extends Object>> asList(
        abstain, abstain, abstain));
    mgr.setAllowIfAllAbstainDecisions(true);
    assertThat(mgr.isAllowIfAllAbstainDecisions()).isTrue(); // check changed

    mgr.decide(user, new Object(), attrs);
  }
}

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

@Test
public void oneAffirmativeVoteOneDenyVoteOneAbstainVoteGrantsAccess()
    throws Exception {
  mgr = new AffirmativeBased(Arrays.<AccessDecisionVoter<? extends Object>> asList(
      grant, deny, abstain));
  mgr.afterPropertiesSet();
  mgr.decide(user, new Object(), attrs);
}

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

@SuppressWarnings("rawtypes")
@Override
protected void configure(HttpSecurity http) throws Exception {
  SecurityExpressionHandler<FilterInvocation> handler = new DefaultWebSecurityExpressionHandler();
  WebExpressionVoter expressionVoter = new WebExpressionVoter();
  AffirmativeBased adm = new AffirmativeBased(Arrays.<AccessDecisionVoter<? extends Object>>asList(expressionVoter));
  http
    .authorizeRequests()
      .expressionHandler(handler)
      .accessDecisionManager(adm)
      .filterSecurityInterceptorOncePerRequest(true)
      .antMatchers("/a", "/b").hasRole("ADMIN")
      .anyRequest().permitAll()
      .and()
    .formLogin();
}
// @formatter:on

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

return new AffirmativeBased(decisionVoters);

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

voters.add(roleVoter);
voters.add(new AuthenticatedVoter());
AffirmativeBased accessDecisionManager = new AffirmativeBased(voters);
accessDecisionManager.setAllowIfAllAbstainDecisions(
    siConfig.isAllowIfAllAbstainDecisions());

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

@Before
public final void setUp() throws Exception {
  MockitoAnnotations.initMocks(this);
  interceptor = new AspectJMethodSecurityInterceptor();
  AccessDecisionVoter[] voters = new AccessDecisionVoter[] {
      new RoleVoter(),
      new PreInvocationAuthorizationAdviceVoter(
          new ExpressionBasedPreInvocationAdvice()) };
  adm = new AffirmativeBased(
      Arrays.<AccessDecisionVoter<? extends Object>> asList(voters));
  interceptor.setAccessDecisionManager(adm);
  interceptor.setAuthenticationManager(authman);
  interceptor
      .setSecurityMetadataSource(new SecuredAnnotationSecurityMetadataSource());
  AnnotationSecurityAspect secAspect = AnnotationSecurityAspect.aspectOf();
  secAspect.setSecurityInterceptor(interceptor);
}

代码示例来源:origin: psi-probe/psi-probe

/**
 * 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;
}

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

/**
 * Creates the default {@code AccessDecisionManager}
 * @return the default {@code AccessDecisionManager}
 */
private AccessDecisionManager createDefaultAccessDecisionManager(H http) {
  AffirmativeBased result = new AffirmativeBased(getDecisionVoters(http));
  return postProcess(result);
}

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

private AbstractAccessDecisionManager createManager(SecurityRule rule) {
  List<AccessDecisionVoter<? extends Object>> voters = new ArrayList<AccessDecisionVoter<? extends Object>>();
  voters.add(new RoleVoter());
  if (rule.getComparisonType() == SecurityRule.COMPARISON_ANY) {
    return new AffirmativeBased(voters);
  } else if (rule.getComparisonType() == SecurityRule.COMPARISON_ALL) {
    return new UnanimousBased(voters);
  } else {
    throw new IllegalStateException("Unknown SecurityRule match type: " + rule.getComparisonType());
  }
}

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

@Bean
public ChannelSecurityInterceptor inboundChannelSecurity() {
  ChannelSecurityInterceptor channelSecurityInterceptor = new ChannelSecurityInterceptor(
      inboundMessageSecurityMetadataSource());
  MessageExpressionVoter<Object> voter = new MessageExpressionVoter<>();
  voter.setExpressionHandler(getMessageExpressionHandler());
  List<AccessDecisionVoter<? extends Object>> voters = new ArrayList<AccessDecisionVoter<? extends Object>>();
  voters.add(voter);
  AffirmativeBased manager = new AffirmativeBased(voters);
  channelSecurityInterceptor.setAccessDecisionManager(manager);
  return channelSecurityInterceptor;
}

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

@Bean
public AccessDecisionManager accessDecisionManager() {
  return new AffirmativeBased(Collections.singletonList(new RoleVoter()));
}

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

@Bean
public AccessDecisionManager accessDecisionManager() {
  return new AffirmativeBased(Collections.singletonList(new RoleVoter()));
}

代码示例来源: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: spring-projects/spring-webflow

private AbstractAccessDecisionManager createManager(SecurityRule rule) {
  List<AccessDecisionVoter<? extends Object>> voters = new ArrayList<AccessDecisionVoter<? extends Object>>();
  voters.add(new RoleVoter());
  if (rule.getComparisonType() == SecurityRule.COMPARISON_ANY) {
    return new AffirmativeBased(voters);
  } else if (rule.getComparisonType() == SecurityRule.COMPARISON_ALL) {
    return new UnanimousBased(voters);
  } else {
    throw new IllegalStateException("Unknown SecurityRule match type: " + rule.getComparisonType());
  }
}

相关文章