@@ -1214,9 +1214,9 @@ Kotlin::
1214
1214
companion object {
1215
1215
@Bean
1216
1216
fun methodSecurityExpressionHandler(val roleHierarchy: RoleHierarchy) : MethodSecurityExpressionHandler {
1217
- val handler = DefaultMethodSecurityExpressionHandler();
1218
- handler.setRoleHierarchy(roleHierarchy);
1219
- return handler;
1217
+ val handler = DefaultMethodSecurityExpressionHandler()
1218
+ handler.setRoleHierarchy(roleHierarchy)
1219
+ return handler
1220
1220
}
1221
1221
}
1222
1222
----
@@ -1260,41 +1260,43 @@ Java::
1260
1260
+
1261
1261
[source,java,role="primary"]
1262
1262
----
1263
- import static org.springframework.security.authorization.AuthorityAuthorizationManager.hasRole;
1263
+ import static org.springframework.security.authorization.AuthorityAuthorizationManager.hasRole
1264
1264
1265
1265
@Bean
1266
1266
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
1267
1267
static Advisor protectServicePointcut() {
1268
- AspectJExpressionPointcut pattern = new AspectJExpressionPointcut();
1269
- pattern.setExpression("execution(* com.mycompany.*Service.*(..))");
1270
- return new AuthorizationManagerBeforeMethodInterceptor(pattern, hasRole("USER"));
1268
+ AspectJExpressionPointcut pattern = new AspectJExpressionPointcut()
1269
+ pattern.setExpression("execution(* com.mycompany.*Service.*(..))")
1270
+ return new AuthorizationManagerBeforeMethodInterceptor(pattern, hasRole("USER"))
1271
1271
}
1272
1272
----
1273
1273
1274
1274
Kotlin::
1275
1275
+
1276
1276
[source,kotlin,role="secondary"]
1277
1277
----
1278
- import static org.springframework.security.authorization.AuthorityAuthorizationManager.hasRole;
1278
+ import static org.springframework.security.authorization.AuthorityAuthorizationManager.hasRole
1279
1279
1280
1280
companion object {
1281
1281
@Bean
1282
1282
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
1283
1283
fun protectServicePointcut(): Advisor {
1284
- val pattern = AspectJExpressionPointcut();
1285
- pattern.setExpression("execution(* com.mycompany.*Service.*(..))");
1286
- return new AuthorizationManagerBeforeMethodInterceptor(pattern, hasRole("USER"));
1284
+ val pattern = AspectJExpressionPointcut()
1285
+ pattern.setExpression("execution(* com.mycompany.*Service.*(..))")
1286
+ return new AuthorizationManagerBeforeMethodInterceptor(pattern, hasRole("USER"))
1287
1287
}
1288
1288
}
1289
1289
----
1290
- ======
1291
1290
1292
- [source,xml]
1291
+ Xml::
1292
+ +
1293
+ [source,xml,role="secondary"]
1293
1294
----
1294
1295
<sec:method-security>
1295
1296
<protect-pointcut expression="execution(* com.mycompany.*Service.*(..))" access="hasRole('USER')"/>
1296
1297
</sec:method-security>
1297
1298
----
1299
+ ======
1298
1300
1299
1301
[[weave-aspectj]]
1300
1302
=== Integrate with AspectJ Byte-weaving
@@ -1445,7 +1447,7 @@ open class MyService {
1445
1447
fun readResource(...): MyResource
1446
1448
1447
1449
@PreAuthorize("@authz.check(#root)")
1448
- fun shareResource(...): MyResource;
1450
+ fun shareResource(...): MyResource
1449
1451
}
1450
1452
----
1451
1453
@@ -1769,8 +1771,8 @@ class MyExpressionHandler: DefaultMethodSecurityExpressionHandler {
1769
1771
val context = super.createEvaluationContext(authentication, mi) as StandardEvaluationContext
1770
1772
val delegate = context.getRootObject().getValue() as MethodSecurityExpressionOperations
1771
1773
val root = MySecurityExpressionRoot(delegate)
1772
- context.setRootObject(root);
1773
- return context;
1774
+ context.setRootObject(root)
1775
+ return context
1774
1776
}
1775
1777
}
1776
1778
----
0 commit comments