@@ -49,55 +49,55 @@ final class PrePostMethodSecurityConfiguration implements ApplicationContextAwar
49
49
50
50
private final PreFilterAuthorizationMethodInterceptor preFilterAuthorizationMethodInterceptor = new PreFilterAuthorizationMethodInterceptor ();
51
51
52
+ private final AuthorizationManagerBeforeMethodInterceptor preAuthorizeAuthorizationMethodInterceptor ;
53
+
52
54
private final PreAuthorizeAuthorizationManager preAuthorizeAuthorizationManager = new PreAuthorizeAuthorizationManager ();
53
55
56
+ private final AuthorizationManagerAfterMethodInterceptor postAuthorizeAuthorizaitonMethodInterceptor ;
57
+
54
58
private final PostAuthorizeAuthorizationManager postAuthorizeAuthorizationManager = new PostAuthorizeAuthorizationManager ();
55
59
56
60
private final PostFilterAuthorizationMethodInterceptor postFilterAuthorizationMethodInterceptor = new PostFilterAuthorizationMethodInterceptor ();
57
61
58
62
private final DefaultMethodSecurityExpressionHandler expressionHandler = new DefaultMethodSecurityExpressionHandler ();
59
63
60
- private boolean customMethodSecurityExpressionHandler = false ;
64
+ PrePostMethodSecurityConfiguration () {
65
+ this .preAuthorizeAuthorizationManager .setExpressionHandler (this .expressionHandler );
66
+ this .preAuthorizeAuthorizationMethodInterceptor = AuthorizationManagerBeforeMethodInterceptor
67
+ .preAuthorize (this .preAuthorizeAuthorizationManager );
68
+ this .postAuthorizeAuthorizationManager .setExpressionHandler (this .expressionHandler );
69
+ this .postAuthorizeAuthorizaitonMethodInterceptor = AuthorizationManagerAfterMethodInterceptor
70
+ .postAuthorize (this .postAuthorizeAuthorizationManager );
71
+ this .preFilterAuthorizationMethodInterceptor .setExpressionHandler (this .expressionHandler );
72
+ this .postFilterAuthorizationMethodInterceptor .setExpressionHandler (this .expressionHandler );
73
+ }
61
74
62
75
@ Bean
63
76
@ Role (BeanDefinition .ROLE_INFRASTRUCTURE )
64
77
Advisor preFilterAuthorizationMethodInterceptor () {
65
- if (!this .customMethodSecurityExpressionHandler ) {
66
- this .preAuthorizeAuthorizationManager .setExpressionHandler (this .expressionHandler );
67
- }
68
78
return this .preFilterAuthorizationMethodInterceptor ;
69
79
}
70
80
71
81
@ Bean
72
82
@ Role (BeanDefinition .ROLE_INFRASTRUCTURE )
73
83
Advisor preAuthorizeAuthorizationMethodInterceptor () {
74
- if (!this .customMethodSecurityExpressionHandler ) {
75
- this .preAuthorizeAuthorizationManager .setExpressionHandler (this .expressionHandler );
76
- }
77
- return AuthorizationManagerBeforeMethodInterceptor .preAuthorize (this .preAuthorizeAuthorizationManager );
84
+ return this .preAuthorizeAuthorizationMethodInterceptor ;
78
85
}
79
86
80
87
@ Bean
81
88
@ Role (BeanDefinition .ROLE_INFRASTRUCTURE )
82
89
Advisor postAuthorizeAuthorizationMethodInterceptor () {
83
- if (!this .customMethodSecurityExpressionHandler ) {
84
- this .postAuthorizeAuthorizationManager .setExpressionHandler (this .expressionHandler );
85
- }
86
- return AuthorizationManagerAfterMethodInterceptor .postAuthorize (this .postAuthorizeAuthorizationManager );
90
+ return this .postAuthorizeAuthorizaitonMethodInterceptor ;
87
91
}
88
92
89
93
@ Bean
90
94
@ Role (BeanDefinition .ROLE_INFRASTRUCTURE )
91
95
Advisor postFilterAuthorizationMethodInterceptor () {
92
- if (!this .customMethodSecurityExpressionHandler ) {
93
- this .postFilterAuthorizationMethodInterceptor .setExpressionHandler (this .expressionHandler );
94
- }
95
96
return this .postFilterAuthorizationMethodInterceptor ;
96
97
}
97
98
98
99
@ Autowired (required = false )
99
100
void setMethodSecurityExpressionHandler (MethodSecurityExpressionHandler methodSecurityExpressionHandler ) {
100
- this .customMethodSecurityExpressionHandler = true ;
101
101
this .preFilterAuthorizationMethodInterceptor .setExpressionHandler (methodSecurityExpressionHandler );
102
102
this .preAuthorizeAuthorizationManager .setExpressionHandler (methodSecurityExpressionHandler );
103
103
this .postAuthorizeAuthorizationManager .setExpressionHandler (methodSecurityExpressionHandler );
0 commit comments