如何使用 Java 从 DoD CAC 中提取用户名
我正在尝试使用 Java 与 CAC 进行通信。从开发人员工具包中,我能够找到有关提取唯一 ID (CHUID) 的信息以及其他一些信息,例如卡上可用的小程序。但是,我无法从卡中提取用户名 (LastName.FirstName.MiddleName.ID),而且我也无法找到有关 CAC 内容的文档。
我没有使用该卡访问安全网站。我在桌面应用程序中使用它来验证用户身份,因此不会访问卡上存储的证书。我能够访问卡上存储的不同小程序,但不知道如何获取用户名。需要此用户名来验证我们系统中的用户。如何从 CAC 获取用户名?
I am trying to communicate with a CAC using Java. From the Developer Kit, I was able to find information about extracting the Unique ID (CHUID) and a few other pieces of information, like the applets available on the card. However, I am unable to extract the username (LastName.FirstName.MiddleName.ID) from the card, and I am also unable to find documentation on the CAC stuff.
I am not using the card to access a secure website. I am using it in a desktop application to authenticate users, and so would not be accessing the certificates stored on the card. I am able to access the different applets stored on the card, but have no idea how to get the username out. This username is needed to verify the users in our system. How can I get the username from a CAC?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不确定您使用什么来执行此操作,但如果您使用 PKCS#11 访问它,您需要在卡的
KeyStore
上找到包含文本“ID 证书”的别名。然后,您可以使用keyStore.getCertificate(alias)
以X509Certificate
形式获取该证书,并使用cert.getSubjectX500Principal().getName 获取您要查找的名称()
。是的,我也从未真正找到过此类事情的任何文档。
I'm not sure what you're using to do this, but if you're accessing it using PKCS#11 you need to find the alias on the card's
KeyStore
that contains the text "ID Certificate". You can then get that certificate as anX509Certificate
usingkeyStore.getCertificate(alias)
and get the name you're looking for usingcert.getSubjectX500Principal().getName()
.And yeah, I never really found any documentation for this sort of thing either.
大多数读卡器都会附带启用 PKCS #11 支持的驱动程序,然后您可以使用 SunPKCS11 安全提供程序像对待任何其他密钥存储一样对待 CAC。 此答案相关问题可能会有所帮助。
至于开发支持 CAC 的 Java 应用程序的文档,我也找不到任何文档。
Most card readers will come with a driver that enables PKCS #11 support, and then you can use the SunPKCS11 security provider to treat the CAC like any other key store. This answer to a related question may be helpful.
As for documentation on developing CAC-enabled Java applications, I was never able to find any either.