本文整理了Java中org.springframework.security.access.vote.AuthenticatedVoter
类的一些代码示例,展示了AuthenticatedVoter
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AuthenticatedVoter
类的具体详情如下:
包路径:org.springframework.security.access.vote.AuthenticatedVoter
类名称:AuthenticatedVoter
[英]Votes if a ConfigAttribute#getAttribute() of IS_AUTHENTICATED_FULLY
or IS_AUTHENTICATED_REMEMBERED
or IS_AUTHENTICATED_ANONYMOUSLY
is present. This list is in order of most strict checking to least strict checking.
The current Authentication
will be inspected to determine if the principal has a particular level of authentication. The "FULLY" authenticated option means the user is authenticated fully (i.e. org.springframework.security.authentication.AuthenticationTrustResolver#isAnonymous(Authentication)is false and org.springframework.security.authentication.AuthenticationTrustResolver#isRememberMe(Authentication)is false). The "REMEMBERED" will grant access if the principal was either authenticated via remember-me OR is fully authenticated. The "ANONYMOUSLY" will grant access if the principal was authenticated via remember-me, OR anonymously, OR via full authentication.
All comparisons and prefixes are case sensitive.
[中]如果存在IS_AUTHENTICATED_FULLY
或IS_AUTHENTICATED_REMEMBERED
或IS_AUTHENTICATED_ANONYMOUSLY
的ConfigAttribute#getAttribute()进行表决。此列表按最严格检查到最不严格检查的顺序排列。
将检查当前Authentication
,以确定主体是否具有特定的身份验证级别。“完全”身份验证选项表示用户已完全身份验证(即org.springframework.security.authentication.AuthenticationTrustResolver#isAnonymous(身份验证)为false,而org为false。springframework。安全认证。AuthenticationTrustResolver#isRememberMe(身份验证)为false)。如果主体通过RememberMe进行了身份验证或完全通过了身份验证,“REMEMBERED”将授予访问权限。如果主体通过RememberMe、匿名或完全身份验证进行身份验证,则“匿名”将授予访问权限。
所有比较和前缀都区分大小写。
代码示例来源: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 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
if (this.supports(attribute)) {
result = ACCESS_DENIED;
if (isFullyAuthenticated(authentication)) {
return ACCESS_GRANTED;
|| isFullyAuthenticated(authentication)) {
return ACCESS_GRANTED;
|| isFullyAuthenticated(authentication)
|| authenticationTrustResolver.isRememberMe(authentication)) {
return ACCESS_GRANTED;
代码示例来源: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
@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
decisionVoters.add(new AuthenticatedVoter());
return new AffirmativeBased(decisionVoters);
代码示例来源: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: org.springframework.security/spring-security-core
if (this.supports(attribute)) {
result = ACCESS_DENIED;
if (isFullyAuthenticated(authentication)) {
return ACCESS_GRANTED;
|| isFullyAuthenticated(authentication)) {
return ACCESS_GRANTED;
|| isFullyAuthenticated(authentication)
|| authenticationTrustResolver.isRememberMe(authentication)) {
return ACCESS_GRANTED;
代码示例来源:origin: geoserver/geoserver
roleVoter.setRolePrefix("");
voters.add(roleVoter);
voters.add(new AuthenticatedVoter());
AffirmativeBased accessDecisionManager = new AffirmativeBased(voters);
accessDecisionManager.setAllowIfAllAbstainDecisions(
代码示例来源:origin: org.springframework.security/org.springframework.security.core
if (this.supports(attribute)) {
result = ACCESS_DENIED;
if (isFullyAuthenticated(authentication)) {
return ACCESS_GRANTED;
|| isFullyAuthenticated(authentication)) {
return ACCESS_GRANTED;
if (authenticationTrustResolver.isAnonymous(authentication) || isFullyAuthenticated(authentication)
|| authenticationTrustResolver.isRememberMe(authentication)) {
return ACCESS_GRANTED;
代码示例来源: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: apache/servicemix-bundles
if (this.supports(attribute)) {
result = ACCESS_DENIED;
if (isFullyAuthenticated(authentication)) {
return ACCESS_GRANTED;
|| isFullyAuthenticated(authentication)) {
return ACCESS_GRANTED;
|| isFullyAuthenticated(authentication)
|| authenticationTrustResolver.isRememberMe(authentication)) {
return ACCESS_GRANTED;
代码示例来源: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);
}
内容来源于网络,如有侵权,请联系作者删除!