<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>Glen Smith (Grails Related category)</title>
  <link rel="alternate" href="http://blogs.bytecode.com.au:80/categories/Grails" />
  <subtitle>Glen Smith (Grails Related category)</subtitle>
  <entry>
    <title>Hacking Custom Authentication Providers with Grails Spring Security</title>
    <link rel="alternate" href="http://blogs.bytecode.com.au:80/glen/2010/01/15/hacking-custom-authentication-providers-with-grails-spring-security.html" />
    <author>
      <name />
    </author>
    <updated>2010-01-14T19:33:00Z</updated>
    <published>2010-01-14T19:33:00Z</published>
    <summary type="html">&lt;p&gt;&#xD;
The Grails &lt;a href="http://www.grails.org/plugin/acegi"&gt;Spring Security plugin&lt;/a&gt; totally rocks. Even though &lt;a href="http://www.cacoethes.co.uk/blog/"&gt;Peter&lt;/a&gt; wrote a fantastic chapter on it for &lt;a href="http://www.manning.com/affiliate/idevaffiliate.php?id=1056_137"&gt;Grails in Action&lt;/a&gt;, I've always been a bit scared of it (based on some early bad experiences with the raw acegi codebase which *was* pretty insanely complex to get going).&#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
Anyways, I've had cause to revisit Spring Security for a new client project, and had some tricky corner cases to solve. In particular, the app exposes a REST API that needs a special custom security provider. The client is issued an API key when they purchase the COTS product, and (basically) a hash of this key is remoted by a rich client during the authentication process so they can access backend services. However they can also access parts of the app using a normal browser interface with a user password and standard "remember me" features. &#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
So the trick was supporting both a custom auth mechanism for certain URLs (eg /api/**) whilst maintaining usernames and passwords for the rest of the app. Turns out that it's all totally doable. First a disclaimer: I know next to nothing about Spring Security, so there is probably way better ways to accomplish this, so feel free to give feedback about how I could simplify all this so that future googlers can benefit. That aside, here's my crack.&#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
Ok. To get all this custom stuff happening you'll need to implement a few things:&#xD;
&lt;/p&gt;&#xD;
&lt;ul&gt;&#xD;
&lt;li&gt;A custom &lt;a href="http://static.springsource.org/spring-security/site/apidocs/org/springframework/security/Authentication.html"&gt;Authentication&lt;/a&gt; object to hold the credentials you scrape from the client's http POST&#xD;
&lt;li&gt;A custom &lt;a href="http://static.springsource.org/spring-security/site/apidocs/org/springframework/security/providers/AuthenticationProvider.html"&gt;AuthenticationProvider&lt;/a&gt; which checks the credentials in that Authentication object match with the ones you've got stored against your backend database.&#xD;
&lt;li&gt;A custom &lt;a href="http://static.springsource.org/spring-security/site/apidocs/org/springframework/security/ui/SpringSecurityFilter.html"&gt;SpringSecurityFilter&lt;/a&gt; which slips into the request pipeline all /api/** URLs and fires when it finds some credentials to use. It will need to extract out the credentials into an Authentication object, then pass it off to the &lt;a href="http://static.springsource.org/spring-security/site/apidocs/org/springframework/security/AuthenticationManager.html"&gt;AuthenticationManager&lt;/a&gt; which will inturn fire you custom provider.&#xD;
&lt;li&gt;Plenty of brain space to hold all that complexity...&#xD;
&lt;/ul&gt;&#xD;
&lt;p&gt;&#xD;
Let's start with the easy stuff and define our custom &lt;code&gt;Authentication&lt;/code&gt; object to hold our credentials. You really only need a custom one so that your &lt;code&gt;AuthenticationProvider&lt;/code&gt; class can answer true to &lt;code&gt;supportsClass(auth)&lt;/code&gt;, and there's probably good adaptors I could have subclassed. Given I'm doing it all in Groovy, it's very concise to implement the entire interface anyways:&#xD;
&lt;/p&gt;&#xD;
&lt;pre class="prettyprint"&gt;&#xD;
import org.springframework.security.*&#xD;
&#xD;
class CustomAppTokenAuthentication implements Authentication {&#xD;
	&#xD;
	String name&#xD;
	GrantedAuthority[] authorities&#xD;
 	Object credentials&#xD;
 	Object details&#xD;
 	Object principal&#xD;
 	boolean authenticated&#xD;
&#xD;
}      &#xD;
&lt;/pre&gt;&#xD;
&lt;p&gt;&#xD;
Ok. We have our "holder" for the credentials that the user is going to present. I'm going to populate the credentials and principal details from the incoming http request. It's the role of the &lt;code&gt;SpringSecurityFilter&lt;/code&gt; to do that scraping, then fire off the &lt;code&gt;AuthenticationManager&lt;/code&gt;'s pipeline of &lt;code&gt;AuthenticationProviders&lt;/code&gt;. Here's  rough crack at a custom Filter:&#xD;
&lt;/p&gt;&#xD;
&lt;pre class="prettyPrint"&gt;&#xD;
import org.springframework.security.ui.*&#xD;
import org.springframework.security.context.*&#xD;
import org.springframework.beans.factory.*&#xD;
import org.springframework.context.*&#xD;
import javax.servlet.*&#xD;
import javax.servlet.http.*&#xD;
&#xD;
class CustomAppTokenFilter extends SpringSecurityFilter implements InitializingBean{&#xD;
	&#xD;
	def authenticationManager&#xD;
	def customProvider&#xD;
	&#xD;
	void doFilterHttp(HttpServletRequest request, HttpServletResponse response, FilterChain chain) {&#xD;
		&#xD;
		if (SecurityContextHolder.getContext().getAuthentication() == null) {&#xD;
&#xD;
			def userId = request.getParameter("userId")&#xD;
			def apiKey = request.getParameter("apiKey")&#xD;
			if ( userId &amp;&amp; apiKey ) {&#xD;
				&#xD;
				def myAuth = new CustomAppTokenAuthentication(&#xD;
						name: userId,&#xD;
						credentials: apiKey,&#xD;
						principal: userId,&#xD;
						authenticated: true&#xD;
				)&#xD;
				&#xD;
				myAuth = authenticationManager.authenticate(myAuth);&#xD;
				if (myAuth) {&#xD;
					println "Successfully Authenticated ${userId} in object ${myAuth}"&#xD;
	&#xD;
					// Store to SecurityContextHolder&#xD;
					SecurityContextHolder.getContext().setAuthentication(myAuth);&#xD;
				 }    &#xD;
			}&#xD;
		}&#xD;
		chain.doFilter(request, response)&#xD;
	}&#xD;
	&#xD;
	int getOrder() {&#xD;
		return FilterChainOrder.REMEMBER_ME_FILTER&#xD;
	}&#xD;
	&#xD;
	void afterPropertiesSet() {&#xD;
		def providers = authenticationManager.providers&#xD;
		providers.add(customProvider)&#xD;
		authenticationManager.providers = providers&#xD;
	}&#xD;
}           &#xD;
&lt;/pre&gt;&#xD;
&lt;p&gt;&#xD;
There's a little magic going on here in &lt;code&gt;afterPropertiesSet()&lt;/code&gt; where I add my custom &lt;code&gt;AuthenticationProvider&lt;/code&gt; (which is going to actually validate the token) to the existing pipeline of AuthenticationManager providers. I was hoping to do that via configuration, but couldn't find out how. Ideas?&#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
With all that in place, the actual logic of firing the request is pretty straightforward. If there is a userId and apiKey coming in, and the user hasn't already been authenticated, you create your custom Authentication holder object for the credentials (contrary to what you might think, the &lt;code&gt;authenticated: true&lt;/code&gt; attribute means "I should be inspected by an AutheticationProvider classes" NOT "the user has been authenticated with this credential"). Traps for young players.&#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
The last piece of code we'll need is that &lt;code&gt;AuthenticationProvider&lt;/code&gt; to actually validate the credential. That will need to look up the user's details in the security database. You can use the plugin's &lt;code&gt;userDetailsService&lt;/code&gt; to do the heavy lifting of that one. Let's you look up the user in the database based on their user id, then gives you a handle to the underlying domain class to get any attributes you need. Here's my rough impl:&#xD;
&lt;/p&gt;&#xD;
&lt;pre class="prettyPrint"&gt;&#xD;
import org.springframework.security.*&#xD;
import org.springframework.security.providers.*&#xD;
import org.springframework.security.userdetails.*&#xD;
&#xD;
class CustomAppTokenAuthenticationProvider implements AuthenticationProvider {&#xD;
	&#xD;
	def userDetailsService&#xD;
	&#xD;
	Authentication authenticate(Authentication customAuth) {&#xD;
		def userDetails = userDetailsService.loadUserByUsername(customAuth.principal)&#xD;
		if (userDetails?.domainClass?.apiKey == customAuth.credentials) {&#xD;
			customAuth.authorities = userDetails.authorities&#xD;
			return customAuth&#xD;
		} else {&#xD;
			return null&#xD;
		}&#xD;
	}&#xD;
	&#xD;
	boolean supports(Class authentication) {&#xD;
		return CustomAppTokenAuthentication.class.isAssignableFrom(authentication)&#xD;
	}&#xD;
	&#xD;
}&#xD;
&lt;/pre&gt;&#xD;
&lt;p&gt;&#xD;
At this stage I'm just comparing that the cleartext API key's match. In the next round I'll use a Grails codec to do the actual &lt;code&gt;.encodeAsCrazyHash&lt;/code&gt; algo that I'll need for the real crypto.  &#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
With all the code in place, we just need the config to wire it all together. Let's start with the spring bean definitions for /grails-app/conf/spring/resources.groovy:&#xD;
&lt;/p&gt;&#xD;
&lt;pre class="prettyprint"&gt;&#xD;
import org.codehaus.groovy.grails.plugins.springsecurity.*&#xD;
import au.com.bytecode.auth.*&#xD;
&#xD;
beans = {&#xD;
&#xD;
	if (AuthorizeTools.securityConfig.security.active) {&#xD;
		&#xD;
		customAppTokenFilter(CustomAppTokenFilter) {&#xD;
			userDetailsService = ref("userDetailsService")&#xD;
			authenticationManager = ref("authenticationManager")&#xD;
			customProvider = ref("customAppTokenAppTokenAuthenticationProvider")&#xD;
		}&#xD;
	   &#xD;
		customAppTokenAppTokenAuthenticationProvider(CustomAppTokenAuthenticationProvider) {&#xD;
	   		userDetailsService = ref("userDetailsService")	&#xD;
		}&#xD;
		&#xD;
	}&#xD;
   &#xD;
}          &#xD;
&#xD;
&lt;/pre&gt;&#xD;
&lt;p&gt;&#xD;
I use the plugin's &lt;code&gt;AuthorizeTools&lt;/code&gt; class just to check that the plugin is turned on in SecurityConfig.groovy. It's useful to be able to turn off security for some testing via that &lt;code&gt;active = false&lt;/code&gt; flag, so I wanted to honour that setting.&#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
The last piece of config is making sure the filter fires only for the /api/** URL Mapping. The &lt;code&gt;SecurityConfig.groovy&lt;/code&gt; setup allow you to specify a map of URL to pipeline. I'm not sure which filters I need in addition to my custom one, so I just specify them all :-) -- you need some of them to persist your custom credential to the http session, for instance. And some to handle the anonymous user who don't submit a token (so that your standard @Secured annotations work on the target controller). Here's the extract:&#xD;
&lt;/p&gt;&#xD;
&lt;pre class="prettyprint"&gt;&#xD;
   filterInvocationDefinitionSourceMap = [&#xD;
    '/api/**': 'httpSessionContextIntegrationFilter,logoutFilter,authenticationProcessingFilter,securityContextHolderAwareRequestFilter,rememberMeProcessingFilter,customAppTokenFilter,anonymousProcessingFilter,exceptionTranslationFilter,filterInvocationInterceptor',&#xD;
    '/**': 'JOINED_FILTERS',&#xD;
	]    &#xD;
&lt;/pre&gt;&#xD;
&lt;p&gt;&#xD;
The &lt;code&gt;JOINED_FILTERS&lt;/code&gt; tag means "all the standard filters", but you can't seem to map "/api/**" to  "customAppTokenFilter,JOINED_FILTERS"  which could have been nice. &#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
Phew! That was quite a journey! As I said, if you have better ways of simplifying this process, I'm all ears. At least here's a rough outline of how to hack together a custom authentication mechanism if your client needs one!&#xD;
&lt;/p&gt;</summary>
    <dc:date>2010-01-14T19:33:00Z</dc:date>
  </entry>
  <entry>
    <title>Log into your Grails app using your Twitter credentials</title>
    <link rel="alternate" href="http://blogs.bytecode.com.au:80/glen/2009/12/08/log-into-your-grails-app-using-your-twitter-credentials.html" />
    <author>
      <name />
    </author>
    <updated>2009-12-08T02:16:00Z</updated>
    <published>2009-12-08T02:16:00Z</published>
    <summary type="html">&lt;p&gt;&#xD;
I've got a new little hobby grails project that relies on a user's tweets to power its data collection, so I've been exploring using Twitter's oauth features to do away user accounts altogether. My little project is called "Twitter Until You're Fitter" and the idea is that I can tweet my weight "@tuyf 93kg" each week, and the app will pick up the value and graph it over time toward my goal weight (85kg). Given my current gym workload, that shouldn't be too far away :-)&#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
For those of you who haven't played with oauth, it's one of those emerging "federated SSO" type protocols. You generate a signed request from your application and sent it off to twitter. Twitter asks the logged on user whether they wish to allow your application access their account. If they agree, twitter will send your application an oauth_verifier which you can use to logon as that user. Generating and processing all those tokens is easily handled by &lt;a href="http://yusuke.homeip.net/twitter4j/en/"&gt;twitter4j&lt;/a&gt;&#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
In order to get started, you first have to &lt;a href="http://twitter.com/apps"&gt;register&lt;/a&gt; your application with twitter, after which you'll be issued with a "consumer key" and a "consumer secret". You'll want to squirrel those away in your /grails-app/conf/Config.groovy to get access to them later:&#xD;
&lt;/p&gt;&#xD;
&lt;pre style="prettyprint"&gt;&#xD;
twitter {&#xD;
	oauth.consumer_key = 'd8sfsv9s0afs89v0sdesvs0'&#xD;
	oauth.consumer_secret = 'lfsdDKSFjepfskvespfseruDFESilsfesfiseLFS=='&#xD;
}&#xD;
&lt;/pre&gt;&#xD;
&lt;p&gt;&#xD;
Next up we'll taked advantage of Grails 1.2's new dependency management gear, by adding twitter4j to our /grails-app/conf/BuildConfig.groovy&#xD;
&lt;/p&gt;&#xD;
&lt;pre class="prettyprint"&gt;&#xD;
dependencies {&#xD;
	build 'net.homeip.yusuke:twitter4j:2.0.10'&#xD;
}&#xD;
&lt;/pre&gt;&#xD;
&lt;p&gt;&#xD;
With our dependency in place, and our keys all set aside in config, it's time to generate a request to send the user off to twitter. I've setup a little TwitterService class to abstract some of the details:&#xD;
&lt;/p&gt;&#xD;
&lt;pre class="prettyprint"&gt;&#xD;
class TwitterService {&#xD;
&#xD;
    def generateRequestToken(twitter, callbackUrl) {	&#xD;
		def consumerKey = ConfigurationHolder.config.twitter.oauth.consumer_key&#xD;
		def consumerSecret = ConfigurationHolder.config.twitter.oauth.consumer_secret&#xD;
		twitter.setOAuthConsumer(consumerKey, consumerSecret)&#xD;
		def requestToken = twitter.getOAuthRequestToken(callbackUrl)&#xD;
		return requestToken &#xD;
    }&#xD;
&#xD;
}&#xD;
&lt;/pre&gt;&#xD;
&lt;p&gt;&#xD;
I'm passing in the twitter4j object itself, since I'm planning on binding that object to the user's session, and using it to access their timeline. Now we just need a controller to generate the "redirect to login" feature of my application. Something like this should do it:&#xD;
&lt;/p&gt;&#xD;
&lt;pre class="prettyprint"&gt;&#xD;
def requestLogin = {&#xD;
	def twitterClient = new twitter4j.Twitter()	&#xD;
	def returnUrl = g.createLink(controller: 'oauth', action: 'processLogin', absolute:true).toString()&#xD;
	log.debug "Generating request with return url of [${returnUrl}]"&#xD;
	def requestToken = twitterService.generateRequestToken(twitterClient, returnUrl)&#xD;
	session.twitter = twitterClient&#xD;
	session.requestToken = requestToken&#xD;
	redirect(url:requestToken.getAuthorizationURL())&#xD;
}&#xD;
&lt;/pre&gt;&#xD;
&lt;p&gt;&#xD;
First we generate a link for our return url after authentication, then I call the TwitterService to generate my request token. The RequestToken class exposes a &lt;code&gt;getAuthorizationURL()&lt;/code&gt; which returns the URL you need to send them off to. The user will be shown an authorisation screen like this:&#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
&lt;img src="images/2009/oauth-login.png" alt="Twitter OAuth login screen"/&gt;&#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
Assuming they click "Allow", twitter will redirect back to your requested URL with a URL containing a oauth_verifier parameter. You can use that parameter to login to twitter as that user. Here's the action that processes the return URL from twitter:&#xD;
&lt;/p&gt;&#xD;
&lt;pre class="prettyprint"&gt;&#xD;
def processLogin = {&#xD;
	&#xD;
	log.debug "Processing Login Return from Twitter"&#xD;
	if (!session.requestToken) {&#xD;
		redirect(action: 'requestLogin')&#xD;
	} else {&#xD;
		def accessToken = session.twitter.getOAuthAccessToken(session.requestToken, params.oauth_verifier)&#xD;
		log.debug "Attempting validate..."&#xD;
		def twitterUser = session.twitter.verifyCredentials()&#xD;
		log.debug "Validate successful for ${twitterUser.screenName}"&#xD;
		session.user = twitterUser&#xD;
		redirect(action: 'displayDetails')&#xD;
	}&#xD;
}&#xD;
&lt;/pre&gt;&#xD;
&lt;p&gt;&#xD;
That &lt;code&gt;accessToken&lt;/code&gt; object turns out to be really important. If you squirrel away it's &lt;code&gt;token&lt;/code&gt; and &lt;code&gt;tokenSecret&lt;/code&gt; properties, you can login as the user any time you want with the redirect step (eg. a future session, cookie value, etc).&#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
Phew! We've come a long way! We're now actually logged on as the user, now we just need a gsp to display some timeline details. Perhaps something like this: &#xD;
&lt;/p&gt;&#xD;
&lt;pre class="prettyprint"&gt;&#xD;
&amp;lt;html&amp;gt;&#xD;
	&amp;lt;head&amp;gt;&#xD;
		&amp;lt;meta http-equiv=&amp;quot;Content-type&amp;quot; content=&amp;quot;text/html; charset=utf-8&amp;quot;&amp;gt;&#xD;
		&amp;lt;title&amp;gt;Welcome ${session.user.name}&amp;lt;/title&amp;gt;	&#xD;
	&amp;lt;/head&amp;gt;&#xD;
	&amp;lt;body&amp;gt;&#xD;
		&amp;lt;h1&amp;gt;Successful Login for ${session.user.name}&amp;lt;/h1&amp;gt;&#xD;
		&amp;lt;p&amp;gt;Your user handle is &amp;lt;a href=&amp;quot;${session.user.getURL()}&amp;quot;&amp;gt;@${session.user.screenName}&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;&#xD;
		&amp;lt;p&amp;gt;Your icon is: &amp;lt;img src=&amp;quot;${session.user.profileImageURL}&amp;quot;&amp;gt;&amp;lt;/p&amp;gt;&#xD;
		&amp;lt;p&amp;gt;Your timeline:&amp;lt;/p&amp;gt;&#xD;
		&amp;lt;ul&amp;gt;&#xD;
			&amp;lt;g:each in=&amp;quot;${session.twitter.homeTimeline}&amp;quot; var=&amp;quot;status&amp;quot; status='i'&amp;gt;&#xD;
				&amp;lt;li class=&amp;quot;${ (i % 2) ? 'odd' : 'even'}&amp;quot;&amp;gt;&#xD;
					&amp;lt;img src=&amp;quot;${status.user.profileImageURL}&amp;quot;/&amp;gt; &#xD;
					${status.user.screenName} : ${status.text} &amp;lt;/li&amp;gt;&#xD;
			&amp;lt;/g:each&amp;gt;&#xD;
		&amp;lt;/ul&amp;gt;&#xD;
	&amp;lt;/body&amp;gt;&#xD;
&amp;lt;/html&amp;gt;&#xD;
&lt;/pre&gt;&#xD;
&lt;p&gt;&#xD;
Which should give us an output like this:&#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
&lt;img src="images/2009/oauth-details.png" alt="The user's details"/&gt;&#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
And our application is fully linked up! If the user has a look in their Twitter settings, they'll now see that our app has read-only access to their account. They can revoke that at any time (so we'll need some error checking to handle that down the track).&#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
&lt;img src="images/2009/oauth-connections.png" alt="The user's twitter connections tab"/&gt;&#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
Once I've got a bit more of the app running, I'll get some source onto a public repo. Till then, I need to get ready for my Spin class..&#xD;
&lt;/p&gt;</summary>
    <dc:date>2009-12-08T02:16:00Z</dc:date>
  </entry>
  <entry>
    <title>A Groovy day out as OSDC</title>
    <link rel="alternate" href="http://blogs.bytecode.com.au:80/glen/2009/12/01/a-groovy-day-out-as-osdc.html" />
    <author>
      <name />
    </author>
    <updated>2009-11-30T23:51:00Z</updated>
    <published>2009-11-30T23:51:00Z</published>
    <summary type="html">&lt;p&gt;&#xD;
I spent last Thursday with a bunch of the Queensland Groovy and Grails folk, hanging out at the &lt;a href=""&gt;Open Source Developers Conference&lt;/a&gt;. The day started with a super Groovy/Grails in the Enterprise talk from &lt;a href="http://wordpress.transentia.com.au/wordpress/"&gt;Bob Brown&lt;/a&gt;. After that was a great chance to meet &lt;a href="http://twitter.com/paulk_asert"&gt;Paul King&lt;/a&gt; from "Groovy in Action" fame:&#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
&lt;img src="images/2009/osdc_paul.jpg" alt="Paul King"/&gt;&#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
I sat down and interviewed Paul about Groovy, Agile, GPars and Chickens, which will appear as part of episode 101 of the Grails podcast. I went to Paul's talk on Groovy Testing which we gave with Craig Smith. There's already a copy on &lt;a href="http://www.slideshare.net/paulk_asert/groovy-testing-aug2009-1945995"&gt;slideshare&lt;/a&gt;, so check it out.&#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
I also had a great chance to hang out with &lt;a href="http://twitter.com/spidie"&gt;Steve Dalton&lt;/a&gt; and Lee Butts from &lt;a href="http://refactor.com.au/"&gt;Refactor&lt;/a&gt;. These guys work on the Grails &lt;a href="http://www.grails.org/plugin/amazon-s3"&gt;S3 plugin&lt;/a&gt; and the &lt;a href="http://www.grails.org/plugin/portlets"&gt;Portlets plugin&lt;/a&gt;. Lee is also a Grails committed. We had lots of good chats about putting together an .au Groovy/Grails conf next year. Stay tuned - it's gonna be a very Groovy time in the Sun.&#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
&lt;img src="images/2009/osdc_steve_lee.jpg" alt="Steve Dalton and Lee Butts"/&gt;&#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
Finally, I had a chance to sit down with &lt;a href="http://twitter.com/ldaley"&gt;Luke Daley&lt;/a&gt;. Luke is behind the &lt;a href="http://www.grails.org/plugin/fixtures"&gt;Grails Fixtures&lt;/a&gt; plugin, the &lt;a href="http://www.grails.org/plugin/ldap"&gt;LDAP plugin&lt;/a&gt; and the Grails Textmate plugin. Luke had some really good insights on developments in the Grails testing space, and it was also cool to meet another Grails Guitar player and Maven fan. &#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
&lt;img src="images/2009/osdc_luke.jpg" alt="Luke Daley"/&gt;&#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
Big thanks to Steve Dalton at &lt;a href="http://refactor.com.au/"&gt;Refactor&lt;/a&gt; for talking me into coming and sorting out getting me in the door. It was a fantastic time and I can't wait for a local GroovyConf next year! It's gonna rock!&#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
Interviews will be up on the &lt;a href="http://www.grailspodcast.com"&gt;Grails Podcast&lt;/a&gt; site later in the week. Stay tuned!&#xD;
&lt;/p&gt;</summary>
    <dc:date>2009-11-30T23:51:00Z</dc:date>
  </entry>
  <entry>
    <title>Converting GoogleCode projects over to Mercurial</title>
    <link rel="alternate" href="http://blogs.bytecode.com.au:80/glen/2009/11/16/converting-googlecode-projects-over-to-mercurial.html" />
    <author>
      <name />
    </author>
    <updated>2009-11-16T10:16:00Z</updated>
    <published>2009-11-16T10:16:00Z</published>
    <summary type="html">&lt;p&gt;&#xD;
Continuing my fascination with all things &lt;a href="http://mercurial.selenic.com/"&gt;mercurial&lt;/a&gt;, I've converted over a few of my googlecode projects (including &lt;a href="http://code.google.com/p/groovyblogs/"&gt;groovyblogs&lt;/a&gt; and &lt;a href="http://code.google.com/p/gravl/"&gt;gravl&lt;/a&gt;). Google code has supported mercurial for &lt;a href="http://googlecode.blogspot.com/2009/04/mercurial-support-for-project-hosting.html"&gt;a while&lt;/a&gt;, but it was initially piloted on just a few projects. These days the floodgates are open :-)&#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
Google provides you with a &lt;a href="http://code.google.com/p/support/wiki/ConvertingSvnToHg"&gt;Step-by-step&lt;/a&gt; guide on converting your project from Subversion to Mercurial. In the best case scenario, just do a "hg convert http://projectname.googlecode.com/svn hg-version-of-my-projectname" and you're in business. I tried this and the changesets took so long to pull from the remove svn repo, that I gave up after letting it run for a few hours. &#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
Fortunately, some kind soul linked to this &lt;a href="http://www.antwerkz.com/migrating-from-subversion-to-mercurial/"&gt;Antwerkz&lt;/a&gt; page which gives you a script for syncing your entire google svn repo to your local drive (just using standard svnsync, which isn't something I've played with before, so this trick might be old news to you). &#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
With my whole svn repo mirrored locally, I could run &lt;code&gt;hgconvert file://data/gravl.svn gravl.hg&lt;/code&gt; and a few seconds later I was done! Follow that up with a &lt;code&gt;hg push https://gravl.googlecode.com/hg/&lt;/code&gt; and we're up and running (with branches and &lt;a href="http://code.google.com/p/gravl/source/list"&gt;full history&lt;/a&gt;!):&#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
&lt;img src="images/2009/hg-gravl.png" alt="Gravl changeset history on google code"/&gt;&#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
Great stuff. Really interested to see how I copy with a wholesale move to Hg. So far things are going great!&#xD;
&lt;/p&gt;</summary>
    <dc:date>2009-11-16T10:16:00Z</dc:date>
  </entry>
  <entry>
    <title>Netbeans {hearts} Mercurial -- With Screenshots</title>
    <link rel="alternate" href="http://blogs.bytecode.com.au:80/glen/2009/11/10/netbeans--hearts--mercurial----with-screenshots.html" />
    <author>
      <name />
    </author>
    <updated>2009-11-10T01:51:00Z</updated>
    <published>2009-11-10T01:51:00Z</published>
    <summary type="html">&lt;p&gt;&#xD;
I've been learning &lt;a href="http://mercurial.selenic.com/"&gt;Mercurial&lt;/a&gt; over the past two weeks and I'm really loving it. I've used git before, and had a bunch of issues with merges (my fault, not git's - but troublesome none the less). I thought I'd have a good look at Mercurial to see what it offered.&#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
I've got to say the learning curve with Mercurial has been awesome. I bought a copy of &lt;a href="http://hgbook.red-bean.com/"&gt;the book&lt;/a&gt;, which has helped with the headshift of working with distributed revision control. A side benefit is that I now understand git better as well :-). &#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
One of my real interests in exploring Mercurial is the standard of tooling. I've been happy with &lt;a href="http://bitbucket.org/tortoisehg/stable/wiki/Home"&gt;TortoiseHg&lt;/a&gt; on Windows, and am comfortable with the commandline on OSX, but I was keen to see how the IDEs fare. These days I'm using Netbeans for Grails development, and the Mercurial support is just fantastic (and built in the basic install!).&#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
First up, let's have a look at the basic editor window. &#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
&lt;img src="images/2009/hg-netbeans-editor.png" alt="The Netbeans Mercurial Editor window"/&gt;&#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
Just like the normal Netbeans subversion support, the project explorer on the left marks modified files in blue, and new files in green. Any folder paths containing new/modified files have a small cylinder to let you know. All good visual cues. You can also see the Versions window active in the bottom right. This gives you a full list of your new/modified files for this project. You can right click to find out the deets. &#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
The editor window itself contains markers for lines you've modified, which avoids a lot of the need to fire up a diff. When you're ready to commit, you get a standard dialog:&#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
&lt;img src="images/2009/hg-netbeans-commit.png" alt="The Netbeans Mercurial Commit window"/&gt;&#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
With our commits all in place, all the colour scheme on our files revert to default black. But what if you need to do a more serious look at a file's history? No problem, just the normal right click, / Mercurial / Show History, and you'll have all the info you need. This dialog gives you the local repo revision number against each change, so it's easy to get back to where you were later:&#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
&lt;img src="images/2009/hg-netbeans-history.png" alt="The Netbeans Mercurial History window"/&gt;&#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
So what's missing in the Netbeans Hg support? There's a few things I haven't found yet. There doesn't seem to be any visual history for the project, (as per "hg glog" or "hg serve") - and there doesn't even seem to be any support for branching and cloning. But for day-to-day stuff, I'm happy to revert to the commandline for those for now. &#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
So overall I've been super happy with Mercurial so far. I just yesterday saw &lt;a href="http://naleid.com/blog/2009/11/08/mercurial-dvcs-devjam-presentation/"&gt;Ted Nalied&lt;/a&gt;'s great presentation on Mercurial - which is also a good resource for seeing what Hg has to offer.&#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
Also look forward to checking out &lt;a href="http://www.vectrace.com/mercurialeclipse/"&gt;Mercurial Eclipse&lt;/a&gt; once I finally get Eclipse Spring/STS installed. &#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&#xD;
If people are interested, I'll put together a basic Mercurial/Grails screencast to get you started (ala Jeff Brown's awesome Grails/Git one). &#xD;
&lt;/p&gt;</summary>
    <dc:date>2009-11-10T01:51:00Z</dc:date>
  </entry>
</feed>

