mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-26 14:02:06 +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:
parent
048e5b679c
commit
5c92ced702
1 changed files with 21 additions and 13 deletions
|
@ -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,13 +1315,22 @@ public class XMPPConnection {
|
|||
pcb = null;
|
||||
}
|
||||
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);
|
||||
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");
|
||||
ks.load(null,null);
|
||||
|
|
Loading…
Reference in a new issue