Archive for April, 2009|Monthly archive page

What is missing in Twitter Search ? Twitter Find !!

It all started with me trying to find what kind of a dog one of my friends had.
He had posted the breed on a Tweet and I tried to search for it.

And then I realized how difficult it can be to use Twitter Search to find something that is not necessarily happening in real-time. Unfortunately (from my perspective) Twitter Search focuses on giving matches (i.e. Tweets that contain the search string) that have been posted recently (i.e. real-time) a higher ranking. Which is fine for real-time search (however one defines real-time search) but misses out on one important aspect of social networking – the NETWORK. I do realize that Twitter is more than just a social networking tool, but one of the most important reasons I use Twitter is to stay connected with my friends and find out what they (i.e. my network) are doing. And I am sure there are people (not just a few) who want to go back and lookup some interesting tidbit of information that somebody in their network had posted, and if that Tweet was posted a few weeks back, then it is like looking up the 455th link on the 17th page of a Google Search.

The image below shows the search results for “Camtasia” and as one can see, all the results are sorted by time – so if I was looking for a Tweet from somebody in my network who had posted a URL a few weeks back on how to convert a .camrec file into a .mp3 file, I would be totally lost trying to search through these results.

Twitter Search Results

Twitter Search Results

And so I started playing around with Twitter Search and its advanced options, and a host of other Twitter search tools like TweetScan and Flaptor but none of them take into account the notion of the NETWORK (and somehow the whole idea of using another tool to search Twitter is just so un-user-friendly). Twitter Search has an advanced feature to specify the “user” whose update you are interested in but once you are following more than 30-50 users and you are posting and receiving daily updates, one tends to forget who posted what. So basically what Twitter needs is a separate mini-search (I call it Twitter Find) that just looks in the Tweets of persons that you are following (and your own Tweets) to handle a host of use-cases like

– A dish that somebody had recommended at a restaurant (e.g. the Al Pastor at Tacos y Tequila and you remember just “Tacos” and “Tequila” as the search terms).
– A URL that talks about solving a specific problem (e.g. one-to-one Hibernate mapping and you remember just “one-to-one” and/or “Hibernate” as the search terms).
– The name of a dentist that was recommended by somebody to somebody else and you just remember “dentist” as the search term.
– And so on and so forth.

But as of now, to use Twitter search to find something in your network is like using Google to find something on your computer’s hard drive. Sorry, bad example, Google Desktop actually does a pretty good job of doing that !!

Java Authentication Explained (using JAAS)

Getting back to blogging after a long long time !!

There is enough literature about Java Authentication and Authorization Service (JAAS)  and most application servers have rich support for different types of authentication. But what really happens under the covers ? And there is no better way to find out than writing a custom login module to authenticate an user using JAAS.

All the sample code discussed in this blog can be viewed at the Google Code project –DalalStreet.

The first step is to define a jaas.conf and this is how the file looks :

DalalStreet {
org.ds.auth.DSLoginModule required;
};

where org.ds.auth.DSLoginModule is the custom login module that contains the code to handle the customized authentication. The login module implements the following methods :
– initialize (gets the callback handler – to get usernames/passwords, etc.)
– login (self-explanatory and the most important method)
– commit (called when login succeeds)
– abort (called when login or commit fails)
– logout

The rest is explained in the short video – less than 10 minutes – below (the video shows a debugging session, so if you want to clearly see the lines of the code, breakpoints, variable values, etc. then it is best viewed in HD mode).

What we have discussed above is a very simple example, and I am sure you could have written code to capture/request the username/password from the user and written code to validate it against a well known set of usernames and password (e.g in a database). So what is it that makes JAAS so special ?

– The most important advantage of using JAAS is that you can switch the login modules (i.e. swap the implementation class) without any code changes. That means if your LoginModule implementation currently authenticates a user via TACACS and tomorrow it has to use LDAP, you just have to write a class that handles the LDAP authentication and modify the jaas.conf to contain the new implementation class and you really don’t have to change a single line of code in your application (it is really that simple).
– even the callback handler can be configured (e.g. by a simple property or Spring) and you can decide to change how you request your user’s credentials.

So hopefully you found this post (and the video) useful/helpful. Here are the links to the files in case you want to take a detailed look at the code.
org.ds.auth package (where most of the files are located)

resources folder (where jaas.conf is located)

org.ds.util

Design a site like this with WordPress.com
Get started