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!
In the Keychain Access app on your Mac, if you don't see a list of keychains, choose Window > Keychain Viewer or press Command-1. Select the keychain that you want to view. To see more information about an item, either double-click it or select it and click the Info button in the toolbar.
When you are using Outlook or Mac mail client software on an Apple Macs, your passwords are stored in your local Mac keychain under Applications folder. Passwords are stored in the local Mac computer in Keychain 1. Go to Application, then Utilities, then Keychain.
You cannot get there "Apple Keychain passwords" from here "Java KeyStore"
The keystore abstraction only wraps the certs in the keychain.
See the difference between the native view of the keychain (bash cmd):
security dump ~/Library/Keychains/login.keychain
vs Java's view of the keychain (bash cmd):
keytool -list -storetype KeychainStore -keystore ~/Library/Keychains/login.keychain
Notice that only certificates are included and the listing is shorter.
You will need to use a different wrapper for Keychain that can access all of it's features.
Suggestions:
Also read the native docs: Keychain Services Concepts -- OS X Keychain Services Tasks (see figure 1-3)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With