What is the standard way to retrieve generic passwords in the Keychain of OS X using only Java? Apple Developer Pages provide some good background but the implementation and examples are in C or native code unfortunately.
The Java KeyStore OS X implementation appears to be good only for public/private key pairs and certs but not generic username/password combos.
I see a project started Here: but it is relatively old and not actively maintained.
Is there a more state of the art solution to the problem of securing credentials in Mac OS X in Java?
EDIT: OAuth is not an option for the class of problem and environment that I am operating in ...
There is also JNA + Maven project here which doesn't require compiling any native code in the build. Apparently supports OSX and Windows.
https://bitbucket.org/east301/java-keyring/
It has less features than osx-keychain-java, but supports Add and Get Generic Password.
<dependency>
<groupId>net.east301</groupId>
<artifactId>java-keyring</artifactId>
<version>1.0.0</version>
</dependency>
Example code
import net.east301.keyring.Keyring;
import net.east301.keyring.PasswordRetrievalException;
Keyring keyring = Keyring.create();
String pw = keyring.getPassword(service, account);
This seems to be a fairly common problem; the only solution I've found that looks like it might meet your requirements is this Github project, but it seems to be extremely old/unmaintained, and I can't speak to the quality or security of the code.
Unfortunately, there does not seem to be native support for accessing passwords stored in the keychain, and this does not seem to be a common enough problem for there to be an actively-developed library to solve it.
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