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.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Collection;
@ -1316,12 +1315,21 @@ public class XMPPConnection {
pcb = null;
}
else if(configuration.getKeystoreType().equals("PKCS11")) {
Provider p = new sun.security.pkcs11.SunPKCS11(configuration.getPKCSConfig());
Security.addProvider(p);
ks = KeyStore.getInstance("PKCS11",p);
pcb = new PasswordCallback("PKCS11 Password: ",false);
callbackHandler.handle(new Callback[]{pcb});
ks.load(null,pcb.getPassword());
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);
ks = KeyStore.getInstance("PKCS11",p);
pcb = new PasswordCallback("PKCS11 Password: ",false);
callbackHandler.handle(new Callback[]{pcb});
ks.load(null,pcb.getPassword());
}
catch (Exception e) {
ks = null;
pcb = null;
}
}
else if(configuration.getKeystoreType().equals("Apple")) {
ks = KeyStore.getInstance("KeychainStore","Apple");
@ -1331,15 +1339,15 @@ public class XMPPConnection {
}
else {
ks = KeyStore.getInstance(configuration.getKeystoreType());
try {
try {
ks.load(new FileInputStream(configuration.getKeystorePath()), pcb.getPassword());
pcb = new PasswordCallback("Keystore Password: ",false);
callbackHandler.handle(new Callback[]{pcb});
}
catch(Exception e) {
ks = null;
pcb = null;
}
}
catch(Exception e) {
ks = null;
pcb = null;
}
}
KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
try {