Run windows features with Java

Asked

Viewed 67 times

-1

I am developing an Nfe emitter and has an option in windows that allows you to select which certificate to use. I wonder if anyone knows how to call this windows feature using Java.

1 answer

2

Try this way:

Imports

import java.security.KeyStore;  
import java.security.KeyStoreException;  
import java.security.NoSuchAlgorithmException;  
import java.security.NoSuchProviderException;  
import java.security.cert.CertificateException;

Function

KeyStore instance = KeyStore.getInstance("Windows-MY", "SunMSCAPI");  

instance.load(null, null);  

Enumeration<String> dados = instance.aliases();  

List<String> certificados = new ArrayList<String>();  
while(dados.hasMoreElements())  
{  
    certificados.add(dados.nextElement());  
}  

for (String cert : certificados)  
{  
    System.out.println(cert);  
}  

Example:

Demonstracao saida

  • @Mrcogiovani. It did. Actually, I forgot to go into more detail. What I would really need is that graphical window that windows itself has, because the certificate I want is the A3.

  • Hi, never used to list the A3, try to take a look in this tutorial

Browser other questions tagged

You are not signed in. Login or sign up in order to post.