mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-12-23 13:07:59 +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,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 {
|
||||
|
|
Loading…
Reference in a new issue