diff options
author | Danny van Heumen <danny@dannyvanheumen.nl> | 2015-01-20 19:28:31 +0100 |
---|---|---|
committer | Danny van Heumen <danny@dannyvanheumen.nl> | 2015-04-03 21:37:01 +0200 |
commit | 89e35bf75c3420553ebbf6efbbff3c4d6f55ee05 (patch) | |
tree | 844d6189f0e044808c251de967ca8953ff643926 /src/net | |
parent | 71d61592c32789006d31c297ddf35d95c973924c (diff) | |
download | jitsi-89e35bf75c3420553ebbf6efbbff3c4d6f55ee05.zip jitsi-89e35bf75c3420553ebbf6efbbff3c4d6f55ee05.tar.gz jitsi-89e35bf75c3420553ebbf6efbbff3c4d6f55ee05.tar.bz2 |
Started work on SASL authentication panel in IRC account configuration.
Diffstat (limited to 'src/net')
7 files changed, 197 insertions, 11 deletions
diff --git a/src/net/java/sip/communicator/impl/protocol/irc/IrcConnection.java b/src/net/java/sip/communicator/impl/protocol/irc/IrcConnection.java index 09b7f83..5c56e6e 100644 --- a/src/net/java/sip/communicator/impl/protocol/irc/IrcConnection.java +++ b/src/net/java/sip/communicator/impl/protocol/irc/IrcConnection.java @@ -218,8 +218,31 @@ public class IrcConnection } 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()); +// } +// }); } /** diff --git a/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderFactoryIrcImpl.java b/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderFactoryIrcImpl.java index fb8e0ef..e599440 100644 --- a/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderFactoryIrcImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderFactoryIrcImpl.java @@ -37,6 +37,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. */ public ProtocolProviderFactoryIrcImpl() diff --git a/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderServiceIrcImpl.java b/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderServiceIrcImpl.java index cc2261c..78eb485 100644 --- a/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderServiceIrcImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderServiceIrcImpl.java @@ -264,6 +264,15 @@ public class ProtocolProviderServiceIrcImpl 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 @@ public class ProtocolProviderServiceIrcImpl 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; diff --git a/src/net/java/sip/communicator/impl/protocol/irc/irc.provider.manifest.mf b/src/net/java/sip/communicator/impl/protocol/irc/irc.provider.manifest.mf index 8ae471e..88c1bce 100644 --- a/src/net/java/sip/communicator/impl/protocol/irc/irc.provider.manifest.mf +++ b/src/net/java/sip/communicator/impl/protocol/irc/irc.provider.manifest.mf @@ -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 diff --git a/src/net/java/sip/communicator/plugin/ircaccregwizz/FirstWizardPage.java b/src/net/java/sip/communicator/plugin/ircaccregwizz/FirstWizardPage.java index 92d2cd3..7d97143 100644 --- a/src/net/java/sip/communicator/plugin/ircaccregwizz/FirstWizardPage.java +++ b/src/net/java/sip/communicator/plugin/ircaccregwizz/FirstWizardPage.java @@ -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 @@ public class FirstWizardPage 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 @@ public class FirstWizardPage 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 class FirstWizardPage .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 class FirstWizardPage 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 class FirstWizardPage this.enableContactPresenceTask.setSelected(contactPresenceTaskEnabled); this.enableChatRoomPresenceTask .setSelected(chatRoomPresenceTaskEnabled); + + this.saslEnabled.setSelected(enableSaslAuthentication); + this.saslUserIdField.setText(saslUser); + this.saslPasswordField.setText(saslPass); + this.saslRoleField.setText(saslRole); } /** diff --git a/src/net/java/sip/communicator/plugin/ircaccregwizz/IrcAccountRegistration.java b/src/net/java/sip/communicator/plugin/ircaccregwizz/IrcAccountRegistration.java index ef2a5e0..d10f3d4 100644 --- a/src/net/java/sip/communicator/plugin/ircaccregwizz/IrcAccountRegistration.java +++ b/src/net/java/sip/communicator/plugin/ircaccregwizz/IrcAccountRegistration.java @@ -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 class IrcAccountRegistration { 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; + } } diff --git a/src/net/java/sip/communicator/plugin/ircaccregwizz/IrcAccountRegistrationWizard.java b/src/net/java/sip/communicator/plugin/ircaccregwizz/IrcAccountRegistrationWizard.java index 76ccdef..9c2f173 100644 --- a/src/net/java/sip/communicator/plugin/ircaccregwizz/IrcAccountRegistrationWizard.java +++ b/src/net/java/sip/communicator/plugin/ircaccregwizz/IrcAccountRegistrationWizard.java @@ -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 class IrcAccountRegistrationWizard 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 class IrcAccountRegistrationWizard { ProtocolProviderFactory factory = IrcAccRegWizzActivator.getIrcProtocolProviderFactory(); - - return this.installAccount(factory, - userName, - password); + return this.installAccount(factory, userName, password); } /** @@ -282,11 +308,19 @@ public class IrcAccountRegistrationWizard 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, |