From dce709a669fc733e03781260851bb92843fb0057 Mon Sep 17 00:00:00 2001 From: Luke Taylor Date: Fri, 11 Jul 2008 12:14:00 +0000 Subject: [PATCH] Minor code formatting in docbookk --- src/docbkx/secured-objects.xml | 61 ++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/src/docbkx/secured-objects.xml b/src/docbkx/secured-objects.xml index 3de54edd44..3de7416305 100644 --- a/src/docbkx/secured-objects.xml +++ b/src/docbkx/secured-objects.xml @@ -3,7 +3,8 @@
- AOP Alliance (MethodInvocation) Security Interceptor + AOP Alliance (MethodInvocation) Security Interceptor + Prior to Spring Security 2.0, securing MethodInvocations needed quite a @@ -49,7 +50,9 @@
- AspectJ (JoinPoint) Security Interceptor + + AspectJ (JoinPoint) Security Interceptor + The AspectJ security interceptor is very similar to the AOP Alliance security interceptor discussed in the previous section. @@ -100,44 +103,46 @@ Next you'll need to define an AspectJ aspect. For example: - package org.springframework.security.samples.aspectj; + +package org.springframework.security.samples.aspectj; - import org.springframework.security.intercept.method.aspectj.AspectJSecurityInterceptor; - import org.springframework.security.intercept.method.aspectj.AspectJCallback; - import org.springframework.beans.factory.InitializingBean; +import org.springframework.security.intercept.method.aspectj.AspectJSecurityInterceptor; +import org.springframework.security.intercept.method.aspectj.AspectJCallback; +import org.springframework.beans.factory.InitializingBean; public aspect DomainObjectInstanceSecurityAspect implements InitializingBean { private AspectJSecurityInterceptor securityInterceptor; pointcut domainObjectInstanceExecution(): target(PersistableEntity) - && execution(public * *(..)) && !within(DomainObjectInstanceSecurityAspect); + && execution(public * *(..)) && !within(DomainObjectInstanceSecurityAspect); Object around(): domainObjectInstanceExecution() { -if (this.securityInterceptor != null) { - AspectJCallback callback = new AspectJCallback() { - public Object proceedWithObject() { - return proceed(); + if (this.securityInterceptor == null) { + return proceed(); } -}; -return this.securityInterceptor.invoke(thisJoinPoint, callback); -} else { - return proceed(); -} + + AspectJCallback callback = new AspectJCallback() { + public Object proceedWithObject() { + return proceed(); + } + }; + + return this.securityInterceptor.invoke(thisJoinPoint, callback); } public AspectJSecurityInterceptor getSecurityInterceptor() { -return securityInterceptor; + return securityInterceptor; } public void setSecurityInterceptor(AspectJSecurityInterceptor securityInterceptor) { -this.securityInterceptor = securityInterceptor; + this.securityInterceptor = securityInterceptor; } public void afterPropertiesSet() throws Exception { -if (this.securityInterceptor == null) - throw new IllegalArgumentException("securityInterceptor required"); -} + if (this.securityInterceptor == null) + throw new IllegalArgumentException("securityInterceptor required"); + } } In the above example, the security interceptor will be applied @@ -155,13 +160,12 @@ if (this.securityInterceptor == null) with the AspectJSecurityInterceptor. A bean declaration which achieves this is shown below: - -<bean id="domainObjectInstanceSecurityAspect" - class="org.springframework.security.samples.aspectj.DomainObjectInstanceSecurityAspect" - factory-method="aspectOf"> -<property name="securityInterceptor"><ref bean="aspectJSecurityInterceptor"/></property> -</bean> - + + +]]> That's it! Now you can create your beans from anywhere within @@ -172,7 +176,6 @@ if (this.securityInterceptor == null)
FilterInvocation Security Interceptor - To secure FilterInvocations, developers need to add a FilterSecurityInterceptor to their filter chain.