title: Java Access Token PKCS11 Not found Provider
body: <p>Hello I'm trying to access the keystore from my smartcard in Java. And I'm using the following code..</p>
  
  <p>I'm using the Pkcs11 implementation of OpenSc <a href="http://www.opensc-project.org/opensc" rel="noreferrer">http://www.opensc-project.org/opensc</a></p>
  
  <p><strong>File windows.cnf</strong> =   </p>
  
  <pre><code>name=dnie
  library=C:\WINDOWS\system32\opensc-pkcs11.dll
  </code></pre>
  
  <p><strong>Java Code</strong> =</p>
  
  <pre><code>String configName = "windows.cnf"
   String PIN = "####";
   Provider p = new sun.security.pkcs11.SunPKCS11(configName);
   Security.addProvider(p);
   KeyStore keyStore = KeyStore.getInstance("PKCS11", "SunPKCS11-dnie");  =)(= 
   char[] pin = PIN.toCharArray();
   keyStore.load(null, pin);
  </code></pre>
  
  <p>When the execution goes by the line with <strong>=)(=</strong>  throws me the following exception </p>
  
  <pre><code>java.security.KeyStoreException: PKCS11 not found
  
      at java.security.KeyStore.getInstance(KeyStore.java:635)
      at ObtenerDatos.LeerDatos(ObtenerDatos.java:52)
      at ObtenerDatos.obtenerNombre(ObtenerDatos.java:19)
      at main.main(main.java:27)
  Caused by: java.security.NoSuchAlgorithmException: no such algorithm: PKCS11 for provider SunPKCS11-dnie
          at sun.security.jca.GetInstance.getService(GetInstance.java:70)
          at sun.security.jca.GetInstance.getInstance(GetInstance.java:190)
          at java.security.Security.getImpl(Security.java:662)
          at java.security.KeyStore.getInstance(KeyStore.java:632)
  </code></pre>
  
  <p>I think the problem is "SunPKCS11-dnie", but I don't know to put there. I had tried with a lot of combinations...</p>
  
  <p>Anyone can help me... </p>