1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-27 00:32:07 +01:00

Checking for PKCS support in java and punting if it doesn't exist.

Using bytestream config instead of full config.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@9689 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Daniel Henninger 2007-12-27 16:15:57 +00:00 committed by dhenninger
parent 048e5b679c
commit 5c92ced702

View file

@ -37,7 +37,6 @@ import javax.net.ssl.KeyManager;
import java.io.*; import java.io.*;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.net.InetAddress;
import java.net.Socket; import java.net.Socket;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.util.Collection; import java.util.Collection;
@ -1316,13 +1315,22 @@ public class XMPPConnection {
pcb = null; pcb = null;
} }
else if(configuration.getKeystoreType().equals("PKCS11")) { else if(configuration.getKeystoreType().equals("PKCS11")) {
Provider p = new sun.security.pkcs11.SunPKCS11(configuration.getPKCSConfig()); try {
Constructor c = Class.forName("sun.security.pkcs11.SunPKCS11").getConstructor(String.class);
String pkcs11Config = "name = SmartCard\nlibrary = "+configuration.getPKCSConfig();
ByteArrayInputStream config = new ByteArrayInputStream(pkcs11Config.getBytes());
Provider p = (Provider)c.newInstance(config);
Security.addProvider(p); Security.addProvider(p);
ks = KeyStore.getInstance("PKCS11",p); ks = KeyStore.getInstance("PKCS11",p);
pcb = new PasswordCallback("PKCS11 Password: ",false); pcb = new PasswordCallback("PKCS11 Password: ",false);
callbackHandler.handle(new Callback[]{pcb}); callbackHandler.handle(new Callback[]{pcb});
ks.load(null,pcb.getPassword()); ks.load(null,pcb.getPassword());
} }
catch (Exception e) {
ks = null;
pcb = null;
}
}
else if(configuration.getKeystoreType().equals("Apple")) { else if(configuration.getKeystoreType().equals("Apple")) {
ks = KeyStore.getInstance("KeychainStore","Apple"); ks = KeyStore.getInstance("KeychainStore","Apple");
ks.load(null,null); ks.load(null,null);