org.springframework.security.access.expression.method.MethodSecurityExpressionHandler Java Examples

The following examples show how to use org.springframework.security.access.expression.method.MethodSecurityExpressionHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OAuth2AutoConfigurationTests.java    From spring-security-oauth2-boot with Apache License 2.0 5 votes vote down vote up
@Test
public void methodSecurityExpressionHandlerIsConfiguredWithRoleHierarchyFromTheContext() {
	this.context = new AnnotationConfigServletWebServerApplicationContext();
	this.context.register(RoleHierarchyConfiguration.class, AuthorizationAndResourceServerConfiguration.class,
			MinimalSecureWebApplication.class);
	this.context.refresh();
	PreInvocationAuthorizationAdvice advice = this.context.getBean(PreInvocationAuthorizationAdvice.class);
	MethodSecurityExpressionHandler expressionHandler = (MethodSecurityExpressionHandler) ReflectionTestUtils
			.getField(advice, "expressionHandler");
	RoleHierarchy roleHierarchy = (RoleHierarchy) ReflectionTestUtils.getField(expressionHandler, "roleHierarchy");
	assertThat(roleHierarchy).isSameAs(this.context.getBean(RoleHierarchy.class));
}
 
Example #2
Source File: OAuth2AutoConfigurationTests.java    From spring-security-oauth2-boot with Apache License 2.0 5 votes vote down vote up
@Test
public void methodSecurityExpressionHandlerIsConfiguredWithPermissionEvaluatorFromTheContext() {
	this.context = new AnnotationConfigServletWebServerApplicationContext();
	this.context.register(PermissionEvaluatorConfiguration.class, AuthorizationAndResourceServerConfiguration.class,
			MinimalSecureWebApplication.class);
	this.context.refresh();
	PreInvocationAuthorizationAdvice advice = this.context.getBean(PreInvocationAuthorizationAdvice.class);
	MethodSecurityExpressionHandler expressionHandler = (MethodSecurityExpressionHandler) ReflectionTestUtils
			.getField(advice, "expressionHandler");
	PermissionEvaluator permissionEvaluator = (PermissionEvaluator) ReflectionTestUtils.getField(expressionHandler,
			"permissionEvaluator");
	assertThat(permissionEvaluator).isSameAs(this.context.getBean(PermissionEvaluator.class));
}
 
Example #3
Source File: ACLContext.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
public MethodSecurityExpressionHandler defaultMethodSecurityExpressionHandler() {
    DefaultMethodSecurityExpressionHandler expressionHandler = new DefaultMethodSecurityExpressionHandler();
    AclPermissionEvaluator permissionEvaluator = new AclPermissionEvaluator(aclService());
    expressionHandler.setPermissionEvaluator(permissionEvaluator);
    expressionHandler.setPermissionCacheOptimizer(new AclPermissionCacheOptimizer(aclService()));
    return expressionHandler;
}
 
Example #4
Source File: MethodSecurityConfig.java    From tutorials with MIT License 5 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
    // final DefaultMethodSecurityExpressionHandler expressionHandler = new DefaultMethodSecurityExpressionHandler();
    final CustomMethodSecurityExpressionHandler expressionHandler = new CustomMethodSecurityExpressionHandler();
    expressionHandler.setPermissionEvaluator(new CustomPermissionEvaluator());
    return expressionHandler;
}
 
Example #5
Source File: MethodSecurityConfig.java    From demo-spring-security-cas with Apache License 2.0 5 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
	DefaultMethodSecurityExpressionHandler expressionHandler = new DefaultMethodSecurityExpressionHandler();
	// expressionHandler.setPermissionEvaluator(permissionEvaluator());
	expressionHandler.setRoleHierarchy(roleHierarchy());
	return expressionHandler;
}
 
Example #6
Source File: PlatformGlobalMethodSecurityConfiguration.java    From abixen-platform with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
    DefaultMethodSecurityExpressionHandler expressionHandler =
            new DefaultMethodSecurityExpressionHandler();
    expressionHandler.setPermissionEvaluator(platformPermissionEvaluator);
    return expressionHandler;
}
 
Example #7
Source File: MethodSecurityConfig.java    From spring-security-oauth with MIT License 4 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
    return new OAuth2MethodSecurityExpressionHandler();
}
 
Example #8
Source File: AclMethodSecurityConfiguration.java    From tutorials with MIT License 4 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
    return defaultMethodSecurityExpressionHandler;
}
 
Example #9
Source File: SecurityConfig.java    From cloudbreak with Apache License 2.0 4 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
    DefaultMethodSecurityExpressionHandler expressionHandler = new DefaultMethodSecurityExpressionHandler();
    expressionHandler.setPermissionEvaluator(tenantBasedPermissionEvaluator);
    return expressionHandler;
}
 
Example #10
Source File: SecurityConfig.java    From cloudbreak with Apache License 2.0 4 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
    DefaultMethodSecurityExpressionHandler expressionHandler = new DefaultMethodSecurityExpressionHandler();
    expressionHandler.setPermissionEvaluator(tenantBasedPermissionEvaluator);
    return expressionHandler;
}
 
Example #11
Source File: MethodSecurityConfiguration.java    From omh-dsu-ri with Apache License 2.0 4 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
    return new OAuth2MethodSecurityExpressionHandler();
}
 
Example #12
Source File: OAuth2MethodSecurityConfiguration.java    From spring-oauth-server with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
    return new OAuth2MethodSecurityExpressionHandler();
}
 
Example #13
Source File: OAuthSampleApplication.java    From cukes with Apache License 2.0 4 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
    return new OAuth2MethodSecurityExpressionHandler();
}
 
Example #14
Source File: MethodSecurityConfiguration.java    From fullstop with Apache License 2.0 4 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
    return new OAuth2MethodSecurityExpressionHandler();
}
 
Example #15
Source File: GlobalMethodSecurityConfig.java    From edison-microservice with Apache License 2.0 4 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
    return new OAuth2MethodSecurityExpressionHandler();
}
 
Example #16
Source File: SecurityConfig.java    From NFVO with Apache License 2.0 4 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
  return new OAuth2MethodSecurityExpressionHandler();
}
 
Example #17
Source File: PlatformGlobalMethodSecurityConfiguration.java    From abixen-platform with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
    PlatformSecurityExpressionHandler expressionHandler = new PlatformSecurityExpressionHandler();
    expressionHandler.setPermissionEvaluator(platformPermissionEvaluator);
    return expressionHandler;
}
 
Example #18
Source File: MethodSecurityConfig.java    From Spring-5.0-Projects with MIT License 4 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
	return new OAuth2MethodSecurityExpressionHandler();
}
 
Example #19
Source File: MethodSecurityConfig.java    From spring-security-oauth with MIT License 4 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
    return new OAuth2MethodSecurityExpressionHandler();
}
 
Example #20
Source File: MethodSecurityConfig.java    From AbacSpringSecurity with MIT License 4 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
	DefaultMethodSecurityExpressionHandler result = new DefaultMethodSecurityExpressionHandler();
	result.setPermissionEvaluator(permissionEvaluator);
	return result;
}
 
Example #21
Source File: MethodSecurityConfig.java    From konker-platform with Apache License 2.0 4 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
	return new OAuth2MethodSecurityExpressionHandler();
}
 
Example #22
Source File: MethodSecurityConfig.java    From konker-platform with Apache License 2.0 4 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
	return new OAuth2MethodSecurityExpressionHandler();
}
 
Example #23
Source File: MethodSecurityConfig.java    From DAFramework with MIT License 4 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
    return new OAuth2MethodSecurityExpressionHandler();
}
 
Example #24
Source File: GlobalMethodSecurityConfig.java    From Building-Web-Apps-with-Spring-5-and-Angular with MIT License 4 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
    return new OAuth2MethodSecurityExpressionHandler();
}
 
Example #25
Source File: MethodSecurityConfig.java    From zhcet-web with Apache License 2.0 4 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
    return new PermissionExpressionHandler(roleHierarchy);
}
 
Example #26
Source File: ResourceServerConfig.java    From java8-spring-cloud-microservice-demo with MIT License 4 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
    return new OAuth2MethodSecurityExpressionHandler();
}
 
Example #27
Source File: OAuth2AutoConfigurationTests.java    From spring-security-oauth2-boot with Apache License 2.0 4 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
	return new OAuth2MethodSecurityExpressionHandler();
}
 
Example #28
Source File: MethodSecurityConfig.java    From oauth2lab with MIT License 4 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
    return new OAuth2MethodSecurityExpressionHandler();
}
 
Example #29
Source File: OAuth2ResourceServerConfig.java    From spring-boot with Apache License 2.0 2 votes vote down vote up
/**
 * 启用 #oauth2 表达式验证
 *
 * @return
 */
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
    return new OAuth2MethodSecurityExpressionHandler();
}