diff --git a/docs/modules/ROOT/pages/servlet/authorization/method-security.adoc b/docs/modules/ROOT/pages/servlet/authorization/method-security.adoc index 9414da1929..600ef376e8 100644 --- a/docs/modules/ROOT/pages/servlet/authorization/method-security.adoc +++ b/docs/modules/ROOT/pages/servlet/authorization/method-security.adoc @@ -1214,9 +1214,9 @@ Kotlin:: companion object { @Bean fun methodSecurityExpressionHandler(val roleHierarchy: RoleHierarchy) : MethodSecurityExpressionHandler { - val handler = DefaultMethodSecurityExpressionHandler(); - handler.setRoleHierarchy(roleHierarchy); - return handler; + val handler = DefaultMethodSecurityExpressionHandler() + handler.setRoleHierarchy(roleHierarchy) + return handler } } ---- @@ -1260,14 +1260,14 @@ Java:: + [source,java,role="primary"] ---- -import static org.springframework.security.authorization.AuthorityAuthorizationManager.hasRole; +import static org.springframework.security.authorization.AuthorityAuthorizationManager.hasRole @Bean @Role(BeanDefinition.ROLE_INFRASTRUCTURE) static Advisor protectServicePointcut() { - AspectJExpressionPointcut pattern = new AspectJExpressionPointcut(); - pattern.setExpression("execution(* com.mycompany.*Service.*(..))"); - return new AuthorizationManagerBeforeMethodInterceptor(pattern, hasRole("USER")); + AspectJExpressionPointcut pattern = new AspectJExpressionPointcut() + pattern.setExpression("execution(* com.mycompany.*Service.*(..))") + return new AuthorizationManagerBeforeMethodInterceptor(pattern, hasRole("USER")) } ---- @@ -1275,26 +1275,28 @@ Kotlin:: + [source,kotlin,role="secondary"] ---- -import static org.springframework.security.authorization.AuthorityAuthorizationManager.hasRole; +import static org.springframework.security.authorization.AuthorityAuthorizationManager.hasRole companion object { @Bean @Role(BeanDefinition.ROLE_INFRASTRUCTURE) fun protectServicePointcut(): Advisor { - val pattern = AspectJExpressionPointcut(); - pattern.setExpression("execution(* com.mycompany.*Service.*(..))"); - return new AuthorizationManagerBeforeMethodInterceptor(pattern, hasRole("USER")); + val pattern = AspectJExpressionPointcut() + pattern.setExpression("execution(* com.mycompany.*Service.*(..))") + return new AuthorizationManagerBeforeMethodInterceptor(pattern, hasRole("USER")) } } ---- -====== -[source,xml] +Xml:: ++ +[source,xml,role="secondary"] ---- ---- +====== [[weave-aspectj]] === Integrate with AspectJ Byte-weaving @@ -1445,7 +1447,7 @@ open class MyService { fun readResource(...): MyResource @PreAuthorize("@authz.check(#root)") - fun shareResource(...): MyResource; + fun shareResource(...): MyResource } ---- @@ -1769,8 +1771,8 @@ class MyExpressionHandler: DefaultMethodSecurityExpressionHandler { val context = super.createEvaluationContext(authentication, mi) as StandardEvaluationContext val delegate = context.getRootObject().getValue() as MethodSecurityExpressionOperations val root = MySecurityExpressionRoot(delegate) - context.setRootObject(root); - return context; + context.setRootObject(root) + return context } } ----