mirror of
https://github.com/igniterealtime/Spark.git
synced 2025-12-01 12:27:58 +00:00
Spark 1740 smack3 compat (#199)
* SPARK-1735: MUC occupants list should have width This commit attempts to prevent that the occupants list in a MUC screen has a near-zero width. * SPARK-1772: Icons for muc role fix * SPARK-1735: MUC occupants list should have vertical scrollbar * SPARK-1740: Allow SASL GSS-API to be executed as it was in SMACK 3 SMACK 4 uses the fully qualified host name, when negotiating GSS-API via SASL. SMACK 3 used the XMPP domain name instead. Spark should have a configurable option that allows it to fall back to the old mechanism (which is likely needed to connect to servers that have already been configured to accept SSO from older versions of Spark). This commit also brings a reorganization of the code of the 'advanced connection settings' dialog - simply because it was pretty unpractical as it was. Small modifications have been made to the layout.
This commit is contained in:
@ -1,101 +0,0 @@
|
||||
/**
|
||||
* $RCSfile: ,v $
|
||||
* $Revision: $
|
||||
* $Date: $
|
||||
*
|
||||
* Copyright (C) 2004-2011 Jive Software. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jivesoftware;
|
||||
|
||||
import javax.security.auth.login.AppConfigurationEntry;
|
||||
import javax.security.auth.login.Configuration;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Vector;
|
||||
|
||||
|
||||
public class GSSAPIConfiguration extends Configuration {
|
||||
|
||||
Map<String, Vector<AppConfigurationEntry>> configs;
|
||||
|
||||
GSSAPIConfiguration() {
|
||||
super();
|
||||
init(true);
|
||||
}
|
||||
|
||||
GSSAPIConfiguration(boolean config_from_file) {
|
||||
super();
|
||||
init(config_from_file);
|
||||
}
|
||||
|
||||
|
||||
private void init(boolean config_from_file) {
|
||||
|
||||
configs = new HashMap<>();
|
||||
|
||||
//The structure of the options is not well documented in terms of
|
||||
//data types. Since the file version of the Configuration object
|
||||
//puts things in quotes, String is assumed. But boolean options
|
||||
//do not have quotes, and my represent different types internally.
|
||||
HashMap<String, String> c_options = new HashMap<>();
|
||||
|
||||
//If Kerberos config is not from a file, it's not possible to (re-)read the config file.
|
||||
//So don't set refreshKrb5Config
|
||||
if (config_from_file) {
|
||||
c_options.put("refreshKrb5Config", "true");
|
||||
}
|
||||
c_options.put("doNotPrompt", "true");
|
||||
c_options.put("useTicketCache", "true");
|
||||
c_options.put("debug", "true");
|
||||
|
||||
|
||||
putAppConfigurationEntry("com.sun.security.jgss.initiate", "com.sun.security.auth.module.Krb5LoginModule", AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, c_options);
|
||||
putAppConfigurationEntry("com.sun.security.jgss.krb5.initiate", "com.sun.security.auth.module.Krb5LoginModule", AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, c_options);
|
||||
|
||||
}
|
||||
|
||||
public AppConfigurationEntry[] getAppConfigurationEntry(String name) {
|
||||
AppConfigurationEntry[] a = new AppConfigurationEntry[1];
|
||||
if (configs.containsKey(name)) {
|
||||
Vector<AppConfigurationEntry> v = configs.get(name);
|
||||
a = v.toArray(a);
|
||||
return a;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean putAppConfigurationEntry(String name, String module, AppConfigurationEntry.LoginModuleControlFlag controlFlag, Map<String,String> options) {
|
||||
Vector<AppConfigurationEntry> v;
|
||||
if (configs.containsKey(name)) {
|
||||
v = configs.get(name);
|
||||
}
|
||||
else {
|
||||
v = new Vector<>();
|
||||
configs.put(name, v);
|
||||
}
|
||||
|
||||
return v.add(new AppConfigurationEntry(module, controlFlag, options));
|
||||
}
|
||||
|
||||
|
||||
public void refresh() {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -40,6 +40,9 @@ import org.jivesoftware.spark.SessionManager;
|
||||
import org.jivesoftware.spark.SparkManager;
|
||||
import org.jivesoftware.spark.Workspace;
|
||||
import org.jivesoftware.spark.component.RolloverButton;
|
||||
import org.jivesoftware.spark.sasl.SASLGSSAPIv3CompatMechanism;
|
||||
import org.jivesoftware.spark.ui.login.GSSAPIConfiguration;
|
||||
import org.jivesoftware.spark.ui.login.LoginSettingDialog;
|
||||
import org.jivesoftware.spark.util.*;
|
||||
import org.jivesoftware.spark.util.SwingWorker;
|
||||
import org.jivesoftware.spark.util.log.Log;
|
||||
@ -293,14 +296,23 @@ public class LoginDialog {
|
||||
}
|
||||
}
|
||||
|
||||
// SPARK-1747: Don't use the GSSAPI mechanism when SSO is disabled.
|
||||
if ( localPref.isSSOEnabled() && !SASLAuthentication.getRegisterdSASLMechanisms().containsKey( SASLGSSAPIMechanism.class.getName() ))
|
||||
// SPARK-1747: Don't use the GSS-API SASL mechanism when SSO is disabled.
|
||||
SASLAuthentication.unregisterSASLMechanism( SASLGSSAPIMechanism.class.getName() );
|
||||
SASLAuthentication.unregisterSASLMechanism( SASLGSSAPIv3CompatMechanism.class.getName() );
|
||||
|
||||
// Add the mechanism only when SSO is enabled (which allows us to register the correct one).
|
||||
if ( localPref.isSSOEnabled() )
|
||||
{
|
||||
SASLAuthentication.registerSASLMechanism( new SASLGSSAPIMechanism() );
|
||||
}
|
||||
else if ( !localPref.isSSOEnabled() && SASLAuthentication.getRegisterdSASLMechanisms().containsValue( SASLGSSAPIMechanism.NAME ))
|
||||
{
|
||||
SASLAuthentication.unregisterSASLMechanism( SASLGSSAPIMechanism.class.getName() );
|
||||
// SPARK-1740: Register a mechanism that's compatible with Smack 3, when requested.
|
||||
if ( localPref.isSaslGssapiSmack3Compatible() )
|
||||
{
|
||||
// SPARK-1747: Don't use the GSSAPI mechanism when SSO is disabled.
|
||||
SASLAuthentication.registerSASLMechanism( new SASLGSSAPIv3CompatMechanism() );
|
||||
}
|
||||
else
|
||||
{
|
||||
SASLAuthentication.registerSASLMechanism( new SASLGSSAPIMechanism() );
|
||||
}
|
||||
}
|
||||
|
||||
ReconnectionManager.setEnabledPerDefault( true );
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,22 @@
|
||||
package org.jivesoftware.spark.sasl;
|
||||
|
||||
import org.jivesoftware.smack.sasl.javax.SASLGSSAPIMechanism;
|
||||
|
||||
/**
|
||||
* This is an implementation of a SASL GSS-API mechanisms, that uses the XMPP domain name, instead of the fully
|
||||
* qualified domain name of the XMPP server that is being connected to.
|
||||
*
|
||||
* This implementation reverts the GSS-API SASL mechanism behavior back to what it was in Smack 3, which can facilitate
|
||||
* running Smack-3- and Smack-4-based clients on the same Openfire instance (Openfire will be configured to require
|
||||
* either the XMPP domain name, or the FQDN).
|
||||
*
|
||||
* @author Guus der Kinderen, guus.der.kinderen@gmail.com
|
||||
*/
|
||||
public class SASLGSSAPIv3CompatMechanism extends SASLGSSAPIMechanism
|
||||
{
|
||||
@Override
|
||||
protected String getServerName()
|
||||
{
|
||||
return super.serviceName;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,104 @@
|
||||
/**
|
||||
* $RCSfile: ,v $
|
||||
* $Revision: $
|
||||
* $Date: $
|
||||
*
|
||||
* Copyright (C) 2004-2011 Jive Software. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jivesoftware.spark.ui.login;
|
||||
|
||||
import javax.security.auth.login.AppConfigurationEntry;
|
||||
import javax.security.auth.login.Configuration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Vector;
|
||||
|
||||
|
||||
public class GSSAPIConfiguration extends Configuration
|
||||
{
|
||||
Map<String, Vector<AppConfigurationEntry>> configs;
|
||||
|
||||
public GSSAPIConfiguration()
|
||||
{
|
||||
super();
|
||||
init( true );
|
||||
}
|
||||
|
||||
public GSSAPIConfiguration( boolean config_from_file )
|
||||
{
|
||||
super();
|
||||
init( config_from_file );
|
||||
}
|
||||
|
||||
private void init( boolean config_from_file )
|
||||
{
|
||||
configs = new HashMap<>();
|
||||
|
||||
//The structure of the options is not well documented in terms of
|
||||
//data types. Since the file version of the Configuration object
|
||||
//puts things in quotes, String is assumed. But boolean options
|
||||
//do not have quotes, and my represent different types internally.
|
||||
HashMap<String, String> c_options = new HashMap<>();
|
||||
|
||||
//If Kerberos config is not from a file, it's not possible to (re-)read the config file.
|
||||
//So don't set refreshKrb5Config
|
||||
if ( config_from_file )
|
||||
{
|
||||
c_options.put( "refreshKrb5Config", "true" );
|
||||
}
|
||||
c_options.put( "doNotPrompt", "true" );
|
||||
c_options.put( "useTicketCache", "true" );
|
||||
c_options.put( "debug", "true" );
|
||||
|
||||
putAppConfigurationEntry( "com.sun.security.jgss.initiate", "com.sun.security.auth.module.Krb5LoginModule", AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, c_options );
|
||||
putAppConfigurationEntry( "com.sun.security.jgss.krb5.initiate", "com.sun.security.auth.module.Krb5LoginModule", AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, c_options );
|
||||
}
|
||||
|
||||
public AppConfigurationEntry[] getAppConfigurationEntry( String name )
|
||||
{
|
||||
AppConfigurationEntry[] a = new AppConfigurationEntry[ 1 ];
|
||||
if ( configs.containsKey( name ) )
|
||||
{
|
||||
Vector<AppConfigurationEntry> v = configs.get( name );
|
||||
a = v.toArray( a );
|
||||
return a;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean putAppConfigurationEntry( String name, String module, AppConfigurationEntry.LoginModuleControlFlag controlFlag, Map<String, String> options )
|
||||
{
|
||||
Vector<AppConfigurationEntry> v;
|
||||
if ( configs.containsKey( name ) )
|
||||
{
|
||||
v = configs.get( name );
|
||||
}
|
||||
else
|
||||
{
|
||||
v = new Vector<>();
|
||||
configs.put( name, v );
|
||||
}
|
||||
|
||||
return v.add( new AppConfigurationEntry( module, controlFlag, options ) );
|
||||
}
|
||||
|
||||
public void refresh()
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,252 @@
|
||||
package org.jivesoftware.spark.ui.login;
|
||||
|
||||
import org.jivesoftware.resource.Default;
|
||||
import org.jivesoftware.resource.Res;
|
||||
import org.jivesoftware.spark.util.ModelUtil;
|
||||
import org.jivesoftware.spark.util.ResourceUtils;
|
||||
import org.jivesoftware.sparkimpl.settings.JiveInfo;
|
||||
import org.jivesoftware.sparkimpl.settings.local.LocalPreferences;
|
||||
import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import static java.awt.GridBagConstraints.*;
|
||||
|
||||
/**
|
||||
* Internal class to set General settings
|
||||
*/
|
||||
class GeneralLoginSettingsPanel extends JPanel implements ActionListener
|
||||
{
|
||||
private final static Insets DEFAULT_INSETS = new Insets( 5, 5, 5, 5 );
|
||||
private final LocalPreferences localPreferences;
|
||||
private JDialog optionsDialog;
|
||||
private JCheckBox autoDiscoverBox = new JCheckBox();
|
||||
private JTextField portField = new JTextField();
|
||||
private JTextField xmppHostField = new JTextField();
|
||||
private JTextField timeOutField = new JTextField();
|
||||
private JTextField resourceField = new JTextField();
|
||||
private JCheckBox useHostnameAsResourceBox = new JCheckBox();
|
||||
private JCheckBox useVersionAsResourceBox = new JCheckBox();
|
||||
private JCheckBox useSSLBox = new JCheckBox();
|
||||
private JCheckBox compressionBox = new JCheckBox();
|
||||
private JCheckBox debuggerBox = new JCheckBox();
|
||||
private JCheckBox acceptAllCertificatesBox = new JCheckBox();
|
||||
|
||||
public GeneralLoginSettingsPanel( LocalPreferences localPreferences, JDialog optionsDialog )
|
||||
{
|
||||
this.localPreferences = localPreferences;
|
||||
this.optionsDialog = optionsDialog;
|
||||
JLabel portLabel = new JLabel();
|
||||
ResourceUtils.resLabel( portLabel, portField, Res.getString( "label.port" ) );
|
||||
JLabel timeOutLabel = new JLabel();
|
||||
ResourceUtils.resLabel( timeOutLabel, timeOutField, Res.getString( "label.response.timeout" ) );
|
||||
JCheckBox autoLoginBox = new JCheckBox();
|
||||
ResourceUtils.resButton( autoLoginBox, Res.getString( "label.auto.login" ) );
|
||||
ResourceUtils.resButton( useSSLBox, Res.getString( "label.old.ssl" ) );
|
||||
JLabel xmppHostLabel = new JLabel();
|
||||
ResourceUtils.resLabel( xmppHostLabel, xmppHostField, Res.getString( "label.host" ) );
|
||||
ResourceUtils.resButton( autoDiscoverBox, Res.getString( "checkbox.auto.discover.port" ) );
|
||||
JLabel resourceLabel = new JLabel();
|
||||
ResourceUtils.resLabel( resourceLabel, resourceField, Res.getString( "label.resource" ) );
|
||||
ResourceUtils.resButton( useHostnameAsResourceBox, Res.getString( "checkbox.use.hostname.as.resource" ) );
|
||||
ResourceUtils.resButton( useVersionAsResourceBox, Res.getString( "checkbox.use.version.as.resource" ) );
|
||||
ResourceUtils.resButton( compressionBox, Res.getString( "checkbox.use.compression" ) );
|
||||
ResourceUtils.resButton( debuggerBox, Res.getString( "checkbox.use.debugger.on.startup" ) );
|
||||
ResourceUtils.resButton( acceptAllCertificatesBox, Res.getString( "checkbox.accept.all.certificates" ) );
|
||||
|
||||
portField.setText( Integer.toString( localPreferences.getXmppPort() ) );
|
||||
timeOutField.setText( Integer.toString( localPreferences.getTimeOut() ) );
|
||||
autoLoginBox.setSelected( localPreferences.isAutoLogin() );
|
||||
useSSLBox.setSelected( localPreferences.isSSL() );
|
||||
xmppHostField.setText( localPreferences.getXmppHost() );
|
||||
resourceField.setText( localPreferences.getResource() );
|
||||
|
||||
useHostnameAsResourceBox.addActionListener( this );
|
||||
useHostnameAsResourceBox.setSelected( localPreferences.isUseHostnameAsResource() );
|
||||
updateResourceHostname();
|
||||
|
||||
useVersionAsResourceBox.addActionListener( this );
|
||||
useVersionAsResourceBox.setSelected( localPreferences.isUseVersionAsResource() );
|
||||
updateResourceVersion();
|
||||
|
||||
autoDiscoverBox.addActionListener( this );
|
||||
|
||||
autoDiscoverBox.setSelected( !localPreferences.isHostAndPortConfigured() );
|
||||
updateAutoDiscovery();
|
||||
|
||||
compressionBox.setSelected( localPreferences.isCompressionEnabled() );
|
||||
|
||||
debuggerBox.setSelected( localPreferences.isDebuggerEnabled() );
|
||||
|
||||
acceptAllCertificatesBox.setSelected( localPreferences.isAcceptAllCertificates() );
|
||||
|
||||
final JPanel connectionPanel = new JPanel();
|
||||
connectionPanel.setLayout( new GridBagLayout() );
|
||||
connectionPanel.setBorder( BorderFactory.createTitledBorder( Res.getString( "group.connection" ) ) );
|
||||
|
||||
setLayout( new GridBagLayout() );
|
||||
|
||||
add( autoDiscoverBox, new GridBagConstraints( 0, 0, 2, 1, 0.0, 0.0, WEST, NONE, DEFAULT_INSETS, 0, 0 ) );
|
||||
|
||||
connectionPanel.add( xmppHostLabel, new GridBagConstraints( 0, 0, 2, 1, 0.0, 0.0, WEST, NONE, DEFAULT_INSETS, 0, 0 ) );
|
||||
connectionPanel.add( xmppHostField, new GridBagConstraints( 2, 0, 1, 1, 0.0, 0.0, WEST, NONE, DEFAULT_INSETS, 200, 0 ) );
|
||||
connectionPanel.add( portLabel, new GridBagConstraints( 0, 1, 2, 1, 0.0, 0.0, WEST, NONE, DEFAULT_INSETS, 0, 0 ) );
|
||||
connectionPanel.add( portField, new GridBagConstraints( 2, 1, 1, 1, 0.0, 0.0, WEST, NONE, DEFAULT_INSETS, 50, 0 ) );
|
||||
|
||||
add( connectionPanel, new GridBagConstraints( 0, 1, 3, 1, 1.0, 1.0, WEST, BOTH, DEFAULT_INSETS, 0, 0 ) );
|
||||
|
||||
if ( Default.getBoolean( Default.HOSTNAME_AS_RESOURCE ) == Default.getBoolean( Default.VERSION_AS_RESOURCE ) )
|
||||
{
|
||||
add( resourceLabel, new GridBagConstraints( 0, 2, 1, 1, 0.0, 0.0, WEST, NONE, DEFAULT_INSETS, 0, 0 ) );
|
||||
add( resourceField, new GridBagConstraints( 1, 2, 1, 1, 0.0, 0.0, WEST, NONE, DEFAULT_INSETS, 100, 0 ) );
|
||||
add( useHostnameAsResourceBox, new GridBagConstraints( 0, 3, 2, 1, 0.0, 1.0, WEST, NONE, DEFAULT_INSETS, 0, 0 ) );
|
||||
add( useVersionAsResourceBox, new GridBagConstraints( 0, 4, 2, 1, 0.0, 1.0, WEST, NONE, DEFAULT_INSETS, 0, 0 ) );
|
||||
}
|
||||
add( timeOutLabel, new GridBagConstraints( 0, 5, 1, 1, 0.0, 0.0, WEST, NONE, DEFAULT_INSETS, 0, 0 ) );
|
||||
add( timeOutField, new GridBagConstraints( 1, 5, 1, 1, 0.0, 0.0, WEST, NONE, DEFAULT_INSETS, 50, 0 ) );
|
||||
add( useSSLBox, new GridBagConstraints( 0, 6, 2, 1, 0.0, 1.0, WEST, HORIZONTAL, DEFAULT_INSETS, 0, 0 ) );
|
||||
add( compressionBox, new GridBagConstraints( 0, 7, 2, 1, 0.0, 1.0, WEST, HORIZONTAL, DEFAULT_INSETS, 0, 0 ) );
|
||||
add( acceptAllCertificatesBox, new GridBagConstraints( 0, 8, 2, 1, 0.0, 1.0, WEST, HORIZONTAL, DEFAULT_INSETS, 0, 0 ) );
|
||||
add( debuggerBox, new GridBagConstraints( 0, 9, 2, 1, 0.0, 1.0, WEST, HORIZONTAL, DEFAULT_INSETS, 0, 0 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates local preferences with auto discovery settings.
|
||||
*/
|
||||
private void updateAutoDiscovery()
|
||||
{
|
||||
boolean isSelected = autoDiscoverBox.isSelected();
|
||||
xmppHostField.setEnabled( !isSelected );
|
||||
portField.setEnabled( !isSelected );
|
||||
localPreferences.setHostAndPortConfigured( !isSelected );
|
||||
SettingsManager.saveSettings();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates resource settings.
|
||||
*/
|
||||
private void updateResourceHostname()
|
||||
{
|
||||
boolean isSelected = useHostnameAsResourceBox.isSelected();
|
||||
try
|
||||
{
|
||||
if ( isSelected )
|
||||
{
|
||||
String resource = InetAddress.getLocalHost().getHostName();
|
||||
resourceField.setText( resource );
|
||||
useVersionAsResourceBox.setSelected( false );
|
||||
}
|
||||
resourceField.setEnabled( !isSelected );
|
||||
}
|
||||
catch ( UnknownHostException e )
|
||||
{
|
||||
UIManager.put( "OptionPane.okButtonText", Res.getString( "ok" ) );
|
||||
JOptionPane.showMessageDialog( optionsDialog,
|
||||
Res.getString( "message.unable.to.use.hostname.as.resource" ),
|
||||
Res.getString( "title.error" ),
|
||||
JOptionPane.ERROR_MESSAGE );
|
||||
}
|
||||
//localPreferences.setHostAndPortConfigured(!isSelected);
|
||||
SettingsManager.saveSettings();
|
||||
}
|
||||
|
||||
private void updateResourceVersion()
|
||||
{
|
||||
boolean isSelected = useVersionAsResourceBox.isSelected();
|
||||
if ( isSelected )
|
||||
{
|
||||
String resource = Default.getString( Default.APPLICATION_NAME ) + " " + JiveInfo.getVersion() + "." + Default.getString( Default.BUILD_NUMBER );
|
||||
resourceField.setText( resource );
|
||||
useHostnameAsResourceBox.setSelected( false );
|
||||
}
|
||||
resourceField.setEnabled( !isSelected );
|
||||
//localPreferences.setHostAndPortConfigured(!isSelected);
|
||||
SettingsManager.saveSettings();
|
||||
}
|
||||
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
if ( e.getSource() == autoDiscoverBox )
|
||||
{
|
||||
updateAutoDiscovery();
|
||||
}
|
||||
else if ( e.getSource() == useHostnameAsResourceBox )
|
||||
{
|
||||
updateResourceHostname();
|
||||
}
|
||||
else if ( e.getSource() == useVersionAsResourceBox )
|
||||
{
|
||||
updateResourceVersion();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean validate_settings()
|
||||
{
|
||||
String timeOut = timeOutField.getText();
|
||||
String port = portField.getText();
|
||||
String resource = resourceField.getText();
|
||||
|
||||
boolean valid = true;
|
||||
UIManager.put( "OptionPane.okButtonText", Res.getString( "ok" ) );
|
||||
|
||||
try
|
||||
{
|
||||
Integer.valueOf( timeOut );
|
||||
}
|
||||
catch ( NumberFormatException numberFormatException )
|
||||
{
|
||||
JOptionPane.showMessageDialog( optionsDialog,
|
||||
Res.getString( "message.supply.valid.timeout" ),
|
||||
Res.getString( "title.error" ),
|
||||
JOptionPane.ERROR_MESSAGE );
|
||||
timeOutField.requestFocus();
|
||||
valid = false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Integer.valueOf( port );
|
||||
}
|
||||
catch ( NumberFormatException numberFormatException )
|
||||
{
|
||||
JOptionPane.showMessageDialog( optionsDialog,
|
||||
Res.getString( "message.supply.valid.port" ),
|
||||
Res.getString( "title.error" ),
|
||||
JOptionPane.ERROR_MESSAGE );
|
||||
portField.requestFocus();
|
||||
valid = false;
|
||||
}
|
||||
|
||||
if ( !ModelUtil.hasLength( resource ) )
|
||||
{
|
||||
JOptionPane.showMessageDialog( optionsDialog,
|
||||
Res.getString( "message.supply.resource" ),
|
||||
Res.getString( "title.error" ),
|
||||
JOptionPane.ERROR_MESSAGE );
|
||||
resourceField.requestFocus();
|
||||
valid = false;
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
public void saveSettings()
|
||||
{
|
||||
localPreferences.setTimeOut( Integer.parseInt( timeOutField.getText() ) );
|
||||
localPreferences.setXmppPort( Integer.parseInt( portField.getText() ) );
|
||||
localPreferences.setSSL( useSSLBox.isSelected() );
|
||||
localPreferences.setXmppHost( xmppHostField.getText() );
|
||||
localPreferences.setCompressionEnabled( compressionBox.isSelected() );
|
||||
localPreferences.setDebuggerEnabled( debuggerBox.isSelected() );
|
||||
localPreferences.setResource( resourceField.getText() );
|
||||
localPreferences.setUseHostnameAsResource( useHostnameAsResourceBox.isSelected() );
|
||||
localPreferences.setUseVersionAsResource( useVersionAsResourceBox.isSelected() );
|
||||
localPreferences.setAcceptAllCertificates( acceptAllCertificatesBox.isSelected() );
|
||||
SettingsManager.saveSettings();
|
||||
}
|
||||
}
|
||||
159
src/java/org/jivesoftware/spark/ui/login/LoginSettingDialog.java
Normal file
159
src/java/org/jivesoftware/spark/ui/login/LoginSettingDialog.java
Normal file
@ -0,0 +1,159 @@
|
||||
/**
|
||||
* $RCSfile: ,v $
|
||||
* $Revision: $
|
||||
* $Date: $
|
||||
*
|
||||
* Copyright (C) 2004-2011 Jive Software. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jivesoftware.spark.ui.login;
|
||||
|
||||
import org.jivesoftware.resource.Default;
|
||||
import org.jivesoftware.resource.Res;
|
||||
import org.jivesoftware.resource.SparkRes;
|
||||
import org.jivesoftware.spark.component.TitlePanel;
|
||||
import org.jivesoftware.sparkimpl.settings.local.LocalPreferences;
|
||||
import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
|
||||
/**
|
||||
* Allows users to configure startup options.
|
||||
*
|
||||
* @author Derek DeMoro
|
||||
* @author Jay Kline
|
||||
*/
|
||||
public class LoginSettingDialog implements PropertyChangeListener
|
||||
{
|
||||
private JDialog optionsDialog;
|
||||
private JOptionPane optionPane;
|
||||
|
||||
private GeneralLoginSettingsPanel generalPanel;
|
||||
private ProxyLoginSettingsPanel proxyPanel;
|
||||
private PkiLoginSettingsPanel pkiPanel;
|
||||
private SsoLoginSettingsPanel ssoPanel;
|
||||
|
||||
/**
|
||||
* Empty Constructor.
|
||||
*/
|
||||
public LoginSettingDialog()
|
||||
{
|
||||
LocalPreferences localPreferences = SettingsManager.getLocalPreferences();
|
||||
generalPanel = new GeneralLoginSettingsPanel( localPreferences, optionsDialog );
|
||||
proxyPanel = new ProxyLoginSettingsPanel( localPreferences, optionsDialog );
|
||||
ssoPanel = new SsoLoginSettingsPanel( localPreferences, optionsDialog );
|
||||
pkiPanel = new PkiLoginSettingsPanel( localPreferences, optionsDialog );
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes the OptionsDialog.
|
||||
*
|
||||
* @param owner the parent owner of this dialog. This is used for correct
|
||||
* parenting.
|
||||
* @return true if the options have been changed.
|
||||
*/
|
||||
public boolean invoke( JFrame owner )
|
||||
{
|
||||
JTabbedPane tabbedPane = new JTabbedPane();
|
||||
TitlePanel titlePanel;
|
||||
|
||||
// Create the title panel for this dialog
|
||||
titlePanel = new TitlePanel( Res.getString( "title.advanced.connection.preferences" ), "", SparkRes.getImageIcon( SparkRes.BLANK_24x24 ), true );
|
||||
tabbedPane.addTab( Res.getString( "tab.general" ), generalPanel );
|
||||
if ( !Default.getBoolean( Default.PROXY_DISABLED ) )
|
||||
{
|
||||
tabbedPane.addTab( Res.getString( "tab.proxy" ), proxyPanel );
|
||||
}
|
||||
if ( !Default.getBoolean( Default.SSO_DISABLED ) )
|
||||
{
|
||||
tabbedPane.addTab( Res.getString( "tab.sso" ), ssoPanel );
|
||||
}
|
||||
if ( !Default.getBoolean( Default.PKI_DISABLED ) )
|
||||
{
|
||||
tabbedPane.addTab( Res.getString( "tab.pki" ), pkiPanel );
|
||||
}
|
||||
|
||||
// Construct main panel w/ layout.
|
||||
final JPanel mainPanel = new JPanel();
|
||||
mainPanel.setLayout( new BorderLayout() );
|
||||
mainPanel.add( titlePanel, BorderLayout.NORTH );
|
||||
|
||||
// The user should only be able to close this dialog.
|
||||
Object[] options = { Res.getString( "ok" ), Res.getString( "cancel" ), Res.getString( "use.default" ) };
|
||||
optionPane = new JOptionPane( tabbedPane, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, options, options[ 0 ] );
|
||||
|
||||
mainPanel.add( optionPane, BorderLayout.CENTER );
|
||||
|
||||
optionsDialog = new JDialog( owner, Res.getString( "title.preferences" ), true );
|
||||
optionsDialog.setContentPane( mainPanel );
|
||||
optionsDialog.pack();
|
||||
|
||||
optionsDialog.setLocationRelativeTo( owner );
|
||||
optionPane.addPropertyChangeListener( this );
|
||||
|
||||
optionsDialog.setResizable( false );
|
||||
optionsDialog.setVisible( true );
|
||||
optionsDialog.toFront();
|
||||
optionsDialog.requestFocus();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* PropertyChangeEvent is called when the user either clicks the Cancel or
|
||||
* OK button.
|
||||
*
|
||||
* @param e the property change event.
|
||||
*/
|
||||
public void propertyChange( PropertyChangeEvent e )
|
||||
{
|
||||
String value = (String) optionPane.getValue();
|
||||
if ( Res.getString( "cancel" ).equals( value ) )
|
||||
{
|
||||
optionsDialog.setVisible( false );
|
||||
}
|
||||
else if ( Res.getString( "ok" ).equals( value ) )
|
||||
{
|
||||
|
||||
boolean valid = generalPanel.validate_settings();
|
||||
valid = valid && proxyPanel.validate_settings();
|
||||
valid = valid && ssoPanel.validate_settings();
|
||||
valid = valid && pkiPanel.validate_settings();
|
||||
|
||||
if ( valid )
|
||||
{
|
||||
generalPanel.saveSettings();
|
||||
proxyPanel.saveSettings();
|
||||
ssoPanel.saveSettings();
|
||||
pkiPanel.saveSettings();
|
||||
SettingsManager.saveSettings();
|
||||
optionsDialog.setVisible( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
optionPane.removePropertyChangeListener( this );
|
||||
optionPane.setValue( JOptionPane.UNINITIALIZED_VALUE );
|
||||
optionPane.addPropertyChangeListener( this );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Some unknown operation happened
|
||||
optionPane.setValue( JOptionPane.UNINITIALIZED_VALUE );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,277 @@
|
||||
package org.jivesoftware.spark.ui.login;
|
||||
|
||||
import org.jivesoftware.resource.Res;
|
||||
import org.jivesoftware.spark.util.ModelUtil;
|
||||
import org.jivesoftware.spark.util.ResourceUtils;
|
||||
import org.jivesoftware.sparkimpl.settings.local.LocalPreferences;
|
||||
import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
|
||||
import static java.awt.GridBagConstraints.*;
|
||||
|
||||
/**
|
||||
* Internal class to set PKI settings
|
||||
*/
|
||||
|
||||
class PkiLoginSettingsPanel extends JPanel implements ActionListener
|
||||
{
|
||||
private final static Insets DEFAULT_INSETS = new Insets( 5, 5, 5, 5 );
|
||||
private final LocalPreferences localPreferences;
|
||||
private JCheckBox usePKIBox = new JCheckBox();
|
||||
private JComboBox<String> pkiStore = new JComboBox<>();
|
||||
private JFileChooser fileChooser = new JFileChooser();
|
||||
private JButton fileButton = new JButton();
|
||||
private JTextField fileField = new JTextField();
|
||||
private JPanel filePanel = new JPanel();
|
||||
private JPasswordField trustStorePassword = new JPasswordField();
|
||||
private JTextField trustStoreField = new JTextField();
|
||||
private JButton trustStoreButton = new JButton();
|
||||
private JDialog optionsDialog;
|
||||
|
||||
public PkiLoginSettingsPanel( LocalPreferences localPreferences, JDialog optionsDialog )
|
||||
{
|
||||
this.localPreferences = localPreferences;
|
||||
this.optionsDialog = optionsDialog;
|
||||
ResourceUtils.resButton( usePKIBox, Res.getString( "checkbox.use.pki.authentication" ) );
|
||||
JLabel pkiStoreLabel = new JLabel();
|
||||
ResourceUtils.resLabel( pkiStoreLabel, pkiStore, Res.getString( "label.which.pki.method" ) );
|
||||
ResourceUtils.resButton( fileButton, Res.getString( "label.choose.file" ) );
|
||||
ResourceUtils.resButton( trustStoreButton, Res.getString( "label.choose.file" ) );
|
||||
JLabel trustStorePasswordLabel = new JLabel();
|
||||
ResourceUtils.resLabel( trustStorePasswordLabel, trustStorePassword, Res.getString( "label.trust.store.password" ) );
|
||||
|
||||
pkiStore.addItem( "Java Keystore" );
|
||||
pkiStore.addItem( "PKCS#11" );
|
||||
// pkiStore.addItem("X.509 PEM File");
|
||||
pkiStore.addItem( "Apple KeyChain" );
|
||||
|
||||
usePKIBox.setSelected( localPreferences.isPKIEnabled() );
|
||||
|
||||
if ( ModelUtil.hasLength( localPreferences.getPKIStore() ) )
|
||||
{
|
||||
if ( localPreferences.getPKIStore().equals( "PKCS11" ) )
|
||||
{
|
||||
pkiStore.setSelectedItem( "PKCS#11" );
|
||||
if ( ModelUtil.hasLength( localPreferences.getPKCS11Library() ) )
|
||||
{
|
||||
fileField.setText( localPreferences.getPKCS11Library() );
|
||||
}
|
||||
else
|
||||
{
|
||||
fileField.setText( "" );
|
||||
}
|
||||
}
|
||||
else if ( localPreferences.getPKIStore().equals( "X509" ) )
|
||||
{
|
||||
pkiStore.setSelectedItem( "X.509 PEM File" );
|
||||
// if(ModelUtil.hasLength(localPreferences.getPEMFile())) {
|
||||
// fileField.setText(localPreferences.getPEMFile());
|
||||
// }
|
||||
// else {
|
||||
fileField.setText( "" );
|
||||
// }
|
||||
}
|
||||
else if ( localPreferences.getPKIStore().equals( "Apple KeyChain" ) )
|
||||
{
|
||||
fileField.setText( "" );
|
||||
}
|
||||
else
|
||||
{
|
||||
pkiStore.setSelectedItem( "Java Keystore" );
|
||||
if ( ModelUtil.hasLength( localPreferences.getJKSPath() ) )
|
||||
{
|
||||
fileField.setText( localPreferences.getJKSPath() );
|
||||
}
|
||||
else
|
||||
{
|
||||
fileField.setText( "" );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pkiStore.setSelectedItem( "Java Keystore" );
|
||||
if ( ModelUtil.hasLength( localPreferences.getJKSPath() ) )
|
||||
{
|
||||
fileField.setText( localPreferences.getJKSPath() );
|
||||
}
|
||||
else
|
||||
{
|
||||
fileField.setText( "" );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ModelUtil.hasLength( localPreferences.getTrustStorePath() ) )
|
||||
{
|
||||
trustStoreField.setText( localPreferences.getTrustStorePath() );
|
||||
}
|
||||
|
||||
if ( ModelUtil.hasLength( localPreferences.getTrustStorePassword() ) )
|
||||
{
|
||||
trustStorePassword.setText( localPreferences.getTrustStorePassword() );
|
||||
}
|
||||
|
||||
pkiStore.setEnabled( usePKIBox.isSelected() );
|
||||
filePanel.setEnabled( usePKIBox.isSelected() );
|
||||
fileField.setEnabled( usePKIBox.isSelected() );
|
||||
fileButton.setEnabled( usePKIBox.isSelected() );
|
||||
|
||||
setLayout( new GridBagLayout() );
|
||||
|
||||
JLabel usePKILabel = new JLabel();
|
||||
|
||||
add( usePKIBox, new GridBagConstraints( 0, 0, 1, 1, 0.0, 0.0, NORTHWEST, NONE, DEFAULT_INSETS, 0, 0 ) );
|
||||
add( usePKILabel, new GridBagConstraints( 1, 0, 1, 1, 0.0, 0.0, NORTHWEST, NONE, DEFAULT_INSETS, 0, 0 ) );
|
||||
add( pkiStoreLabel, new GridBagConstraints( 0, 1, 1, 1, 0.0, 0.0, NORTHWEST, NONE, DEFAULT_INSETS, 0, 0 ) );
|
||||
add( pkiStore, new GridBagConstraints( 1, 1, 1, 1, 0.0, 0.0, NORTHWEST, NONE, DEFAULT_INSETS, 0, 0 ) );
|
||||
|
||||
filePanel.setLayout( new GridBagLayout() );
|
||||
filePanel.setBorder( BorderFactory.createTitledBorder( Res.getString( "label.keystore.location" ) ) );
|
||||
filePanel.add( fileField, new GridBagConstraints( 0, 0, 1, 1, 0.0, 0.0, NORTHWEST, HORIZONTAL, DEFAULT_INSETS, 100, 0 ) );
|
||||
filePanel.add( fileButton, new GridBagConstraints( 1, 0, 1, 1, 0.0, 0.0, NORTHWEST, NONE, DEFAULT_INSETS, 0, 0 ) );
|
||||
|
||||
add( filePanel, new GridBagConstraints( 0, 2, 2, 1, 0.0, 0.0, NORTHWEST, HORIZONTAL, DEFAULT_INSETS, 150, 0 ) );
|
||||
|
||||
JPanel trustStorePanel = new JPanel();
|
||||
trustStorePanel.setLayout( new GridBagLayout() );
|
||||
trustStorePanel.setBorder( BorderFactory.createTitledBorder( Res.getString( "label.truststore.location" ) ) );
|
||||
trustStorePanel.add( trustStoreField, new GridBagConstraints( 0, 0, 1, 1, 0.0, 0.0, NORTHWEST, HORIZONTAL, DEFAULT_INSETS, 100, 0 ) );
|
||||
trustStorePanel.add( trustStoreButton, new GridBagConstraints( 1, 0, 1, 1, 0.0, 0.0, NORTHWEST, NONE, DEFAULT_INSETS, 0, 0 ) );
|
||||
trustStorePanel.add( trustStorePasswordLabel, new GridBagConstraints( 0, 1, 1, 1, 0.0, 0.0, NORTHWEST, NONE, DEFAULT_INSETS, 0, 0 ) );
|
||||
trustStorePanel.add( trustStorePassword, new GridBagConstraints( 1, 1, 1, 1, 0.0, 0.0, NORTHWEST, HORIZONTAL, DEFAULT_INSETS, 100, 0 ) );
|
||||
|
||||
add( trustStorePanel, new GridBagConstraints( 0, 3, 2, 1, 0.0, 0.0, NORTHWEST, HORIZONTAL, DEFAULT_INSETS, 150, 0 ) );
|
||||
|
||||
usePKIBox.addActionListener( this );
|
||||
pkiStore.addActionListener( this );
|
||||
fileButton.addActionListener( this );
|
||||
trustStoreButton.addActionListener( this );
|
||||
}
|
||||
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
if ( e.getSource() == usePKIBox )
|
||||
{
|
||||
pkiStore.setEnabled( usePKIBox.isSelected() );
|
||||
filePanel.setEnabled( usePKIBox.isSelected() );
|
||||
fileField.setEnabled( usePKIBox.isSelected() );
|
||||
fileButton.setEnabled( usePKIBox.isSelected() );
|
||||
}
|
||||
else if ( e.getSource() == pkiStore )
|
||||
{
|
||||
if ( ( pkiStore.getSelectedItem() ).equals( "PKCS#11" ) )
|
||||
{
|
||||
filePanel.setBorder( BorderFactory.createTitledBorder( Res.getString( "label.pkcs.library.file" ) ) );
|
||||
if ( ModelUtil.hasLength( localPreferences.getPKCS11Library() ) )
|
||||
{
|
||||
fileField.setText( localPreferences.getPKCS11Library() );
|
||||
}
|
||||
else
|
||||
{
|
||||
fileField.setText( "" );
|
||||
}
|
||||
}
|
||||
else if ( ( pkiStore.getSelectedItem() )
|
||||
.equals( "X.509 PEM File" ) )
|
||||
{
|
||||
filePanel.setBorder( BorderFactory.createTitledBorder( Res.getString( "label.x509.certificate" ) ) );
|
||||
// if(ModelUtil.hasLength(localPreferences.getPEMFile())) {
|
||||
// fileField.setText(localPreferences.getPEMFile());
|
||||
// } else {
|
||||
// fileField.setText("");
|
||||
// }
|
||||
}
|
||||
else if ( ( pkiStore.getSelectedItem() )
|
||||
.equals( "Apple KeyChain" ) )
|
||||
{
|
||||
filePanel.setBorder( BorderFactory.createTitledBorder( Res.getString( "label.apple.keychain" ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
filePanel.setBorder( BorderFactory.createTitledBorder( Res.getString( "label.keystore.location" ) ) );
|
||||
if ( ModelUtil.hasLength( localPreferences.getJKSPath() ) )
|
||||
{
|
||||
fileField.setText( localPreferences.getJKSPath() );
|
||||
}
|
||||
else
|
||||
{
|
||||
fileField.setText( "" );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( e.getSource() == fileButton )
|
||||
{
|
||||
int retval = fileChooser.showOpenDialog( this );
|
||||
if ( retval == JFileChooser.APPROVE_OPTION )
|
||||
{
|
||||
File file = fileChooser.getSelectedFile();
|
||||
fileField.setText( file.getAbsolutePath() );
|
||||
}
|
||||
}
|
||||
else if ( e.getSource() == trustStoreButton )
|
||||
{
|
||||
int retVal = fileChooser.showOpenDialog( this );
|
||||
if ( retVal == JFileChooser.APPROVE_OPTION )
|
||||
{
|
||||
File file = fileChooser.getSelectedFile();
|
||||
trustStoreField.setText( file.getAbsolutePath() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean validate_settings()
|
||||
{
|
||||
|
||||
boolean valid = true;
|
||||
UIManager.put( "OptionPane.okButtonText", Res.getString( "ok" ) );
|
||||
|
||||
if ( usePKIBox.isSelected() )
|
||||
{
|
||||
if ( !ModelUtil.hasLength( fileField.getText() ) )
|
||||
{
|
||||
JOptionPane.showMessageDialog( optionsDialog,
|
||||
"You must specify a file location",
|
||||
Res.getString( "title.error" ),
|
||||
JOptionPane.ERROR_MESSAGE );
|
||||
fileField.requestFocus();
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
|
||||
public void saveSettings()
|
||||
{
|
||||
|
||||
localPreferences.setPKIEnabled( usePKIBox.isSelected() );
|
||||
localPreferences.setPKIStore( (String) pkiStore.getSelectedItem() );
|
||||
if ( ( pkiStore.getSelectedItem() ).equals( "PKCS#11" ) )
|
||||
{
|
||||
localPreferences.setPKIStore( "PKCS11" );
|
||||
localPreferences.setPKCS11Library( fileField.getText() );
|
||||
}
|
||||
else if ( ( pkiStore.getSelectedItem() ).equals( "X.509 Certificate" ) )
|
||||
{
|
||||
localPreferences.setPKIStore( "X509" );
|
||||
// localPreferences.setPEMFile(fileField.getText());
|
||||
}
|
||||
else if ( ( pkiStore.getSelectedItem() ).equals( "Apple KeyChain" ) )
|
||||
{
|
||||
localPreferences.setPKIStore( "Apple" );
|
||||
}
|
||||
else
|
||||
{
|
||||
localPreferences.setPKIStore( "JKS" );
|
||||
localPreferences.setJKSPath( fileField.getText() );
|
||||
}
|
||||
localPreferences.setTrustStorePath( trustStoreField.getText() );
|
||||
localPreferences.setTrustStorePassword( new String(
|
||||
trustStorePassword.getPassword() ) );
|
||||
SettingsManager.saveSettings();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,310 @@
|
||||
package org.jivesoftware.spark.ui.login;
|
||||
|
||||
import org.jivesoftware.resource.Default;
|
||||
import org.jivesoftware.resource.Res;
|
||||
import org.jivesoftware.spark.util.ModelUtil;
|
||||
import org.jivesoftware.spark.util.ResourceUtils;
|
||||
import org.jivesoftware.sparkimpl.settings.local.LocalPreferences;
|
||||
import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.Properties;
|
||||
|
||||
import static java.awt.GridBagConstraints.*;
|
||||
|
||||
/**
|
||||
* Internal class to allow setting of proxies within Spark.
|
||||
*/
|
||||
class ProxyLoginSettingsPanel extends JPanel
|
||||
{
|
||||
private final static Insets DEFAULT_INSETS = new Insets( 5, 5, 5, 5 );
|
||||
private final LocalPreferences localPreferences;
|
||||
private JCheckBox useProxyBox = new JCheckBox();
|
||||
private JComboBox<String> protocolBox = new JComboBox<>();
|
||||
private JTextField hostField = new JTextField();
|
||||
private JTextField portField = new JTextField();
|
||||
private JTextField usernameField = new JTextField();
|
||||
private JPasswordField passwordField = new JPasswordField();
|
||||
private JDialog optionsDialog;
|
||||
|
||||
public ProxyLoginSettingsPanel( LocalPreferences localPreferences, JDialog optionsDialog )
|
||||
{
|
||||
this.localPreferences = localPreferences;
|
||||
this.optionsDialog = optionsDialog;
|
||||
final JLabel protocolLabel = new JLabel();
|
||||
final JLabel hostLabel = new JLabel();
|
||||
final JLabel portLabel = new JLabel();
|
||||
final JLabel usernameLabel = new JLabel();
|
||||
final JLabel passwordLabel = new JLabel();
|
||||
|
||||
protocolBox.addItem( "SOCKS" );
|
||||
protocolBox.addItem( "HTTP" );
|
||||
|
||||
ResourceUtils.resButton( useProxyBox, Res.getString( "checkbox.use.proxy.server" ) );
|
||||
ResourceUtils.resLabel( protocolLabel, protocolBox, Res.getString( "label.protocol" ) );
|
||||
ResourceUtils.resLabel( hostLabel, hostField, Res.getString( "label.host" ) );
|
||||
ResourceUtils.resLabel( portLabel, portField, Res.getString( "label.port" ) );
|
||||
ResourceUtils.resLabel( usernameLabel, usernameField, Res.getString( "label.username" ) );
|
||||
ResourceUtils.resLabel( passwordLabel, passwordField, Res.getString( "label.password" ) );
|
||||
|
||||
setLayout( new GridBagLayout() );
|
||||
add( useProxyBox, new GridBagConstraints( 0, 0, 2, 1, 1.0, 0.0, NORTHWEST, NONE, DEFAULT_INSETS, 0, 0 ) );
|
||||
add( protocolLabel, new GridBagConstraints( 0, 1, 1, 1, 0.0, 0.0, NORTHWEST, NONE, DEFAULT_INSETS, 0, 0 ) );
|
||||
add( protocolBox, new GridBagConstraints( 1, 1, 1, 1, 1.0, 0.0, NORTHWEST, HORIZONTAL, DEFAULT_INSETS, 0, 0 ) );
|
||||
add( hostLabel, new GridBagConstraints( 0, 2, 1, 1, 0.0, 0.0, NORTHWEST, NONE, DEFAULT_INSETS, 0, 0 ) );
|
||||
add( hostField, new GridBagConstraints( 1, 2, 1, 1, 1.0, 0.0, NORTHWEST, HORIZONTAL, DEFAULT_INSETS, 0, 0 ) );
|
||||
add( portLabel, new GridBagConstraints( 0, 3, 1, 1, 0.0, 0.0, NORTHWEST, NONE, DEFAULT_INSETS, 0, 0 ) );
|
||||
add( portField, new GridBagConstraints( 1, 3, 1, 1, 1.0, 0.0, NORTHWEST, HORIZONTAL, DEFAULT_INSETS, 0, 0 ) );
|
||||
add( usernameLabel, new GridBagConstraints( 0, 4, 1, 1, 0.0, 0.0, NORTHWEST, NONE, DEFAULT_INSETS, 0, 0 ) );
|
||||
add( usernameField, new GridBagConstraints( 1, 4, 1, 1, 1.0, 0.0, NORTHWEST, HORIZONTAL, DEFAULT_INSETS, 0, 0 ) );
|
||||
add( passwordLabel, new GridBagConstraints( 0, 5, 1, 1, 0.0, 0.0, NORTHWEST, NONE, DEFAULT_INSETS, 0, 0 ) );
|
||||
add( passwordField, new GridBagConstraints( 1, 5, 1, 1, 1.0, 0.0, NORTHWEST, HORIZONTAL, DEFAULT_INSETS, 0, 0 ) );
|
||||
|
||||
useProxyBox.addActionListener( e -> enableFields( useProxyBox.isSelected() ) );
|
||||
|
||||
// Check localSettings
|
||||
if ( localPreferences.isProxyEnabled() )
|
||||
{
|
||||
useProxyBox.setSelected( true );
|
||||
}
|
||||
|
||||
enableFields( useProxyBox.isSelected() );
|
||||
|
||||
if ( ModelUtil.hasLength( localPreferences.getHost() ) )
|
||||
{
|
||||
hostField.setText( localPreferences.getHost() );
|
||||
}
|
||||
|
||||
if ( ModelUtil.hasLength( localPreferences.getPort() ) )
|
||||
{
|
||||
portField.setText( localPreferences.getPort() );
|
||||
}
|
||||
|
||||
if ( ModelUtil.hasLength( localPreferences.getProxyPassword() ) )
|
||||
{
|
||||
passwordField.setText( localPreferences.getProxyPassword() );
|
||||
}
|
||||
|
||||
if ( ModelUtil.hasLength( localPreferences.getProxyUsername() ) )
|
||||
{
|
||||
usernameField.setText( localPreferences.getProxyUsername() );
|
||||
}
|
||||
|
||||
if ( ModelUtil.hasLength( localPreferences.getProtocol() ) )
|
||||
{
|
||||
protocolBox.setSelectedItem( localPreferences.getProtocol() );
|
||||
}
|
||||
|
||||
if ( Default.getString( "PROXY_PROTOCOL" ).length() > 0 )
|
||||
{
|
||||
protocolBox.setSelectedItem( Default.getString( "PROXY_PROTOCOL" ) );
|
||||
protocolBox.setEnabled( false );
|
||||
useProxyBox.setSelected( true );
|
||||
useProxyBox.setVisible( false );
|
||||
}
|
||||
if ( Default.getString( "PROXY_HOST" ).length() > 0 )
|
||||
{
|
||||
hostField.setText( Default.getString( "PROXY_HOST" ) );
|
||||
hostField.setEnabled( false );
|
||||
useProxyBox.setSelected( true );
|
||||
useProxyBox.setVisible( false );
|
||||
}
|
||||
if ( Default.getString( "PROXY_PORT" ).length() > 0 )
|
||||
{
|
||||
portField.setText( Default.getString( "PROXY_PORT" ) );
|
||||
portField.setEnabled( false );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the fields of the proxy panel.
|
||||
*
|
||||
* @param enable true if all fields should be enabled, otherwise false.
|
||||
*/
|
||||
private void enableFields( boolean enable )
|
||||
{
|
||||
Component[] comps = getComponents();
|
||||
for ( Component comp1 : comps )
|
||||
{
|
||||
if ( comp1 instanceof JTextField || comp1 instanceof JComboBox )
|
||||
{
|
||||
JComponent comp = (JComponent) comp1;
|
||||
comp.setEnabled( enable );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the protocol to use for this proxy.
|
||||
*
|
||||
* @return the protocol.
|
||||
*/
|
||||
public String getProtocol()
|
||||
{
|
||||
return (String) protocolBox.getSelectedItem();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the host to use for this proxy.
|
||||
*
|
||||
* @return the host.
|
||||
*/
|
||||
public String getHost()
|
||||
{
|
||||
return hostField.getText();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the port to use with this proxy.
|
||||
*
|
||||
* @return the port to use.
|
||||
*/
|
||||
public String getPort()
|
||||
{
|
||||
return portField.getText();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the username to use with this proxy.
|
||||
*
|
||||
* @return the username.
|
||||
*/
|
||||
public String getUsername()
|
||||
{
|
||||
return usernameField.getText();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the password to use with this proxy.
|
||||
*
|
||||
* @return the password.
|
||||
*/
|
||||
public String getPassword()
|
||||
{
|
||||
return new String( passwordField.getPassword() );
|
||||
}
|
||||
|
||||
public boolean validate_settings()
|
||||
{
|
||||
boolean valid = true;
|
||||
|
||||
UIManager.put( "OptionPane.okButtonText", Res.getString( "ok" ) );
|
||||
|
||||
if ( useProxyBox.isSelected() )
|
||||
{
|
||||
try
|
||||
{
|
||||
Integer.valueOf( portField.getText() );
|
||||
}
|
||||
catch ( NumberFormatException numberFormatException )
|
||||
{
|
||||
JOptionPane.showMessageDialog( optionsDialog,
|
||||
Res.getString( "message.supply.valid.port" ),
|
||||
Res.getString( "title.error" ),
|
||||
JOptionPane.ERROR_MESSAGE );
|
||||
portField.requestFocus();
|
||||
valid = false;
|
||||
}
|
||||
|
||||
if ( !ModelUtil.hasLength( hostField.getText() ) )
|
||||
{
|
||||
JOptionPane.showMessageDialog( optionsDialog,
|
||||
Res.getString( "message.supply.valid.host" ),
|
||||
Res.getString( "title.error" ),
|
||||
JOptionPane.ERROR_MESSAGE );
|
||||
hostField.requestFocus();
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Persist the proxy settings to local preferences.
|
||||
*/
|
||||
public void saveSettings()
|
||||
{
|
||||
localPreferences.setProxyEnabled( useProxyBox.isSelected() );
|
||||
|
||||
if ( ModelUtil.hasLength( getProtocol() ) )
|
||||
{
|
||||
localPreferences.setProtocol( getProtocol() );
|
||||
}
|
||||
|
||||
if ( ModelUtil.hasLength( getHost() ) )
|
||||
{
|
||||
localPreferences.setHost( getHost() );
|
||||
}
|
||||
|
||||
if ( ModelUtil.hasLength( getPort() ) )
|
||||
{
|
||||
localPreferences.setPort( getPort() );
|
||||
}
|
||||
|
||||
if ( getUsername().equals( "" ) || getUsername() == null )
|
||||
{
|
||||
localPreferences.setProxyUsername( "" );
|
||||
}
|
||||
|
||||
if ( ModelUtil.hasLength( getUsername() ) )
|
||||
{
|
||||
localPreferences.setProxyUsername( getUsername() );
|
||||
}
|
||||
|
||||
if ( getPassword().equals( "" ) || getPassword() == null )
|
||||
{
|
||||
localPreferences.setProxyPassword( "" );
|
||||
}
|
||||
|
||||
if ( ModelUtil.hasLength( getPassword() ) )
|
||||
{
|
||||
localPreferences.setProxyPassword( getPassword() );
|
||||
}
|
||||
|
||||
if ( !localPreferences.isProxyEnabled() )
|
||||
{
|
||||
Properties props = System.getProperties();
|
||||
props.remove( "socksProxyHost" );
|
||||
props.remove( "socksProxyPort" );
|
||||
props.remove( "http.proxyHost" );
|
||||
props.remove( "http.proxyPort" );
|
||||
props.remove( "http.proxySet" );
|
||||
}
|
||||
else
|
||||
{
|
||||
String host = localPreferences.getHost();
|
||||
String port = localPreferences.getPort();
|
||||
String protocol = localPreferences.getProtocol();
|
||||
|
||||
boolean isValid = ModelUtil.hasLength( host ) && ModelUtil.hasLength( port );
|
||||
|
||||
if ( isValid )
|
||||
{
|
||||
if ( protocol.equals( "SOCKS" ) )
|
||||
{
|
||||
System.setProperty( "socksProxyHost", host );
|
||||
System.setProperty( "socksProxyPort", port );
|
||||
}
|
||||
else
|
||||
{
|
||||
System.setProperty( "http.proxySet", "true" );
|
||||
|
||||
// Set https settings
|
||||
System.setProperty( "https.proxyHost", host );
|
||||
System.setProperty( "https.proxyPort", port );
|
||||
|
||||
// Set http settings
|
||||
System.setProperty( "http.proxyHost", host );
|
||||
System.setProperty( "http.proxyPort", port );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
localPreferences.setProxyEnabled( false );
|
||||
}
|
||||
}
|
||||
SettingsManager.saveSettings();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,258 @@
|
||||
package org.jivesoftware.spark.ui.login;
|
||||
|
||||
import org.jivesoftware.resource.Res;
|
||||
import org.jivesoftware.spark.component.WrappedLabel;
|
||||
import org.jivesoftware.spark.util.ModelUtil;
|
||||
import org.jivesoftware.spark.util.ResourceUtils;
|
||||
import org.jivesoftware.spark.util.log.Log;
|
||||
import org.jivesoftware.sparkimpl.settings.local.LocalPreferences;
|
||||
import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
|
||||
|
||||
import javax.security.auth.Subject;
|
||||
import javax.security.auth.login.Configuration;
|
||||
import javax.security.auth.login.LoginContext;
|
||||
import javax.security.auth.login.LoginException;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.security.Principal;
|
||||
|
||||
import static java.awt.GridBagConstraints.*;
|
||||
|
||||
/**
|
||||
* Internal class to set SSO settings
|
||||
*/
|
||||
class SsoLoginSettingsPanel extends JPanel implements ActionListener
|
||||
{
|
||||
private final static Insets DEFAULT_INSETS = new Insets( 5, 5, 5, 5 );
|
||||
private final LocalPreferences localPreferences;
|
||||
private JCheckBox useSSOBox = new JCheckBox();
|
||||
private JTextField realmField = new JTextField();
|
||||
private JTextField kdcField = new JTextField();
|
||||
private JRadioButton methodFileRadio = new JRadioButton();
|
||||
private JRadioButton methodDNSRadio = new JRadioButton();
|
||||
private JRadioButton methodManualRadio = new JRadioButton();
|
||||
private JCheckBox useSaslGssapiSmack3compatBox = new JCheckBox();
|
||||
private JDialog optionsDialog;
|
||||
|
||||
public SsoLoginSettingsPanel( LocalPreferences localPreferences, JDialog optionsDialog )
|
||||
{
|
||||
this.localPreferences = localPreferences;
|
||||
this.optionsDialog = optionsDialog;
|
||||
|
||||
ResourceUtils.resButton( useSSOBox, Res.getString( "title.advanced.connection.usesso" ) );
|
||||
useSSOBox.addActionListener( this );
|
||||
ResourceUtils.resButton( useSaslGssapiSmack3compatBox, Res.getString( "title.advanced.connection.sso.smack3compat" ) );
|
||||
useSaslGssapiSmack3compatBox.addActionListener( this );
|
||||
|
||||
final WrappedLabel wrappedLabel = new WrappedLabel();
|
||||
String principalName = null;
|
||||
try
|
||||
{
|
||||
principalName = getPrincipalName();
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
// Ignore
|
||||
}
|
||||
|
||||
if ( ModelUtil.hasLength( principalName ) )
|
||||
{
|
||||
wrappedLabel.setText( Res.getString( "title.advanced.connection.sso.account", principalName ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
wrappedLabel.setForeground( Color.RED );
|
||||
wrappedLabel.setText( Res.getString( "title.advanced.connection.sso.noprincipal" ) );
|
||||
}
|
||||
wrappedLabel.setBackground( Color.white );
|
||||
|
||||
final String method = localPreferences.getSSOMethod();
|
||||
if ( ModelUtil.hasLength( method ) )
|
||||
{
|
||||
switch ( method )
|
||||
{
|
||||
case "file":
|
||||
methodFileRadio.setSelected( true );
|
||||
break;
|
||||
case "dns":
|
||||
methodDNSRadio.setSelected( true );
|
||||
break;
|
||||
case "manual":
|
||||
methodManualRadio.setSelected( true );
|
||||
break;
|
||||
default:
|
||||
methodFileRadio.setSelected( true );
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
methodFileRadio.setSelected( true );
|
||||
}
|
||||
|
||||
if ( ModelUtil.hasLength( localPreferences.getSSORealm() ) )
|
||||
{
|
||||
realmField.setText( localPreferences.getSSORealm() );
|
||||
}
|
||||
if ( ModelUtil.hasLength( localPreferences.getSSOKDC() ) )
|
||||
{
|
||||
kdcField.setText( localPreferences.getSSOKDC() );
|
||||
}
|
||||
|
||||
final JLabel methodFileLabel = new JLabel();
|
||||
final JLabel methodDNSLabel = new JLabel();
|
||||
final JLabel methodManualLabel = new JLabel();
|
||||
final JLabel realmLabel = new JLabel();
|
||||
final JLabel kdcLabel = new JLabel();
|
||||
|
||||
ResourceUtils.resLabel( methodFileLabel, methodFileRadio, Res.getString( "checkbox.use.krbconf" ) );
|
||||
ResourceUtils.resLabel( methodDNSLabel, methodDNSRadio, Res.getString( "checkbox.use.krb.dns" ) );
|
||||
ResourceUtils.resLabel( methodManualLabel, methodManualRadio, Res.getString( "checkbox.use.specify.below" ) );
|
||||
ResourceUtils.resLabel( realmLabel, realmField, Res.getString( "label.krb.realm" ) );
|
||||
ResourceUtils.resLabel( kdcLabel, kdcField, Res.getString( "label.krb.kdc" ) );
|
||||
|
||||
final ButtonGroup ssoMethodRadio = new ButtonGroup();
|
||||
ssoMethodRadio.add( methodFileRadio );
|
||||
ssoMethodRadio.add( methodDNSRadio );
|
||||
ssoMethodRadio.add( methodManualRadio );
|
||||
|
||||
setLayout( new GridBagLayout() );
|
||||
add( wrappedLabel, new GridBagConstraints( 0, 0, 3, 1, 1.0, 0.0, WEST, HORIZONTAL, DEFAULT_INSETS, 0, 10 ) );
|
||||
add( useSSOBox, new GridBagConstraints( 0, 1, 3, 1, 1.0, 0.0, WEST, NONE, DEFAULT_INSETS, 0, 0 ) );
|
||||
add( methodFileRadio, new GridBagConstraints( 0, 2, 1, 1, 0.0, 0.0, WEST, HORIZONTAL, DEFAULT_INSETS, 0, 0 ) );
|
||||
add( methodFileLabel, new GridBagConstraints( 1, 2, 2, 1, 1.0, 0.0, WEST, NONE, DEFAULT_INSETS, 0, 0 ) );
|
||||
add( methodDNSRadio, new GridBagConstraints( 0, 3, 1, 1, 0.0, 0.0, WEST, HORIZONTAL, DEFAULT_INSETS, 0, 0 ) );
|
||||
add( methodDNSLabel, new GridBagConstraints( 1, 3, 2, 1, 1.0, 0.0, WEST, NONE, DEFAULT_INSETS, 0, 0 ) );
|
||||
add( methodManualRadio, new GridBagConstraints( 0, 4, 1, 1, 0.0, 0.0, WEST, HORIZONTAL, DEFAULT_INSETS, 0, 0 ) );
|
||||
add( methodManualLabel, new GridBagConstraints( 1, 4, 2, 1, 1.0, 0.0, WEST, NONE, DEFAULT_INSETS, 0, 0 ) );
|
||||
add( realmLabel, new GridBagConstraints( 1, 5, 1, 1, 0.0, 0.0, WEST, NONE, DEFAULT_INSETS, 0, 0 ) );
|
||||
add( realmField, new GridBagConstraints( 2, 5, 1, 1, 1.0, 0.0, WEST, HORIZONTAL, DEFAULT_INSETS, 0, 0 ) );
|
||||
add( kdcLabel, new GridBagConstraints( 1, 6, 1, 1, 0.0, 0.0, WEST, NONE, DEFAULT_INSETS, 0, 0 ) );
|
||||
add( kdcField, new GridBagConstraints( 2, 6, 1, 1, 1.0, 0.0, WEST, HORIZONTAL, DEFAULT_INSETS, 0, 0 ) );
|
||||
add( useSaslGssapiSmack3compatBox, new GridBagConstraints( 0, 7, 3, 1, 1.0, 0.0, WEST, HORIZONTAL, DEFAULT_INSETS, 0, 0 ) );
|
||||
|
||||
useSSOBox.setSelected( localPreferences.isSSOEnabled() );
|
||||
useSaslGssapiSmack3compatBox.setSelected( localPreferences.isSaslGssapiSmack3Compatible() );
|
||||
|
||||
setFormEnabled( useSSOBox.isSelected() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the principal name if one exists.
|
||||
*
|
||||
* @return the name (ex. derek) of the principal.
|
||||
* @throws Exception thrown if a Principal was not found.
|
||||
*/
|
||||
private String getPrincipalName() throws Exception
|
||||
{
|
||||
if ( localPreferences.getDebug() )
|
||||
{
|
||||
System.setProperty( "java.security.krb5.debug", "true" );
|
||||
}
|
||||
System.setProperty( "javax.security.auth.useSubjectCredsOnly", "false" );
|
||||
GSSAPIConfiguration config = new GSSAPIConfiguration( false );
|
||||
Configuration.setConfiguration( config );
|
||||
|
||||
LoginContext lc;
|
||||
try
|
||||
{
|
||||
lc = new LoginContext( "com.sun.security.jgss.krb5.initiate" );
|
||||
lc.login();
|
||||
}
|
||||
catch ( LoginException le )
|
||||
{
|
||||
Log.debug( le.getMessage() );
|
||||
return null;
|
||||
}
|
||||
|
||||
Subject mySubject = lc.getSubject();
|
||||
|
||||
for ( Principal p : mySubject.getPrincipals() )
|
||||
{
|
||||
String name = p.getName();
|
||||
int indexOne = name.indexOf( "@" );
|
||||
if ( indexOne != -1 )
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
if ( e.getSource() == useSSOBox )
|
||||
{
|
||||
setFormEnabled( useSSOBox.isSelected() );
|
||||
}
|
||||
}
|
||||
|
||||
private void setFormEnabled( boolean enabled )
|
||||
{
|
||||
methodFileRadio.setEnabled( enabled );
|
||||
methodDNSRadio.setEnabled( enabled );
|
||||
methodManualRadio.setEnabled( enabled );
|
||||
realmField.setEnabled( enabled );
|
||||
kdcField.setEnabled( enabled );
|
||||
useSaslGssapiSmack3compatBox.setEnabled( enabled );
|
||||
}
|
||||
|
||||
public boolean validate_settings()
|
||||
{
|
||||
boolean valid = true;
|
||||
UIManager.put( "OptionPane.okButtonText", Res.getString( "ok" ) );
|
||||
|
||||
if ( useSSOBox.isSelected() )
|
||||
{
|
||||
if ( methodManualRadio.isSelected() )
|
||||
{
|
||||
if ( !ModelUtil.hasLength( realmField.getText() ) )
|
||||
{
|
||||
JOptionPane.showMessageDialog( optionsDialog,
|
||||
"You must specify a realm",
|
||||
Res.getString( "title.error" ),
|
||||
JOptionPane.ERROR_MESSAGE );
|
||||
realmField.requestFocus();
|
||||
valid = false;
|
||||
}
|
||||
if ( !ModelUtil.hasLength( kdcField.getText() ) )
|
||||
{
|
||||
JOptionPane.showMessageDialog( optionsDialog,
|
||||
"You must specify a KDC",
|
||||
Res.getString( "title.error" ),
|
||||
JOptionPane.ERROR_MESSAGE );
|
||||
kdcField.requestFocus();
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
public void saveSettings()
|
||||
{
|
||||
localPreferences.setSSOEnabled( useSSOBox.isSelected() );
|
||||
if ( methodFileRadio.isSelected() )
|
||||
{
|
||||
localPreferences.setSSOMethod( "file" );
|
||||
}
|
||||
else if ( methodDNSRadio.isSelected() )
|
||||
{
|
||||
localPreferences.setSSOMethod( "dns" );
|
||||
}
|
||||
else if ( methodManualRadio.isSelected() )
|
||||
{
|
||||
localPreferences.setSSOMethod( "manual" );
|
||||
localPreferences.setSSORealm( realmField.getText() );
|
||||
localPreferences.setSSOKDC( kdcField.getText() );
|
||||
}
|
||||
else
|
||||
{
|
||||
localPreferences.setSSOMethod( "file" );
|
||||
}
|
||||
SettingsManager.saveSettings();
|
||||
}
|
||||
}
|
||||
@ -908,6 +908,13 @@ public class LocalPreferences {
|
||||
return getBoolean("ssoEnabled", false);
|
||||
}
|
||||
|
||||
public boolean isSaslGssapiSmack3Compatible() {
|
||||
return getBoolean("saslGssapiSmack3compat", false);
|
||||
}
|
||||
|
||||
public void setSaslGssapiSmack3Compatible( boolean b) {
|
||||
setBoolean( "saslGssapiSmack3compat", b );
|
||||
}
|
||||
public void setSSOMethod(String method) {
|
||||
props.setProperty("ssoMethod", method);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user