How do you store a username/password in the Mac Keychain using Java?

Viewed 3105

I'd like to use the Mac KeyChain to store some username/password combinations for my Java Swing application to use to connect to external services on behalf of the user.

I have found a few sources demonstrating that you can get access to a java.security.KeyStore object by doing:

KeyStore keyStore = KeyStore.getInstance("KeychainStore", "Apple");
keyStore.load(null, null);

However, I can't find any examples of how you use the resulting KeyStore to actually store/retrieve usernames and passwords.

Any help would be greatly appreciated.

Thanks!

3 Answers
Related