问题描述
仅使用Java在OS X的钥匙串中检索通用密码的标准方法是什么? Apple开发人员页面提供了一些良好的背景知识但是不幸的是,实现和示例都是用C或本机代码编写的.
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.
Java KeyStore OS X实现似乎仅对公钥/私钥对和证书有效,而对通用用户名/密码组合无效.
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.
在Java中的Mac OS X中,是否有更先进的解决方案来保护凭据安全?
Is there a more state of the art solution to the problem of securing credentials in Mac OS X in Java?
编辑:对于在...中操作的问题和环境,OAuth不是一个选项.
EDIT: OAuth is not an option for the class of problem and environment that I am operating in ...
推荐答案
根据f-stephen-q的上述答案,该库似乎仍然可以正常工作.我正在用它的叉子叉子
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
$ git clone https://github.com/physion/osx-keychain-java
$ mvn install
$ cp dist/osxkeychain.jar ~/myproject/external
添加依赖项
<dependency>
<groupId>us.physion</groupId>
<artifactId>osx-keychain</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/external/osxkeychain.jar</systemPath>
</dependency>
运行
osx-keychain-java$ jshell -cp ./dist/osxkeychain.jar
jshell> import com.mcdermottroe.apple.*;
jshell> OSXKeychain keychain = OSXKeychain.getInstance();
keychain ==> com.mcdermottroe.apple.OSXKeychain@2286778
jshell> keychain.addGenericPassword("aardvark", "a", "b");
jshell> keychain.findGenericPassword("aardvark", "a");
$4 ==> "b"
这篇关于Java中的Mac OS X钥匙串访问通用密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!