views:

838

answers:

3

I'm writing a small program (a twitter client) in Java, aimed at Mac OS X. As part of its functionality, it needs to have a place to store the twitter username/password. The natural place would be the mac keychain, but I can't find any way of accessing it.

Is there any way of accessing the mac keychain from Java, or failing that, what is your recommendation for where to store the username/password instead?

+3  A: 
erickson
+6  A: 

There is Java keychain API, in that there's an implementation of KeyStore on OS X backed by the keychain.

I think the keychain is the best place (if not the place) to store the password. It's encrypted with a good algorithm, the user is free to be as permissive or as paranoid over the availability of the keychain to apps as they like, and the password would then be stored with and configured like all of the other passwords the user stores.

Graham Lee
I like this better than Kevin's answer because sometimes you won't be writing a twitter client and you want the paranoid apple password warnings. Cancel or Allow. Cancel or Allow. (vista almost had it right)
shemnon
I like this one too, for the same reasons.
Kevin Williams
+3  A: 

You should take a look at twitters API page on OAuth support. By using OAuth, you don't need to know the user's twitter password.

http://apiwiki.twitter.com/OAuth-FAQ

Kevin Williams
That's brilliant! I will have to look into it more, but it sounds like a much better solution than storing the passwords.
Zarkonnen
Glad to help. I hope it works for you.
Kevin Williams
If it does, you'll get the best answer tick, obviously.
Zarkonnen
Kevin Williams