Run windows resources with Java [closed]

-1

I am developing an NFe issuer and have an option in windows that allows you to select which certificate to use. I would like to know if anyone knows how to call this feature from windows using Java.

    
asked by anonymous 02.09.2016 / 13:42

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:

    
02.09.2016 / 14:19