Monday, December 31, 2012

HTTP basic authentication in Grails with Spring Security

Setting up HTTP basic authentication in Grails using Spring Security is pretty straightforward. Here's a quick how-to:
  1. grails create-app basicauthdemo
  2. cd basicauthdemo
  3. grails install-plugin spring-security-core
  4. grails s2-quickstart basicauthdemo User Role
  5. Edit grails-app/conf/Config.groovy and add two lines telling the Spring Security plugin to use HTTP basic authentication:
    grails.plugins.springsecurity.useBasicAuth = true
    grails.plugins.springsecurity.basic.realmName = "HTTP Basic Auth Demo"
  6. Edit grails-app/conf/BootStrap.groovy to setup a user and role:
    import basicauthdemo.*
    class BootStrap {
        def init = { servletContext ->
            def userRole = Role.findByAuthority("ROLE_USER") ?: new Role(authority: "ROLE_USER").save(flush: true)
            def user = User.findByUsername("tst") ?: new User(username: "tst", password: "foo", enabled: true).save(flush: true)
            UserRole.create(user, userRole, true)
        def destroy = {
  7. grails create-controller hello
  8. Edit grails-app/controllers/basicauthdemo/HelloController.groovy and add a security annotation:
    package basicauthdemo
    import grails.plugins.springsecurity.Secured
    class HelloController {
        def index() {
            render "Hello World!"
  9. grails run-app
  10. Open http://localhost:8080/basicauthdemo/hello

Monday, December 17, 2012

Watching digital HD TV without a Telenet decoder

And now for something completely different. If you live in Flanders and use Telenet as cable TV provider, it might be interesting to know that you can watch quite a few digital HD channels without using a Telenet decoder (either an HD Digibox or HD Digicorder; Telenet also has a FAQ article documenting this). All you need is:
  • A Telenet cable TV subscription
  • A television set with DVB-C tuner
Since every somewhat recent HD TV has a built-in DVB-C tuner, these requirements aren't very demanding. Just have your TV do a full scan of the digital spectrum. That takes quite a while and will find more than 200 channels. Of all those channels, you can currently watch the following unencrypted in their full digital HD 720p magnificence:
  • één HD
  • Canvas HD
  • Ketnet/OP12
  • France 3
  • Arte Belgique
  • TV5 Monde
  • Actua TV
  • CNBC Europe
  • BBC World
  • CNN
Next to these TV channels, you'll also be able to listen to a number of digital radio stations (STU BRU, ...). Of course there is one caveat: you won't be able to use interactive features such as Net Gemist.