本文整理了Java中org.springframework.security.access.vote.AffirmativeBased
类的一些代码示例,展示了AffirmativeBased
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AffirmativeBased
类的具体详情如下:
包路径:org.springframework.security.access.vote.AffirmativeBased
类名称:AffirmativeBased
[英]Simple concrete implementation of org.springframework.security.access.AccessDecisionManager that grants access if any AccessDecisionVoter
returns an affirmative response.
[中]org的简单具体实现。springframework。安全通道AccessDecisionManager,如果有AccessDecisionVoter
授予访问权限,则返回肯定响应。
代码示例来源: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: geoserver/geoserver
voters.add(roleVoter);
voters.add(new AuthenticatedVoter());
AffirmativeBased accessDecisionManager = new AffirmativeBased(voters);
accessDecisionManager.setAllowIfAllAbstainDecisions(
siConfig.isAllowIfAllAbstainDecisions());
filter.setAccessDecisionManager(accessDecisionManager);
代码示例来源:origin: spring-projects/spring-security
int deny = 0;
for (AccessDecisionVoter voter : getDecisionVoters()) {
int result = voter.vote(authentication, object, configAttributes);
checkAllowIfAllAbstainDecisions();
代码示例来源: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
@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: stackoverflow.com
AffirmativeBased adm = new AffirmativeBased();
adm.setDecisionVoters(voters);
代码示例来源: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: sk.seges.acris/acris-security-spring
@Bean
public AffirmativeBased AffirmativeAccessDecisionManager() {
AffirmativeBased decisionManager = new AffirmativeBased();
decisionManager.setAllowIfAllAbstainDecisions(false);
List<AccessDecisionVoter> decissionVoters = new ArrayList<AccessDecisionVoter>();
decissionVoters.add(roleVoter());
decisionManager.setDecisionVoters(decissionVoters);
return decisionManager;
}
}
代码示例来源:origin: stackoverflow.com
@Override
protected AccessDecisionManager accessDecisionManager()
{
try {
AffirmativeBased ab = (AffirmativeBased) super.accessDecisionManager();
List<AccessDecisionVoter<? extends Object>> advs = ab.getDecisionVoters();
ResourceBasedPreInvocationAdvice expressionAdvice = new ResourceBasedPreInvocationAdvice();
List<AccessDecisionVoter<? extends Object>> toBeRemoved = new ArrayList<>();
for (AccessDecisionVoter<? extends Object> adv : advs) {
if (adv instanceof PreInvocationAuthorizationAdviceVoter) {
toBeRemoved.add(adv);
}
}
for (AccessDecisionVoter<? extends Object> adv : toBeRemoved) {
advs.remove(adv);
}
advs.add(new PreInvocationAuthorizationAdviceVoter(expressionAdvice));
return ab;
}
catch (ClassCastException ex) {
ArrayList decisionVoters = new ArrayList();
ResourceBasedPreInvocationAdvice expressionAdvice = new ResourceBasedPreInvocationAdvice();
decisionVoters.add(new PreInvocationAuthorizationAdviceVoter(expressionAdvice));
return new AffirmativeBased(decisionVoters);
}
}
代码示例来源:origin: stackoverflow.com
voters.add(new RoleVoter());
AffirmativeBased affirmativeBased = new AffirmativeBased(voters);
affirmativeBased.setAllowIfAllAbstainDecisions(false);
affirmativeBased.afterPropertiesSet();
代码示例来源:origin: stackoverflow.com
public AffirmativeBased accessDecisionManager() {
AffirmativeBased affirmativeBased = new AffirmativeBased(Arrays.asList((AccessDecisionVoter) webExpressionVoter()));
affirmativeBased.setAllowIfAllAbstainDecisions(false);
return affirmativeBased;
代码示例来源: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: 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
@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: 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.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: 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: org.springframework.security/spring-security-core
int deny = 0;
for (AccessDecisionVoter voter : getDecisionVoters()) {
int result = voter.vote(authentication, object, configAttributes);
checkAllowIfAllAbstainDecisions();
代码示例来源: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
内容来源于网络,如有侵权,请联系作者删除!