Initial support for secure connections and Wizard UI tweaks.

Initial support for secure connections has been introduced. An extra
package path has been added to the manifest in order to acquire
SSL-related classes. The IrcStack has been modified to receive an extra
parameter indicating whether or not to establish a secure connection.

A number of small UI tweaks have been made to the wizard. User id and
server entered into the "simple form" are now migrated to the full form.
An extra checkbox is added to indicate plaintext/secure connection. The
wizard currently defaults to secure. An appropriate default port is set
based on plaintext/secure type of connection. Registered new listeners
in order to evalute access to Next-button on every change.
fix-message-formatting
Danny van Heumen 12 years ago
parent 0df1c45e96
commit 69b962cf05

@ -1073,6 +1073,7 @@ plugin.ircaccregwizz.USE_DEFAULT_PORT=Use default port
plugin.ircaccregwizz.PASSWORD_NOT_REQUIRED=My nickname doesn't require identification
plugin.ircaccregwizz.HOST=Hostname:
plugin.ircaccregwizz.IRC_SERVER=Server
plugin.ircaccregwizz.USE_SECURE_CONNECTION=Use secure connection
# jabber accregwizz
plugin.jabberaccregwizz.PROTOCOL_NAME=XMPP

@ -111,7 +111,7 @@ public boolean isSecureConnection()
* @throws Exception
*/
public void connect(String host, int port, String password,
boolean autoNickChange) throws Exception
boolean secureConnection, boolean autoNickChange) throws Exception
{
if (this.irc != null && this.connectionState != null
&& this.connectionState.isConnected())
@ -124,7 +124,7 @@ public void connect(String host, int port, String password,
final Exception[] exceptionContainer = new Exception[1];
this.irc = new IRCApiImpl(true);
this.params.setServer(new IRCServer(host, port, password, false));
this.params.setServer(new IRCServer(host, port, password, secureConnection));
synchronized (this.irc)
{
// register a server listener in order to catch server and cross-/multi-channel messages

@ -170,7 +170,7 @@ public void register(SecurityAuthority authority)
= accountID
.getAccountPropertyInt(
ProtocolProviderFactory.SERVER_PORT,
6667);
6697);
//Verify whether a password has already been stored for this account
String serverPassword = IrcActivator.
getProtocolProviderFactory().loadPassword(getAccountID());
@ -180,6 +180,9 @@ public void register(SecurityAuthority authority)
boolean passwordRequired =
accountID.getAccountPropertyBoolean(
ProtocolProviderFactory.NO_PASSWORD_REQUIRED, true);
boolean secureConnection =
accountID.getAccountPropertyBoolean(
ProtocolProviderFactory.DEFAULT_ENCRYPTION, true);
//if we don't - retrieve it from the user through the security authority
if (serverPassword == null && passwordRequired)
@ -195,8 +198,12 @@ public void register(SecurityAuthority authority)
credentials,
SecurityAuthority.AUTHENTICATION_REQUIRED);
//extract the password the user passed us.
char[] pass = credentials.getPassword();
char[] pass = null;
if (credentials != null)
{
// extract the password the user passed us.
pass = credentials.getPassword();
}
// the user didn't provide us a password (canceled the operation)
if (pass == null)
@ -221,7 +228,7 @@ public void register(SecurityAuthority authority)
try
{
this.ircStack.connect(serverAddress, serverPort, serverPassword,
autoNickChange);
secureConnection, autoNickChange);
}
catch (Exception e)
{

@ -10,4 +10,5 @@ Import-Package: org.osgi.framework,
net.java.sip.communicator.service.resources,
net.java.sip.communicator.util,
net.java.sip.communicator.service.protocol,
net.java.sip.communicator.service.protocol.event
net.java.sip.communicator.service.protocol.event,
javax.net.ssl

@ -42,6 +42,10 @@ public class FirstWizardPage
public static final String USER_NAME_EXAMPLE = "Ex: ircuser";
public static final String SERVER_EXAMPLE = "Ex: irc.quakenet.org";
private static final String DEFAULT_PLAINTEXT_PORT = "6667";
private static final String DEFAULT_SECURE_PORT = "6697";
private JPanel userPassPanel = new TransparentPanel(new BorderLayout(10, 10));
@ -104,6 +108,9 @@ public class FirstWizardPage
private JCheckBox passwordNotRequired = new SIPCommCheckBox(
Resources.getString("plugin.ircaccregwizz.PASSWORD_NOT_REQUIRED"));
private JCheckBox useSecureConnection = new SIPCommCheckBox(
Resources.getString("plugin.ircaccregwizz.USE_SECURE_CONNECTION"));
private JPanel mainPanel = new TransparentPanel();
@ -118,7 +125,7 @@ public class FirstWizardPage
*
* @param wizard the parent wizard
*/
public FirstWizardPage(IrcAccountRegistrationWizard wizard)
public FirstWizardPage(IrcAccountRegistrationWizard wizard, String userId, String server)
{
super(new BorderLayout());
@ -126,7 +133,7 @@ public FirstWizardPage(IrcAccountRegistrationWizard wizard)
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
this.init();
this.init(userId, server);
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
@ -150,12 +157,13 @@ public FirstWizardPage(IrcAccountRegistrationWizard wizard)
this.portField.setEnabled(false);
this.rememberPassBox.setEnabled(false);
this.useSecureConnection.setEnabled(true);
}
/**
* Initializes all panels, buttons, etc.
*/
private void init()
private void init(String userId, String server)
{
this.mainPanel.setOpaque(false);
this.labelsPanel.setOpaque(false);
@ -164,13 +172,20 @@ private void init()
this.userIDField.getDocument().addDocumentListener(this);
this.serverField.getDocument().addDocumentListener(this);
this.passField.getDocument().addDocumentListener(this);
this.defaultPort.addActionListener(this);
this.passwordNotRequired.addActionListener(this);
this.useSecureConnection.addActionListener(this);
this.userIDField.setText(userId);
this.serverField.setText(server);
this.passField.setEnabled(false);
this.rememberPassBox.setSelected(true);
this.autoNickChange.setSelected(true);
this.defaultPort.setSelected(true);
this.passwordNotRequired.setSelected(false);
this.passwordNotRequired.setSelected(true);
this.useSecureConnection.setSelected(true);
this.portField.setText(this.useSecureConnection.isSelected() ? DEFAULT_SECURE_PORT : DEFAULT_PLAINTEXT_PORT);
this.nickExampleLabel.setForeground(Color.GRAY);
this.nickExampleLabel.setFont(
@ -206,7 +221,7 @@ private void init()
.createTitledBorder(Resources.getString(
"plugin.ircaccregwizz.USERNAME_AND_PASSWORD")));
labelsServerPanel.add(server);
labelsServerPanel.add(this.server);
labelsServerPanel.add(emptyPanel2);
labelsServerPanel.add(port);
@ -216,7 +231,12 @@ private void init()
serverPanel.add(labelsServerPanel, BorderLayout.WEST);
serverPanel.add(valuesServerPanel, BorderLayout.CENTER);
serverPanel.add(defaultPort, BorderLayout.SOUTH);
JPanel serverSubPanel = new JPanel(new BorderLayout());
serverSubPanel.setOpaque(false);
serverSubPanel.add(defaultPort, BorderLayout.WEST);
serverSubPanel.add(useSecureConnection, BorderLayout.EAST);
serverPanel.add(serverSubPanel, BorderLayout.SOUTH);
serverPanel.setBorder(BorderFactory.createTitledBorder(
Resources.getString("plugin.ircaccregwizz.IRC_SERVER")));
@ -314,6 +334,7 @@ public void commitPage()
registration.setRememberPassword(rememberPassBox.isSelected());
registration.setAutoChangeNick(autoNickChange.isSelected());
registration.setRequiredPassword(!passwordNotRequired.isSelected());
registration.setSecureConnection(useSecureConnection.isSelected());
isCommitted = true;
}
@ -412,6 +433,10 @@ public void loadAccount(ProtocolProviderService protocolProvider)
String noPasswordRequired =
accountID
.getAccountPropertyString(ProtocolProviderFactory.NO_PASSWORD_REQUIRED);
boolean useSecureConnection =
accountID.getAccountPropertyBoolean(
ProtocolProviderFactory.DEFAULT_ENCRYPTION, true);
this.userIDField.setEnabled(false);
this.userIDField.setText(accountID.getUserID());
@ -445,6 +470,8 @@ public void loadAccount(ProtocolProviderService protocolProvider)
passField.setEnabled(isPassRequired);
}
this.useSecureConnection.setSelected(useSecureConnection);
}
/**
@ -455,11 +482,15 @@ public void actionPerformed(ActionEvent event)
{
if (defaultPort.isSelected())
{
portField.setText("");
portField
.setText(useSecureConnection.isSelected() ? DEFAULT_SECURE_PORT
: DEFAULT_PLAINTEXT_PORT);
portField.setEnabled(false);
}
else
{
portField.setEnabled(true);
}
if (passwordNotRequired.isSelected())
{
@ -472,7 +503,8 @@ public void actionPerformed(ActionEvent event)
passField.setEnabled(true);
rememberPassBox.setEnabled(true);
}
setNextButtonAccordingToUserID();
}
public void changedUpdate(DocumentEvent event){}
@ -514,4 +546,14 @@ public boolean isCommitted()
{
return isCommitted;
}
public String getCurrentUserId()
{
return this.userIDField.getText();
}
public String getCurrentServer()
{
return this.serverField.getText();
}
}

@ -21,6 +21,7 @@ public class IrcAccountRegistration
private boolean rememberPassword;
private boolean autoChangeNick;
private boolean isRequiredPassword;
private boolean secureConnection;
/**
* Returns the User ID of the IRC registration account.
@ -168,4 +169,26 @@ public void setRememberPassword(boolean rememberPassword)
{
this.rememberPassword = rememberPassword;
}
/**
* Indicates if the the connection must be secure or not.
*
* @return returns <code>true</code> to indicate that the connection should
* be secure, or false for unsecured connection.
*/
public boolean isSecureConnection()
{
return this.secureConnection;
}
/**
* Set the <tt>useSecureConnection</tt> property.
*
* @param secureConnection true to require secure connection, or false
* for unsecured connections
*/
public void setSecureConnection(boolean secureConnection)
{
this.secureConnection = secureConnection;
}
}

@ -108,7 +108,14 @@ public String getProtocolDescription()
public Iterator<WizardPage> getPages()
{
java.util.List<WizardPage> pages = new ArrayList<WizardPage>();
firstWizardPage = new FirstWizardPage(this);
String userId = "";
String server = "";
if (firstWizardPage != null)
{
userId = firstWizardPage.getCurrentUserId();
server = firstWizardPage.getCurrentServer();
}
firstWizardPage = new FirstWizardPage(this, userId, server);
pages.add(firstWizardPage);
@ -227,6 +234,9 @@ public ProtocolProviderService installAccount(
accountProperties.put(
ProtocolProviderFactory.NO_PASSWORD_REQUIRED,
new Boolean(!registration.isRequiredPassword()).toString());
accountProperties.put(ProtocolProviderFactory.DEFAULT_ENCRYPTION,
new Boolean(registration.isSecureConnection()).toString());
if (isModification())
{
@ -366,7 +376,7 @@ public boolean isSimpleFormEnabled()
@Override
public Object getSimpleForm(boolean isCreateAccount)
{
firstWizardPage = new FirstWizardPage(this);
firstWizardPage = new FirstWizardPage(this, "", "");
return firstWizardPage.getSimpleForm();
}

Loading…
Cancel
Save