@@ -108,7 +108,7 @@ Kotlin::
108
108
open class MyCustomerService {
109
109
@PreAuthorize("hasAuthority('permission:read')")
110
110
@PostAuthorize("returnObject.owner == authentication.name")
111
- fun readCustomer(val id: String): Customer { ... }
111
+ fun readCustomer(id: String): Customer { ... }
112
112
}
113
113
----
114
114
======
@@ -338,7 +338,7 @@ Kotlin::
338
338
@Component
339
339
open class BankService {
340
340
@PreAuthorize("hasRole('ADMIN')")
341
- fun readAccount(val id: Long): Account {
341
+ fun readAccount(id: Long): Account {
342
342
// ... is only invoked if the `Authentication` has the `ROLE_ADMIN` authority
343
343
}
344
344
}
@@ -426,7 +426,7 @@ Kotlin::
426
426
@Component
427
427
open class BankService {
428
428
@PostAuthorize("returnObject.owner == authentication.name")
429
- fun readAccount(val id: Long): Account {
429
+ fun readAccount(id: Long): Account {
430
430
// ... is only returned if the `Account` belongs to the logged in user
431
431
}
432
432
}
@@ -536,7 +536,7 @@ Kotlin::
536
536
@Component
537
537
open class BankService {
538
538
@RequireOwnership
539
- fun readAccount(val id: Long): Account {
539
+ fun readAccount(id: Long): Account {
540
540
// ... is only returned if the `Account` belongs to the logged in user
541
541
}
542
542
}
@@ -993,7 +993,7 @@ Kotlin::
993
993
@Component
994
994
open class BankService {
995
995
@IsAdmin
996
- fun readAccount(val id: Long): Account {
996
+ fun readAccount(id: Long): Account {
997
997
// ... is only returned if the `Account` belongs to the logged in user
998
998
}
999
999
}
@@ -1084,7 +1084,7 @@ Kotlin::
1084
1084
@Component
1085
1085
open class BankService {
1086
1086
@HasRole("ADMIN")
1087
- fun readAccount(val id: Long): Account {
1087
+ fun readAccount(id: Long): Account {
1088
1088
// ... is only returned if the `Account` belongs to the logged in user
1089
1089
}
1090
1090
}
@@ -1144,7 +1144,7 @@ Kotlin::
1144
1144
@Component
1145
1145
open class BankService {
1146
1146
@HasAnyRole(roles = arrayOf("'USER'", "'ADMIN'"))
1147
- fun readAccount(val id: Long): Account {
1147
+ fun readAccount(id: Long): Account {
1148
1148
// ... is only returned if the `Account` belongs to the logged in user
1149
1149
}
1150
1150
}
@@ -1271,7 +1271,7 @@ Kotlin::
1271
1271
----
1272
1272
@Component("authz")
1273
1273
open class AuthorizationLogic {
1274
- fun decide(val operations: MethodSecurityExpressionOperations): boolean {
1274
+ fun decide(operations: MethodSecurityExpressionOperations): boolean {
1275
1275
// ... authorization logic
1276
1276
}
1277
1277
}
@@ -1342,7 +1342,7 @@ Kotlin::
1342
1342
----
1343
1343
@Component("authz")
1344
1344
open class AuthorizationLogic {
1345
- fun decide(val operations: MethodSecurityExpressionOperations): AuthorizationDecision {
1345
+ fun decide(operations: MethodSecurityExpressionOperations): AuthorizationDecision {
1346
1346
// ... authorization logic
1347
1347
return MyAuthorizationDecision(false, details)
1348
1348
}
@@ -1435,13 +1435,13 @@ Kotlin::
1435
1435
class MethodSecurityConfig {
1436
1436
@Bean
1437
1437
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
1438
- fun preAuthorize(val manager: MyAuthorizationManager) : Advisor {
1438
+ fun preAuthorize(manager: MyAuthorizationManager) : Advisor {
1439
1439
return AuthorizationManagerBeforeMethodInterceptor.preAuthorize(manager)
1440
1440
}
1441
1441
1442
1442
@Bean
1443
1443
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
1444
- fun postAuthorize(val manager: MyAuthorizationManager) : Advisor {
1444
+ fun postAuthorize(manager: MyAuthorizationManager) : Advisor {
1445
1445
return AuthorizationManagerAfterMethodInterceptor.postAuthorize(manager)
1446
1446
}
1447
1447
}
@@ -1501,7 +1501,7 @@ Kotlin::
1501
1501
----
1502
1502
companion object {
1503
1503
@Bean
1504
- fun methodSecurityExpressionHandler(val roleHierarchy: RoleHierarchy) : MethodSecurityExpressionHandler {
1504
+ fun methodSecurityExpressionHandler(roleHierarchy: RoleHierarchy) : MethodSecurityExpressionHandler {
1505
1505
val handler = DefaultMethodSecurityExpressionHandler()
1506
1506
handler.setRoleHierarchy(roleHierarchy)
1507
1507
return handler
@@ -3236,7 +3236,7 @@ Kotlin::
3236
3236
[source,kotlin,role="secondary"]
3237
3237
----
3238
3238
class MyAuthorizer {
3239
- fun isAdmin(val root: MethodSecurityExpressionOperations): boolean {
3239
+ fun isAdmin(root: MethodSecurityExpressionOperations): boolean {
3240
3240
val decision = root.hasAuthority("ADMIN");
3241
3241
// custom work ...
3242
3242
return decision;
@@ -3295,7 +3295,7 @@ Kotlin::
3295
3295
----
3296
3296
@Component
3297
3297
class MyExpressionHandler: DefaultMethodSecurityExpressionHandler {
3298
- override fun createEvaluationContext(val authentication: Supplier<Authentication>,
3298
+ override fun createEvaluationContext(authentication: Supplier<Authentication>,
3299
3299
val mi: MethodInvocation): EvaluationContext {
3300
3300
val context = super.createEvaluationContext(authentication, mi) as StandardEvaluationContext
3301
3301
val delegate = context.getRootObject().getValue() as MethodSecurityExpressionOperations
0 commit comments