<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Olaf&#039;s blog &#187; acegi</title>
	<atom:link href="http://olafsblog.sysbsb.de/category/acegi/feed/" rel="self" type="application/rss+xml" />
	<link>http://olafsblog.sysbsb.de</link>
	<description>Olaf&#039;s blog on software development and life</description>
	<lastBuildDate>Thu, 18 Nov 2010 07:57:20 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Howto use acegi-security and the @Secured annotation for method interception</title>
		<link>http://olafsblog.sysbsb.de/howto-use-acegi-security-and-the-secured-annotation-for-method-interception/</link>
		<comments>http://olafsblog.sysbsb.de/howto-use-acegi-security-and-the-secured-annotation-for-method-interception/#comments</comments>
		<pubDate>Fri, 04 Jul 2008 10:19:51 +0000</pubDate>
		<dc:creator>olaf</dc:creator>
				<category><![CDATA[J2EE]]></category>
		<category><![CDATA[System architecture]]></category>
		<category><![CDATA[acegi]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://olafsblog.sysbsb.de/?p=52</guid>
		<description><![CDATA[Acegi-security (now spring-security) provides a @Secured (org.acegisecurity.annotation.Secured) annotation.
Classes using this annotation can be processed by a suitable BeanPostProcessor, which will proxy the class so that calls to @Secured methods are intercepted and the required authentication is validated against the acegi security context. Note that the following is a configuration for acegi-security, things might be different [...]]]></description>
			<content:encoded><![CDATA[<p>Acegi-security (now spring-security) provides a @Secured (<code>org.acegisecurity.annotation.Secured</code>) annotation.<br />
Classes using this annotation can be processed by a suitable BeanPostProcessor, which will proxy the class so that calls to @Secured methods are intercepted and the required authentication is validated against the acegi security context. Note that the following is a configuration for acegi-security, things might be different with spring-security.</p>
<p><em>2008-07-12: Comment:<a href="http://www.jroller.com/habuma/entry/method_level_security_in_spring"> It is indeed a lot simpler using spring-security, as Craig Walls demonstrates in this posting in his blog &#8220;Spring-Loaded&#8221;</a></em>).</p>
<p>In order to activate the post processing for the @Secured annotations, a spring configuration such as the following is required:<br />
<span id="more-52"></span></p>
<pre class="brush: xml;">
    &lt;!-- Bean post-processor for activating any advisors --&gt;
    &lt;bean class=&quot;org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator&quot;/&gt;

    &lt;!-- The advisor that creates secured proxies for beans using security annotations such as @Secured --&gt;
    &lt;bean class=&quot;org.acegisecurity.intercept.method.aopalliance.MethodDefinitionSourceAdvisor&quot;&gt;
        &lt;constructor-arg&gt;
            &lt;ref bean=&quot;myMethodInterceptor&quot;/&gt;
        &lt;/constructor-arg&gt;
    &lt;/bean&gt;
</pre>
<p>Where <code>myMethodInterceptor</code> is a <a href="http://acegisecurity.org/acegi-security/apidocs/org/acegisecurity/intercept/method/aopalliance/MethodSecurityInterceptor.html">MethodSecurityInterceptor</a>, which may be configured like this:</p>
<pre class="brush: xml;">
    &lt;bean id=&quot;myMethodInterceptor&quot; class=&quot;org.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor&quot;&gt;
        &lt;property name=&quot;validateConfigAttributes&quot; value=&quot;false&quot;/&gt;
        &lt;property name=&quot;authenticationManager&quot; ref=&quot;authenticationManager&quot;/&gt;
        &lt;property name=&quot;accessDecisionManager&quot; ref=&quot;accessDecisionManager&quot;/&gt;
        &lt;property name=&quot;objectDefinitionSource&quot; ref=&quot;objectDefinitionSource&quot;/&gt;
    &lt;/bean&gt;
</pre>
<p>With a suitable <a href="http://www.acegisecurity.org/acegi-security/apidocs/org/acegisecurity/AuthenticationManager.html">AuthenticationManager</a>,  <a href="http://www.acegisecurity.org/acegi-security/apidocs/org/acegisecurity/AccessDecisionManager.html">AccessDescisionManager</a> and and <code>objectDefinitionSource</code> of type <a href="http://www.acegisecurity.org/acegi-security/apidocs/org/acegisecurity/intercept/method/MethodDefinitionSource.html">MethodDefinitionSource</a>.</p>
<p>Often it is the case that annotated bean classes must be proxied directly, rather than proxying some implemented interface. </p>
<p>If you get an exception such as<br />
<code><br />
 Failed to convert property value of type [$Proxy70] to required type ...<br />
 no matching editors or conversion strategy found<br />
</code></p>
<p>Your solution might be to force the proxying of the target class itself using:</p>
<pre class="brush: xml;">
    &lt;!-- Bean post-processor for auto-activating all advisors --&gt;
    &lt;bean class=&quot;org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator&quot;&gt;
        &lt;property name=&quot;proxyTargetClass&quot; value=&quot;true&quot; /&gt;
    &lt;/bean&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://olafsblog.sysbsb.de/howto-use-acegi-security-and-the-secured-annotation-for-method-interception/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

