Include check for crypto algorithm support.

git-svn-id: file:///home/svn/framework3/trunk@13430 4d416f70-5f16-0410-b530-b9f4589650da
unstable
Matt Weeks 2011-07-30 19:38:35 +00:00
parent 2b912e3b4a
commit 8447141a0c
2 changed files with 18 additions and 2 deletions

Binary file not shown.

View File

@ -4,6 +4,7 @@ import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.io.File;
import java.security.NoSuchAlgorithmException;
import java.util.Map;
import javax.swing.JFileChooser;
import javax.swing.JTextField;
@ -60,6 +61,21 @@ public class OpenConnectionDialog extends javax.swing.JDialog {
disableDbButton.setSelected(Boolean.TRUE.equals(root.get("disableDb")));
}
private boolean checkCrypto(boolean ssl) throws MsfException {
try {
if (ssl)
javax.crypto.KeyGenerator.getInstance("RSA");
} catch (NoSuchAlgorithmException nsax) {
MsfguiApp.showMessage(this, "Error: this version of Java does not support the necessary "
+ "\ncryptographic capabilities to connect to msfrpcd over SSL. Try running \n"
+ (System.getProperty("os.name").toLowerCase().contains("windows") ? "" : "java -jar ")
+ MsfguiApp.getMsfRoot() + "/data/gui/msfgui.jar \n"
+ "as your system version of Java may work.");
throw new MsfException("SSLcheck");
}
return ssl;
}
/** Sets the text of the given component if val is defined */
private void fillDefault(Object val, JTextField field) {
if (val!= null)
@ -313,7 +329,7 @@ public class OpenConnectionDialog extends javax.swing.JDialog {
char[] password = passwordField.getPassword();
String host = hostField.getText();
int port = Integer.parseInt(portField.getText());
boolean ssl = sslBox.isSelected();
boolean ssl = checkCrypto(sslBox.isSelected());
try {
rpcConn = new RpcConnection(username, password, host, port, ssl);
} catch (MsfException mex) {
@ -351,7 +367,7 @@ public class OpenConnectionDialog extends javax.swing.JDialog {
if(hostField.getText().length() > 0)
RpcConnection.defaultHost = hostField.getText();
RpcConnection.defaultPort = Integer.parseInt(portField.getText());
RpcConnection.defaultSsl = sslBox.isSelected();
RpcConnection.defaultSsl = checkCrypto(sslBox.isSelected());
RpcConnection.disableDb = disableDbButton.isSelected();
//do the action. There's probably a "right" way to do Oh well.
mainframe.getContext().getActionMap(mainframe).get("startRpc").actionPerformed(new java.awt.event.ActionEvent(startNewButton,1234,""));