aich.pom
aich.pom

Reputation: 183

Error on class sun.security.pkcs11.SunPKCS11

I have made keyStore in java1.4 using this code.

 `public static void main(String[] args )
      throws IOException, DocumentException, GeneralSecurityException {
String pkcs11Config = "name=eToken\nlibrary=C://WINDOWS//system32//eTPKCS11.dll";
java.io.ByteArrayInputStream pkcs11ConfigStream = new java.io.ByteArrayInputStream(pkcs11Config.getBytes());
sun.security.pkcs11.SunPKCS11 providerPKCS11 = new   sun.security.pkcs11.SunPKCS11(pkcs11ConfigStream);
java.security.Security.addProvider(providerPKCS11);

// Get provider KeyStore and login with PIN
String pin = "123456";
 java.security.KeyStore keyStore =java.security.KeyStore.getInstance("PKCS11", providerPKCS11);
keyStore.load(null, pin.toCharArray());

// Enumerate items (certificates and private keys) in the KeyStore
java.util.Enumeration<String> aliases = keyStore.aliases();
String alias=null;
while (aliases.hasMoreElements()) {
 alias = aliases.nextElement();
System.out.println(alias);

 }}    

But I have get an error

`Error(2,28): cannot access class sun.security.pkcs11.SunPKCS11; class file has wrong version 49.0, should be 45.3 or 46.0 or 47.0 or 48.0`

Please Tell me the solution. How can I download the class of version below 49 like 48 etc.

Upvotes: 3

Views: 2558

Answers (1)

Vivek Chavda
Vivek Chavda

Reputation: 473

SunPKCS11 was introduced in Java 1.5

You must either upgrade the Java version or remain unable to utilize it.

Uplifting a project isn't uncommon. "The project is already running" isn't a reason to avoid this, as it's an expected part of a continuous development process.

Upvotes: 2

Related Questions