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

The following examples show how to use org.springframework.security.access.expression.method.MethodSecurityExpressionHandler. These examples are extracted from open source projects. 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
@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
@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
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
    DefaultMethodSecurityExpressionHandler expressionHandler =
            new DefaultMethodSecurityExpressionHandler();
    expressionHandler.setPermissionEvaluator(platformPermissionEvaluator);
    return expressionHandler;
}
 
Example 4
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
	DefaultMethodSecurityExpressionHandler expressionHandler = new DefaultMethodSecurityExpressionHandler();
	// expressionHandler.setPermissionEvaluator(permissionEvaluator());
	expressionHandler.setRoleHierarchy(roleHierarchy());
	return expressionHandler;
}
 
Example 5
Source Project: tutorials   Source File: MethodSecurityConfig.java    License: 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 6
Source Project: tutorials   Source File: ACLContext.java    License: 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 7
Source Project: Spring-5.0-Projects   Source File: MethodSecurityConfig.java    License: MIT License 4 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
	return new OAuth2MethodSecurityExpressionHandler();
}
 
Example 8
Source Project: oauth2lab   Source File: MethodSecurityConfig.java    License: MIT License 4 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
    return new OAuth2MethodSecurityExpressionHandler();
}
 
Example 9
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
	return new OAuth2MethodSecurityExpressionHandler();
}
 
Example 10
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
    return new OAuth2MethodSecurityExpressionHandler();
}
 
Example 11
Source Project: zhcet-web   Source File: MethodSecurityConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
    return new PermissionExpressionHandler(roleHierarchy);
}
 
Example 12
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
    return new OAuth2MethodSecurityExpressionHandler();
}
 
Example 13
Source Project: DAFramework   Source File: MethodSecurityConfig.java    License: MIT License 4 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
    return new OAuth2MethodSecurityExpressionHandler();
}
 
Example 14
Source Project: konker-platform   Source File: MethodSecurityConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
	return new OAuth2MethodSecurityExpressionHandler();
}
 
Example 15
Source Project: konker-platform   Source File: MethodSecurityConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
	return new OAuth2MethodSecurityExpressionHandler();
}
 
Example 16
Source Project: AbacSpringSecurity   Source File: MethodSecurityConfig.java    License: MIT License 4 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
	DefaultMethodSecurityExpressionHandler result = new DefaultMethodSecurityExpressionHandler();
	result.setPermissionEvaluator(permissionEvaluator);
	return result;
}
 
Example 17
Source Project: spring-security-oauth   Source File: MethodSecurityConfig.java    License: MIT License 4 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
    return new OAuth2MethodSecurityExpressionHandler();
}
 
Example 18
Source Project: spring-security-oauth   Source File: MethodSecurityConfig.java    License: MIT License 4 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
    return new OAuth2MethodSecurityExpressionHandler();
}
 
Example 19
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
    PlatformSecurityExpressionHandler expressionHandler = new PlatformSecurityExpressionHandler();
    expressionHandler.setPermissionEvaluator(platformPermissionEvaluator);
    return expressionHandler;
}
 
Example 20
Source Project: NFVO   Source File: SecurityConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
  return new OAuth2MethodSecurityExpressionHandler();
}
 
Example 21
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
    return new OAuth2MethodSecurityExpressionHandler();
}
 
Example 22
Source Project: fullstop   Source File: MethodSecurityConfiguration.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
    return new OAuth2MethodSecurityExpressionHandler();
}
 
Example 23
Source Project: cukes   Source File: OAuthSampleApplication.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
    return new OAuth2MethodSecurityExpressionHandler();
}
 
Example 24
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
    return new OAuth2MethodSecurityExpressionHandler();
}
 
Example 25
Source Project: omh-dsu-ri   Source File: MethodSecurityConfiguration.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
    return new OAuth2MethodSecurityExpressionHandler();
}
 
Example 26
Source Project: cloudbreak   Source File: SecurityConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
    DefaultMethodSecurityExpressionHandler expressionHandler = new DefaultMethodSecurityExpressionHandler();
    expressionHandler.setPermissionEvaluator(tenantBasedPermissionEvaluator);
    return expressionHandler;
}
 
Example 27
Source Project: cloudbreak   Source File: SecurityConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
    DefaultMethodSecurityExpressionHandler expressionHandler = new DefaultMethodSecurityExpressionHandler();
    expressionHandler.setPermissionEvaluator(tenantBasedPermissionEvaluator);
    return expressionHandler;
}
 
Example 28
Source Project: tutorials   Source File: AclMethodSecurityConfiguration.java    License: MIT License 4 votes vote down vote up
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
    return defaultMethodSecurityExpressionHandler;
}
 
Example 29
Source Project: spring-boot   Source File: OAuth2ResourceServerConfig.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * 启用 #oauth2 表达式验证
 *
 * @return
 */
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
    return new OAuth2MethodSecurityExpressionHandler();
}