Started work on SASL authentication panel in IRC account configuration.

maven
Danny van Heumen 12 years ago
parent 71d61592c3
commit 89e35bf75c

@ -1096,6 +1096,9 @@ plugin.ircaccregwizz.EXAMPLE_SERVER=Ex: chat.freenode.net
plugin.ircaccregwizz.USE_SECURE_CONNECTION=Use secure connection
plugin.ircaccregwizz.ENABLE_CONTACT_PRESENCE=Enable contact presence
plugin.ircaccregwizz.ENABLE_CHAT_ROOM_PRESENCE=Enable chat room presence
plugin.ircaccregwizz.SASL_AUTHENTICATION_TITLE=SASL authentication
plugin.ircaccregwizz.ENABLE_SASL_AUTHENTICATION=Enable SASL authentication
plugin.ircaccregwizz.SASL_AUTHZ_ROLE=Role
# jabber accregwizz
plugin.jabberaccregwizz.PROTOCOL_NAME=XMPP

@ -218,8 +218,31 @@ private static CapabilityNegotiator determineNegotiator(final String user,
}
else
{
// FIXME correctly determine capabilities and SASL authentication
// enabled
return new SaslNegotiator(user, password, null);
}
// FIXME DEBUG CODE remove
// final ArrayList<Capability> caps = new ArrayList<Capability>();
// caps.add(new SimpleCapability("away-notify"));
// if (password != null)
// {
// caps.add(new SaslCapability(true, null, user, password));
// }
// return new CompositeNegotiator(caps, new CompositeNegotiator.Host()
// {
// @Override
// public void reject(Capability cap)
// {
// LOGGER.warn("REJECTED: " + cap.getId());
// }
//
// @Override
// public void acknowledge(Capability cap)
// {
// LOGGER.warn("ACKED: " + cap.getId());
// }
// });
}
/**

@ -36,6 +36,26 @@ public class ProtocolProviderFactoryIrcImpl
*/
public static final String CONTACT_PRESENCE_TASK = "CONTACT_PRESENCE_TASK";
/**
* Property indicating SASL is enabled.
*/
public static final String SASL_ENABLED = "SASL_ENABLED";
/**
* Property for SASL user name.
*/
public static final String SASL_USERNAME = "SASL_USERNAME";
/**
* Property for SASL password.
*/
public static final String SASL_PASSWORD = "SASL_PASSWORD";
/**
* Property for SASL authorization role.
*/
public static final String SASL_ROLE = "SASL_ROLE";
/**
* Constructor.
*/

@ -264,6 +264,15 @@ public void register(final SecurityAuthority authority)
accountID.getAccountPropertyBoolean(
ProtocolProviderFactoryIrcImpl.CONTACT_PRESENCE_TASK, true);
boolean saslEnabled = accountID.getAccountPropertyBoolean(
ProtocolProviderFactoryIrcImpl.SASL_ENABLED, false);
String saslUser = accountID.getAccountPropertyString(
ProtocolProviderFactoryIrcImpl.SASL_USERNAME);
String saslPass = accountID.getAccountPropertyString(
ProtocolProviderFactoryIrcImpl.SASL_PASSWORD);
String saslRole = accountID.getAccountPropertyString(
ProtocolProviderFactoryIrcImpl.SASL_ROLE);
//if we don't - retrieve it from the user through the security authority
if (serverPassword == null && passwordRequired)
{
@ -388,7 +397,8 @@ private boolean loadDNSThroughProxySetting()
IrcActivator.getConfigurationService();
if (configSvc == null)
{
return false;
// Assuming maximum use of configured proxy server is desirable.
return true;
}
// FIXME implement support for option to enable SOCKS5 DNS resolving
return true;

@ -25,5 +25,6 @@ Import-Package: org.osgi.framework,
com.ircclouds.irc.api.state,
com.ircclouds.irc.api.commands,
com.ircclouds.irc.api.negotiators,
com.ircclouds.irc.api.negotiators.capabilities,
org.apache.commons.lang3,
org.apache.commons.codec.binary

@ -61,6 +61,8 @@ public class FirstWizardPage
private JPanel serverPanel = new TransparentPanel(new BorderLayout(10, 10));
private JPanel optionsPanel = new TransparentPanel(new BorderLayout(10, 10));
private JPanel saslPanel = new TransparentPanel(new BorderLayout(10, 10));
private JPanel labelsPanel = new TransparentPanel();
@ -127,6 +129,15 @@ public class FirstWizardPage
private JCheckBox enableChatRoomPresenceTask = new SIPCommCheckBox(
Resources.getString("plugin.ircaccregwizz.ENABLE_CHAT_ROOM_PRESENCE"));
private JCheckBox saslEnabled = new SIPCommCheckBox(
Resources.getString("plugin.ircaccregwizz.ENABLE_SASL_AUTHENTICATION"));
private JTextField saslUserIdField = new JTextField();
private JPasswordField saslPasswordField = new JPasswordField();
private JTextField saslRoleField = new JTextField();
private JPanel mainPanel = new TransparentPanel();
private Object nextPageIdentifier = WizardPage.SUMMARY_PAGE_IDENTIFIER;
@ -223,18 +234,14 @@ private void init(String userId, String server)
labelsPanel.add(emptyPanel);
labelsPanel.add(passLabel);
// labelsPanel.add(server);
valuesPanel.add(userIDField);
valuesPanel.add(nickExampleLabel);
valuesPanel.add(passField);
// valuesPanel.add(serverField);
userPassPanel.add(infoPassword, BorderLayout.NORTH);
userPassPanel.add(labelsPanel, BorderLayout.WEST);
userPassPanel.add(valuesPanel, BorderLayout.CENTER);
userPassPanel.add(passwordNotRequired, BorderLayout.SOUTH);
// userPassPanel.add(autoChangeNick, BorderLayout.SOUTH);
userPassPanel.setBorder(BorderFactory
.createTitledBorder(Resources.getString(
@ -271,15 +278,39 @@ private void init(String userId, String server)
optionsPanel.setBorder(BorderFactory.createTitledBorder(
Resources.getString("service.gui.OPTIONS")));
saslPanel.add(this.saslEnabled, BorderLayout.NORTH);
TransparentPanel saslControlsPanel = new TransparentPanel();
saslControlsPanel.setLayout(new BoxLayout(saslControlsPanel, BoxLayout.Y_AXIS));
saslPanel.add(saslControlsPanel, BorderLayout.CENTER);
JLabel saslUserLabel = new JLabel(Resources.getString("plugin.ircaccregwizz.USERNAME") + ":");
saslControlsPanel.add(horizontal(100, saslUserLabel, saslUserIdField));
JLabel saslPassLabel = new JLabel(Resources.getString("service.gui.PASSWORD") + ":");
saslControlsPanel.add(horizontal(100, saslPassLabel, saslPasswordField));
JLabel saslRoleLabel = new JLabel(Resources.getString("plugin.ircaccregwizz.SASL_AUTHZ_ROLE") + ":");
saslControlsPanel.add(horizontal(100, saslRoleLabel, saslRoleField));
// FIXME continue implementation of the sasl authentication panel
saslPanel.setBorder(BorderFactory.createTitledBorder(Resources
.getString("plugin.ircaccregwizz.SASL_AUTHENTICATION_TITLE")));
mainPanel.add(userPassPanel);
mainPanel.add(serverPanel);
mainPanel.add(optionsPanel);
mainPanel.add(saslPanel);
this.add(mainPanel, BorderLayout.NORTH);
// this.add(serverPanel, BorderLayout.SOUTH);
// this.add(optionsPanel, BorderLayout.AFTER_LAST_LINE);
}
private JPanel horizontal(int width, Component cmp1, Component cmp2) {
TransparentPanel panel = new TransparentPanel(new BorderLayout(10, 10));
cmp1.setPreferredSize(new Dimension(width, cmp1.getHeight()));
panel.add(cmp1, BorderLayout.WEST);
panel.add(cmp2, BorderLayout.CENTER);
return panel;
}
/**
* Implements the <code>WizardPage.getIdentifier</code> to return
* this page identifier.
@ -364,6 +395,10 @@ public void commitPage()
.isSelected());
registration.setChatRoomPresenceTaskEnabled(enableChatRoomPresenceTask
.isSelected());
registration.setSaslEnabled(this.saslEnabled.isSelected());
registration.setSaslUser(this.saslUserIdField.getText());
registration.setSaslPass(new String(saslPasswordField.getPassword()));
registration.setSaslRole(this.saslRoleField.getText());
isCommitted = true;
}
@ -475,6 +510,20 @@ public void loadAccount(ProtocolProviderService protocolProvider)
accountID.getAccountPropertyBoolean(
IrcAccountRegistrationWizard.CHAT_ROOM_PRESENCE_TASK, true);
final boolean enableSaslAuthentication =
accountID.getAccountPropertyBoolean(
IrcAccountRegistrationWizard.SASL_ENABLED, false);
final String saslUser =
accountID.getAccountPropertyString(
IrcAccountRegistrationWizard.SASL_USERNAME, "");
// FIXME load password from secure password storage!
final String saslPass =
accountID.getAccountPropertyString(
IrcAccountRegistrationWizard.SASL_PASSWORD, "");
final String saslRole =
accountID.getAccountPropertyString(
IrcAccountRegistrationWizard.SASL_ROLE, "");
this.userIDField.setEnabled(false);
this.userIDField.setText(accountID.getUserID());
this.serverField.setText(server);
@ -516,6 +565,11 @@ public void loadAccount(ProtocolProviderService protocolProvider)
this.enableContactPresenceTask.setSelected(contactPresenceTaskEnabled);
this.enableChatRoomPresenceTask
.setSelected(chatRoomPresenceTaskEnabled);
this.saslEnabled.setSelected(enableSaslAuthentication);
this.saslUserIdField.setText(saslUser);
this.saslPasswordField.setText(saslPass);
this.saslRoleField.setText(saslRole);
}
/**

@ -23,6 +23,10 @@ public class IrcAccountRegistration
private boolean autoChangeNick;
private boolean isRequiredPassword;
private boolean secureConnection;
private boolean saslEnabled;
private String saslUser;
private String saslPass;
private String saslRole;
/**
* Option for activating contact presence task.
@ -242,4 +246,44 @@ public void setChatRoomPresenceTaskEnabled(final boolean value)
{
this.chatroomPresenceTaskEnabled = value;
}
public boolean isSaslEnabled()
{
return this.saslEnabled;
}
public void setSaslEnabled(final boolean enabled)
{
this.saslEnabled = enabled;
}
public String getSaslUser()
{
return this.saslUser;
}
public void setSaslUser(final String user)
{
this.saslUser = user;
}
public String getSaslPass()
{
return this.saslPass;
}
public void setSaslPass(final String pass)
{
this.saslPass = pass;
}
public String getSaslRole()
{
return this.saslRole;
}
public void setSaslRole(final String role)
{
this.saslRole = role;
}
}

@ -47,6 +47,26 @@ public class IrcAccountRegistrationWizard
public static final String CHAT_ROOM_PRESENCE_TASK =
"CHAT_ROOM_PRESENCE_TASK";
/**
* Property indicating SASL is enabled.
*/
public static final String SASL_ENABLED = "SASL_ENABLED";
/**
* Property name for SASL user.
*/
public static final String SASL_USERNAME = "SASL_USERNAME";
/**
* Property name for SASL password.
*/
public static final String SASL_PASSWORD = "SASL_PASSWORD";
/**
* Property for SASL authorization role.
*/
public static final String SASL_ROLE = "SASL_ROLE";
private final Logger logger
= Logger.getLogger(IrcAccountRegistrationWizard.class);
@ -190,6 +210,15 @@ public Iterator<Map.Entry<String, String>> getSummary()
summaryTable.put(Resources
.getString("plugin.ircaccregwizz.ENABLE_CHAT_ROOM_PRESENCE"),
registration.isChatRoomPresenceTaskEnabled() ? yes : no);
summaryTable.put(Resources
.getString("plugin.ircaccregwizz.ENABLE_SASL_AUTHENTICATION"),
registration.isSaslEnabled() ? yes : no);
summaryTable.put(
"SASL " + Resources.getString("plugin.ircaccregwizz.USERNAME"),
registration.getSaslUser());
summaryTable.put("SASL "
+ Resources.getString("plugin.ircaccregwizz.SASL_AUTHZ_ROLE"),
registration.getSaslRole());
return summaryTable.entrySet().iterator();
}
@ -233,10 +262,7 @@ public ProtocolProviderService signin(final String userName,
{
ProtocolProviderFactory factory
= IrcAccRegWizzActivator.getIrcProtocolProviderFactory();
return this.installAccount(factory,
userName,
password);
return this.installAccount(factory, userName, password);
}
/**
@ -282,11 +308,19 @@ private ProtocolProviderService installAccount(
accountProperties.put(ProtocolProviderFactory.DEFAULT_ENCRYPTION,
new Boolean(registration.isSecureConnection()).toString());
// Presence-based background tasks
accountProperties.put(CONTACT_PRESENCE_TASK,
Boolean.toString(registration.isContactPresenceTaskEnabled()));
accountProperties.put(CHAT_ROOM_PRESENCE_TASK,
Boolean.toString(registration.isChatRoomPresenceTaskEnabled()));
// SASL properties
accountProperties.put(SASL_ENABLED,
Boolean.toString(registration.isSaslEnabled()));
accountProperties.put(SASL_USERNAME, registration.getSaslUser());
accountProperties.put(SASL_PASSWORD, registration.getSaslPass());
accountProperties.put(SASL_ROLE, registration.getSaslRole());
if (isModification())
{
providerFactory.modifyAccount(this.protocolProvider,

Loading…
Cancel
Save