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 ...
I am now using https://github.com/davidafsilva/jkeychain which is a fork of conormcd/osx-keychain-java
Gradle
Example
Example project usage: https://github.com/yschimke/okurl/blob/b3208514b4338a2f57bfedccb2da4e6f54d0d99a/src/main/kotlin/com/baulsupp/okurl/credentials/OSXCredentialsStore.kt
I've done this myself by using the command line, e.g. running /usr/bin/security. However it doesn't have strong access controls. So you can run the /usr/bin/security from a terminal to access the same passwords, but a C++ app calling into the library directly would be blocked.
Because of this I'm using it only for oauth tokens for Social Media accounts. Things that you could do similarly by launching a web browser when logged in as the user.
https://github.com/yschimke/oksocial/blob/master/src/main/java/com/baulsupp/oksocial/credentials/OSXCredentialsStore.java
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.
Example code
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.
Further to the answer above by f-stephen-q, this library appears to work well still. I'm using a fork of it which is mavenised
Adding a dependency
Running it