<?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>Tales From The Cloud &#187; Spring Security</title>
	<atom:link href="http://blog.newsplore.com/tag/spring-security/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.newsplore.com</link>
	<description>Everything beta</description>
	<lastBuildDate>Tue, 07 Sep 2010 10:40:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Upgrading to Spring 3.0.0.M3 and Spring Security 3.0.0.M1</title>
		<link>http://blog.newsplore.com/2009/06/04/upgrading-to-spring-300m3-and-spring-security-300m1</link>
		<comments>http://blog.newsplore.com/2009/06/04/upgrading-to-spring-300m3-and-spring-security-300m1#comments</comments>
		<pubDate>Fri, 05 Jun 2009 02:50:31 +0000</pubDate>
		<dc:creator>Florin</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[JEE]]></category>
		<category><![CDATA[Spring Security]]></category>

		<guid isPermaLink="false">http://blog.newsplore.com/?p=1224</guid>
		<description><![CDATA[A short two months back I posted an article describing how to upgrade to Spring 3.0 M2. Spring folks are releasing at breakneck speed and so I got busy again upgrading spincloud.com to Spring 3.0 M3 released at the beginning of May. Just yesterday (June 3rd) the team released Spring Security 3.0 M1 and I [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="padding-right:0;margin-top:3px"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.newsplore.com%2F2009%2F06%2F04%2Fupgrading-to-spring-300m3-and-spring-security-300m1"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.newsplore.com%2F2009%2F06%2F04%2Fupgrading-to-spring-300m3-and-spring-security-300m1" height="61" width="51" /></a></div><p>A short two months back I <a href='http://blog.newsplore.com/?p=773'>posted</a> an article describing how to upgrade to Spring 3.0 M2. Spring folks are releasing at breakneck speed and so I got busy again upgrading <a href='http://spincloud.com'>spincloud.com</a> to <a href='http://blog.springsource.com/2009/05/06/spring-framework-30-m3-released/'>Spring 3.0 M3</a> released at the beginning of May. Just yesterday (June 3rd) the team <a href='http://blog.springsource.com/2009/05/06/spring-framework-30-m3-released/'>released</a> Spring Security 3.0 M1 and I decided to roll this in Spincloud as well.</p>
<p><b>Upgrading Spring Security from 2.0.4 to 3.0.0 M1</b><br />
For Spring Security 3.0.0 M1 I&#8217;m doing a &#8220;soft&#8221; upgrade since I had done my homework when I migrated from Acegi. I won&#8217;t use any of the new 3.0 features, just getting ready to use them. </p>
<p>To digress a bit, Spring Security a technology that is harder to swallow due to its breadth. To simplify the picture, Spring Security (former Acegi) provides three major security concerns to enterprise applications:<br />
- Authorization of method execution (either through standard JSR-250 JEE security annotations or via specific <a href='http://static.springsource.org/spring-security/site/docs/3.0.x/reference/ns-config.html#ns-method-security'>annotation-based method security</a>).<br />
- HTTP Request authorization (mapping URLs to accessible roles using Ant style or regexp&#8217;ed paths,  dubbed <a href='http://static.springsource.org/spring-security/site/docs/3.0.x/reference/channel-security.html#channel-security-config'>channel security</a>).<br />
- Website authentication (integrating Single Sign On (SSO) services by supporting major SSO providers, HTTP BASIC authentication, OpenId authentication and other types).<br />
For Spincloud I&#8217;m using OpenId for authentication and Channel Security to secure website pages.<br />
<span id="more-1224"></span><br />
To perform the upgrade you have to first grab the new jars. Here&#8217;s the Maven config:</p>
<pre>
	&lt;repository&gt;
		&lt;id&gt;Springframework milestone&lt;/id&gt;
		&lt;url&gt;http://maven.springframework.org/milestone&lt;/url&gt;
	&lt;/repository&gt;
	&lt;properties&gt;
		&lt;spring.version&gt;3.0.0.M3&lt;/spring.version&gt;
		&lt;spring-security.version&gt;3.0.0.M1&lt;/spring-security.version&gt;
	&lt;/properties&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
			&lt;artifactId&gt;spring-security-core&lt;/artifactId&gt;
			&lt;version&gt;${spring-security.version}&lt;/version&gt;
			&lt;scope&gt;compile&lt;/scope&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
			&lt;artifactId&gt;spring-security-config&lt;/artifactId&gt;
			&lt;version&gt;${spring-security.version}&lt;/version&gt;
			&lt;scope&gt;compile&lt;/scope&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
			&lt;artifactId&gt;spring-security-openid&lt;/artifactId&gt;
			&lt;version&gt;${spring-security.version}&lt;/version&gt;
			&lt;scope&gt;compile&lt;/scope&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
			&lt;artifactId&gt;spring-security-taglibs&lt;/artifactId&gt;
			&lt;version&gt;${spring-security.version}&lt;/version&gt;
			&lt;scope&gt;compile&lt;/scope&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
			&lt;artifactId&gt;spring-security-web&lt;/artifactId&gt;
			&lt;version&gt;${spring-security.version}&lt;/version&gt;
			&lt;scope&gt;compile&lt;/scope&gt;
		&lt;/dependency&gt;
</pre>
<p>Make sure your build process refers only to these jars.<br />
in 3.0.0 M1, the package structure was changed. Here&#8217;s what I had to do to upgrade the packages:<br />
Before</p>
<pre>
import org.springframework.security.Authentication;
import org.springframework.security.context.SecurityContext;
import org.springframework.security.context.SecurityContextHolder;
import org.springframework.security.context.SecurityContextImpl;
import org.springframework.security.providers.openid.OpenIDAuthenticationStatus;
import org.springframework.security.providers.openid.OpenIDAuthenticationToken;
import org.springframework.security.userdetails.UserDetails;
import org.springframework.security.userdetails.UserDetailsService;
</pre>
<p>After:</p>
<pre>
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.context.SecurityContextImpl;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.openid.OpenIDAuthenticationStatus;
import org.springframework.security.openid.OpenIDAuthenticationToken;
</pre>
<p>The security namespace has <a href='http://static.springsource.org/spring-security/site/docs/3.0.x/reference/ns-config.html'>changed</a> too so I updated my security XML file namespace and I had only to change the packages for standard Spring Security beans defined  to match the new package structure.</p>
<p><b>Upgrading Spring from 3.0.0 M2 to M3</b><br />
This should be easy. First, grab the new jars through Maven by using the same Maven config I described at the beginning of <a href='http://blog.newsplore.com/?p=773'>this post</a> and change the spring.version to 3.0.0.M3. I&#8217;m planning to move more XML configuration to annotations and M3 enables more of that (@Lazy for instance). I&#8217;m still waiting for the scheduling namespace due to appear in this milestone but pushed to RC1 apparently. I&#8217;m craving for some annotation-based timer configuration too&#8230;</p>
<p><b>Build and deployment</b><br />
At first, the build failed on me with the follwing error:</p>
<pre>
java.lang.NoClassDefFoundError: org/springframework/asm/ClassVisitor
	at org.springframework.context.support.AbstractRefreshableApplicationContext.customizeBeanFactory(AbstractRefreshableApplicationContext.java:205)
	at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:125)
	at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:419)
</pre>
<p>This is because M3 (finally) repackages asm. So I deleted the asm libraries I used to fix the M2 issues and added the repackaged Spring asm library:</p>
<pre>
		&lt;dependency&gt;
			&lt;groupId&gt;org.springframework&lt;/groupId&gt;
			&lt;artifactId&gt;org.springframework.asm&lt;/artifactId&gt;
			&lt;version&gt;${spring.version}&lt;/version&gt;
		&lt;/dependency&gt;
</pre>
<p>If you&#8217;re getting this error on container start-up:</p>
<pre>
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/security]
Offending resource: ServletContext resource [/WEB-INF/classes/applicationContext-security.xml]
</pre>
<p>means you have forgotten to add security-config jar (see the Maven config in the Security section). </p>
<p>That&#8217;s all. Done in 3 hours with no problems at all.</p>
<p class="fbconnect_share"><fb:share-button class="url" href="http://blog.newsplore.com/2009/06/04/upgrading-to-spring-300m3-and-spring-security-300m1" /></p>]]></content:encoded>
			<wfw:commentRss>http://blog.newsplore.com/2009/06/04/upgrading-to-spring-300m3-and-spring-security-300m1/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>
