You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by tb...@apache.org on 2006/12/12 16:24:14 UTC

svn commit: r486187 [27/49] - in /directory/trunks/triplesec: ./ admin-api/ admin-api/src/ admin-api/src/main/ admin-api/src/main/java/ admin-api/src/main/java/org/ admin-api/src/main/java/org/safehaus/ admin-api/src/main/java/org/safehaus/triplesec/ a...

Added: directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/ConnectionDialog.java
URL: http://svn.apache.org/viewvc/directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/ConnectionDialog.java?view=auto&rev=486187
==============================================================================
--- directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/ConnectionDialog.java (added)
+++ directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/ConnectionDialog.java Tue Dec 12 07:23:31 2006
@@ -0,0 +1,511 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.safehaus.triplesec.admin.swing;
+
+
+import javax.swing.JPanel;
+import javax.swing.JDialog;
+
+import java.awt.Color;
+import java.awt.GridBagLayout;
+import java.awt.GridBagConstraints;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+import java.awt.Dimension;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+import javax.swing.JCheckBox;
+import javax.swing.JButton;
+
+
+public class ConnectionDialog extends JDialog
+{
+    private static final long serialVersionUID = -4476950680973044809L;
+
+    private JPanel mainPanel = null;
+    private JPanel textAreaPanel = null;
+    private JTextArea messageTextArea = null;
+    private JPanel ldapPortPanel = null;
+    private JLabel ldapPortLabel = null;
+    private JTextField ldapPortTextField = null;
+    private JPanel hostPanel = null;
+    private JLabel hostLabel = null;
+    private JTextField hostTextField = null;
+    private JPanel krb5PortPanel = null;
+    private JLabel krb5PortLabel = null;
+    private JTextField krb5TextField = null;
+    private JPanel useLdapsPanel = null;
+    private JLabel useLdapsLabel = null;
+    private JCheckBox useLdapsCheckBox = null;
+    private JPanel buttonPanel = null;
+    private JButton cancelButton = null;
+    private JButton connectButton = null;
+    private final ConnectionInfoModifier modifier = new ConnectionInfoModifier();
+
+    private boolean canceled = true;
+    
+
+    /**
+     * This is the default constructor
+     */
+    public ConnectionDialog()
+    {
+        super();
+        initialize();
+    }
+
+
+    /**
+     * constructor for pre-setting values
+     */
+    public ConnectionDialog( ConnectionInfo connectionInfo )
+    {
+        super();
+        initialize();
+        
+        this.ldapPortTextField.setText( String.valueOf( connectionInfo.getLdapPort() ) );
+        modifier.setLdapPort( connectionInfo.getLdapPort() );
+        
+        this.hostTextField.setText( connectionInfo.getHost() );
+        modifier.setHost( connectionInfo.getHost() );
+        
+        this.krb5TextField.setText( String.valueOf( connectionInfo.getKrb5Port() ) );
+        modifier.setKrb5Port( connectionInfo.getKrb5Port() );
+        
+        this.useLdapsCheckBox.setSelected( connectionInfo.isUseLdaps() );
+        modifier.setUseLdaps( connectionInfo.isUseLdaps() );
+    }
+    
+    
+    public ConnectionInfoModifier getConnectionModifier()
+    {
+        return modifier;
+    }
+    
+    
+    public boolean isCanceled()
+    {
+        return canceled;
+    }
+
+
+    /**
+     * This method initializes this
+     * 
+     * @return void
+     */
+    private void initialize()
+    {
+        this.setSize( 359, 334 );
+        this.setTitle( "Connection Settings" );
+        this.setContentPane( getJContentPane() );
+    }
+
+
+    /**
+     * This method initializes jContentPane
+     * 
+     * @return javax.swing.JPanel
+     */
+    private JPanel getJContentPane()
+    {
+        if ( mainPanel == null )
+        {
+            GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
+            gridBagConstraints5.gridx = 1;
+            gridBagConstraints5.insets = new java.awt.Insets( 25, 160, 0, 0 );
+            gridBagConstraints5.weightx = 0.0D;
+            gridBagConstraints5.gridy = 8;
+            GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
+            gridBagConstraints4.gridx = 1;
+            gridBagConstraints4.insets = new java.awt.Insets( 8, 0, 0, 12 );
+            gridBagConstraints4.gridy = 7;
+            GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
+            gridBagConstraints3.gridx = 1;
+            gridBagConstraints3.insets = new java.awt.Insets( 10, 0, 0, 0 );
+            gridBagConstraints3.gridy = 6;
+            GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
+            gridBagConstraints2.gridx = 1;
+            gridBagConstraints2.insets = new java.awt.Insets( 10, 31, 0, 0 );
+            gridBagConstraints2.gridy = 5;
+            GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
+            gridBagConstraints1.gridx = 1;
+            gridBagConstraints1.insets = new java.awt.Insets( 20, 0, 0, 0 );
+            gridBagConstraints1.gridy = 4;
+            GridBagConstraints gridBagConstraints = new GridBagConstraints();
+            gridBagConstraints.gridx = 1;
+            gridBagConstraints.gridheight = 4;
+            gridBagConstraints.gridy = 0;
+            mainPanel = new JPanel();
+            mainPanel.setLayout( new GridBagLayout() );
+            mainPanel.add( getJPanel(), gridBagConstraints );
+            mainPanel.add( getJPanel2(), gridBagConstraints1 );
+            mainPanel.add( getJPanel3(), gridBagConstraints2 );
+            mainPanel.add( getJPanel4(), gridBagConstraints3 );
+            mainPanel.add( getJPanel5(), gridBagConstraints4 );
+            mainPanel.add( getJPanel6(), gridBagConstraints5 );
+        }
+        return mainPanel;
+    }
+
+
+    /**
+     * This method initializes jPanel
+     * 
+     * @return javax.swing.JPanel
+     */
+    private JPanel getJPanel()
+    {
+        if ( textAreaPanel == null )
+        {
+            textAreaPanel = new JPanel();
+            textAreaPanel.setBorder( javax.swing.BorderFactory
+                .createEtchedBorder( javax.swing.border.EtchedBorder.RAISED ) );
+            textAreaPanel.add( getJTextArea(), null );
+        }
+        return textAreaPanel;
+    }
+
+
+    /**
+     * This method initializes jTextArea
+     * 
+     * @return javax.swing.JTextArea
+     */
+    private JTextArea getJTextArea()
+    {
+        if ( messageTextArea == null )
+        {
+            messageTextArea = new JTextArea();
+            messageTextArea.setText( "You have not loaded a local server configuration \n"
+                + "file so remote connection settings are required." );
+            messageTextArea.setEditable( false );
+        }
+        return messageTextArea;
+    }
+
+
+    /**
+     * This method initializes jPanel
+     * 
+     * @return javax.swing.JPanel
+     */
+    private JPanel getJPanel2()
+    {
+        if ( ldapPortPanel == null )
+        {
+            ldapPortLabel = new JLabel();
+            ldapPortLabel.setText( "Ldap Port: " );
+            ldapPortPanel = new JPanel();
+            ldapPortPanel.add( ldapPortLabel, null );
+            ldapPortPanel.add( getJTextField(), null );
+        }
+        return ldapPortPanel;
+    }
+
+
+    /**
+     * This method initializes jTextField
+     * 
+     * @return javax.swing.JTextField
+     */
+    private JTextField getJTextField()
+    {
+        if ( ldapPortTextField == null )
+        {
+            ldapPortTextField = new JTextField();
+            ldapPortTextField.setText( "10389" );
+            ldapPortTextField.setColumns(5);
+            ldapPortTextField.setPreferredSize( new java.awt.Dimension( 44, 17 ) );
+            ldapPortTextField.addFocusListener( new java.awt.event.FocusAdapter()
+            {
+                public void focusLost( java.awt.event.FocusEvent e )
+                {
+                    if ( isIntFieldValid( ldapPortTextField ) )
+                    {
+                        ldapPortLabel.setForeground( Color.BLACK );
+                    }
+                    else
+                    {
+                        ldapPortLabel.setForeground( Color.RED );
+                    }
+                }
+            } );
+        }
+        return ldapPortTextField;
+    }
+
+
+    /**
+     * This method initializes jPanel
+     * 
+     * @return javax.swing.JPanel
+     */
+    private JPanel getJPanel3()
+    {
+        if ( hostPanel == null )
+        {
+            hostLabel = new JLabel();
+            hostLabel.setText( "Host: " );
+            hostPanel = new JPanel();
+            hostPanel.add( hostLabel, null );
+            hostPanel.add( getJTextField2(), null );
+        }
+        return hostPanel;
+    }
+
+
+    /**
+     * This method initializes jTextField
+     * 
+     * @return javax.swing.JTextField
+     */
+    private JTextField getJTextField2()
+    {
+        if ( hostTextField == null )
+        {
+            hostTextField = new JTextField();
+            hostTextField.setText( "localhost" );
+            hostTextField.setColumns(10);
+            hostTextField.setPreferredSize( new java.awt.Dimension( 44, 17 ) );
+            hostTextField.addFocusListener( new java.awt.event.FocusAdapter()
+            {
+                public void focusLost( java.awt.event.FocusEvent e )
+                {
+                    if ( isHostValid() )
+                    {
+                        hostLabel.setForeground( Color.BLACK );
+                    }
+                    else 
+                    {
+                        hostLabel.setForeground( Color.RED );
+                    }
+                }
+            } );
+        }
+        return hostTextField;
+    }
+
+
+    /**
+     * This method initializes jPanel
+     * 
+     * @return javax.swing.JPanel
+     */
+    private JPanel getJPanel4()
+    {
+        if ( krb5PortPanel == null )
+        {
+            krb5PortLabel = new JLabel();
+            krb5PortLabel.setText( "Krb5 Port: " );
+            krb5PortPanel = new JPanel();
+            krb5PortPanel.add( krb5PortLabel, null );
+            krb5PortPanel.add( getJTextField3(), null );
+        }
+        return krb5PortPanel;
+    }
+
+
+    /**
+     * This method initializes jTextField
+     * 
+     * @return javax.swing.JTextField
+     */
+    private JTextField getJTextField3()
+    {
+        if ( krb5TextField == null )
+        {
+            krb5TextField = new JTextField();
+            krb5TextField.setText( "88" );
+            krb5TextField.setColumns(5);
+            krb5TextField.setPreferredSize( new Dimension( 44, 17 ) );
+            krb5TextField.addFocusListener( new java.awt.event.FocusAdapter()
+            {
+                public void focusLost( java.awt.event.FocusEvent e )
+                {
+                    if ( isIntFieldValid( krb5TextField ) )
+                    {
+                        krb5PortLabel.setForeground( Color.BLACK );
+                    }
+                    else
+                    {
+                        krb5PortLabel.setForeground( Color.RED );
+                    }
+                }
+            } );
+        }
+        return krb5TextField;
+    }
+
+
+    /**
+     * This method initializes jPanel
+     * 
+     * @return javax.swing.JPanel
+     */
+    private JPanel getJPanel5()
+    {
+        if ( useLdapsPanel == null )
+        {
+            useLdapsLabel = new JLabel();
+            useLdapsLabel.setText( "Use Ldaps:    " );
+            useLdapsPanel = new JPanel();
+            useLdapsPanel.add( useLdapsLabel, null );
+            useLdapsPanel.add( getJCheckBox(), null );
+        }
+        return useLdapsPanel;
+    }
+
+
+    /**
+     * This method initializes jCheckBox
+     * 
+     * @return javax.swing.JCheckBox
+     */
+    private JCheckBox getJCheckBox()
+    {
+        if ( useLdapsCheckBox == null )
+        {
+            useLdapsCheckBox = new JCheckBox();
+            useLdapsCheckBox.addItemListener( new java.awt.event.ItemListener()
+            {
+                public void itemStateChanged( java.awt.event.ItemEvent e )
+                {
+                    modifier.setUseLdaps( useLdapsCheckBox.isSelected() );
+                }
+            } );
+        }
+        return useLdapsCheckBox;
+    }
+
+
+    /**
+     * This method initializes jPanel
+     * 
+     * @return javax.swing.JPanel
+     */
+    private JPanel getJPanel6()
+    {
+        if ( buttonPanel == null )
+        {
+            buttonPanel = new JPanel();
+            buttonPanel.add( getJButton(), null );
+            buttonPanel.add( getJButton1(), null );
+        }
+        return buttonPanel;
+    }
+
+
+    /**
+     * This method initializes jButton
+     * 
+     * @return javax.swing.JButton
+     */
+    private JButton getJButton()
+    {
+        if ( cancelButton == null )
+        {
+            cancelButton = new JButton();
+            cancelButton.setText( "Cancel" );
+            cancelButton.setPreferredSize( new java.awt.Dimension( 75, 25 ) );
+            cancelButton.addActionListener( new java.awt.event.ActionListener()
+            {
+                public void actionPerformed( java.awt.event.ActionEvent e )
+                {
+                    setVisible( false );
+                    dispose();
+                    canceled = true;
+                }
+            } );
+        }
+        return cancelButton;
+    }
+
+
+    /**
+     * This method initializes jButton1
+     * 
+     * @return javax.swing.JButton
+     */
+    private JButton getJButton1()
+    {
+        if ( connectButton == null )
+        {
+            connectButton = new JButton();
+            connectButton.setText( "Connect" );
+            connectButton.addActionListener( new java.awt.event.ActionListener()
+            {
+                public void actionPerformed( java.awt.event.ActionEvent e )
+                {
+                    if ( isIntFieldValid( ldapPortTextField ) && 
+                         isIntFieldValid( krb5TextField ) &&
+                         isHostValid() )
+                    {
+                        modifier.setLdapPort( Integer.parseInt( ldapPortTextField.getText() ) );
+                        modifier.setKrb5Port( Integer.parseInt( krb5TextField.getText() ) );
+                        modifier.setHost( hostTextField.getText() );
+                        modifier.setUseLdaps( useLdapsCheckBox.isSelected() );
+                        canceled = false;
+                        setVisible( false );
+                        dispose();
+                    }
+                    else
+                    {
+                        JOptionPane.showMessageDialog( ConnectionDialog.this, "Empty or invalid fields remain", 
+                            "Empty or Invalid Field", JOptionPane.ERROR_MESSAGE );
+                    }
+                }
+            } );
+        }
+        return connectButton;
+    }
+
+    
+    private boolean isIntFieldValid( JTextField field )
+    {
+        try
+        {
+            Integer.parseInt( field.getText() );
+            return true;
+        }
+        catch ( NumberFormatException e )
+        {
+            return false;
+        }
+    }
+    
+    
+    private boolean isHostValid()
+    {
+        try
+        {
+            InetAddress.getByName( hostTextField.getText() );
+            return true;
+        }
+        catch ( UnknownHostException e1 )
+        {
+            hostLabel.setForeground( Color.RED );
+            return false;
+        }
+    }
+} // @jve:decl-index=0:visual-constraint="10,10"

Added: directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/ConnectionInfo.java
URL: http://svn.apache.org/viewvc/directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/ConnectionInfo.java?view=auto&rev=486187
==============================================================================
--- directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/ConnectionInfo.java (added)
+++ directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/ConnectionInfo.java Tue Dec 12 07:23:31 2006
@@ -0,0 +1,104 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.safehaus.triplesec.admin.swing;
+
+
+import org.apache.directory.shared.ldap.util.NamespaceTools;
+
+
+public class ConnectionInfo
+{
+    private final String host;
+    private final int ldapPort;
+    private final int krb5Port;
+    private final boolean useLdaps;
+    private final String realm;
+    private final String principal;
+    private final String credentials;
+    private final String passcode;
+
+    
+    public ConnectionInfo ( String host, int ldapPort, int krb5Port, boolean useLdaps, 
+        String realm, String princial, String credentials, String passcode )
+    {
+        this.host = host;
+        this.ldapPort = ldapPort;
+        this.krb5Port = krb5Port;
+        this.useLdaps = useLdaps;
+        this.realm = realm;
+        this.principal = princial;
+        this.credentials = credentials;
+        this.passcode = passcode;
+    }
+
+    
+    public String getHost()
+    {
+        return host;
+    }
+
+
+    public int getLdapPort()
+    {
+        return ldapPort;
+    }
+
+
+    public int getKrb5Port()
+    {
+        return krb5Port;
+    }
+
+
+    public boolean isUseLdaps()
+    {
+        return useLdaps;
+    }
+
+
+    public String getRealm()
+    {
+        return realm;
+    }
+
+    
+    public String getLdapRealmBase()
+    {
+        return NamespaceTools.inferLdapName( realm );
+    }
+    
+
+    public String getPrincipal()
+    {
+        return principal;
+    }
+
+
+    public String getCredentials()
+    {
+        return credentials;
+    }
+
+
+    public String getPasscode()
+    {
+        return passcode;
+    }
+}

Added: directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/ConnectionInfoModifier.java
URL: http://svn.apache.org/viewvc/directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/ConnectionInfoModifier.java?view=auto&rev=486187
==============================================================================
--- directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/ConnectionInfoModifier.java (added)
+++ directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/ConnectionInfoModifier.java Tue Dec 12 07:23:31 2006
@@ -0,0 +1,107 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.safehaus.triplesec.admin.swing;
+
+
+
+public class ConnectionInfoModifier
+{
+    private String host;
+    private int ldapPort;
+    private int krb5Port;
+    private boolean useLdaps;
+    private String realm;
+    private String principal;
+    private String credentials;
+    private String passcode;
+    
+    
+    public ConnectionInfoModifier()
+    {
+    }
+
+    
+    public ConnectionInfoModifier( ConnectionInfo copy )
+    {
+        this.host = copy.getHost();
+        this.credentials = copy.getCredentials();
+        this.krb5Port = copy.getKrb5Port();
+        this.ldapPort = copy.getLdapPort();
+        this.useLdaps = copy.isUseLdaps();
+        this.realm = copy.getRealm();
+        this.principal = copy.getPrincipal();
+        this.passcode = copy.getPasscode();
+    }
+    
+    
+    public void setHost( String host )
+    {
+        this.host = host;
+    }
+
+
+    public void setLdapPort( int ldapPort )
+    {
+        this.ldapPort = ldapPort;
+    }
+
+
+    public void setKrb5Port( int krb5Port )
+    {
+        this.krb5Port = krb5Port;
+    }
+
+
+    public void setUseLdaps( boolean useLdaps )
+    {
+        this.useLdaps = useLdaps;
+    }
+
+
+    public void setRealm( String realm )
+    {
+        this.realm = realm;
+    }
+
+
+    public void setPrincipal( String principal )
+    {
+        this.principal = principal;
+    }
+
+
+    public void setCredentials( String credentials )
+    {
+        this.credentials = credentials;
+    }
+
+
+    public void setPasscode( String passcode )
+    {
+        this.passcode = passcode;
+    }
+    
+    
+    public ConnectionInfo getConnectionInfo()
+    {
+        return new ConnectionInfo ( host, ldapPort, krb5Port, useLdaps, 
+            realm, principal, credentials, passcode );
+    }
+}

Added: directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/ConnectionManager.java
URL: http://svn.apache.org/viewvc/directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/ConnectionManager.java?view=auto&rev=486187
==============================================================================
--- directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/ConnectionManager.java (added)
+++ directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/ConnectionManager.java Tue Dec 12 07:23:31 2006
@@ -0,0 +1,234 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.safehaus.triplesec.admin.swing;
+
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Observable;
+import java.util.Properties;
+
+import javax.naming.Context;
+import javax.security.auth.Subject;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.security.auth.login.LoginException;
+
+import org.safehaus.triplesec.admin.TriplesecAdmin;
+import org.safehaus.triplesec.admin.dao.DaoFactory;
+import org.safehaus.triplesec.admin.dao.ldap.LdapDaoFactory;
+import org.safehaus.triplesec.configuration.TriplesecStartupConfiguration;
+import org.safehaus.triplesec.guardian.ApplicationPolicy;
+import org.safehaus.triplesec.guardian.Profile;
+import org.safehaus.triplesec.jaas.PasscodeCallback;
+import org.safehaus.triplesec.jaas.PolicyCallback;
+import org.safehaus.triplesec.jaas.RealmCallback;
+import org.safehaus.triplesec.jaas.SafehausLoginModule;
+import org.safehaus.triplesec.jaas.SafehausPrincipal;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class ConnectionManager extends Observable
+{
+    private static final Logger log = LoggerFactory.getLogger( ConnectionManager.class );
+    private Throwable lastFailure;
+    private TriplesecAdmin admin;
+    private String realm;
+    
+    
+    public boolean connect( final ConnectionInfo connectionInfo, final ApplicationPolicy policy ) throws LoginException
+    {
+        CallbackHandler handler = new CallbackHandler()
+        {
+            public void handle( Callback[] callbacks ) throws IOException, UnsupportedCallbackException
+            {
+                for ( int ii = 0; ii < callbacks.length; ii++ )
+                {
+                    if ( callbacks[ii] instanceof NameCallback )
+                    {
+                        NameCallback ncb = ( NameCallback ) callbacks[ii];
+                        ncb.setName( connectionInfo.getPrincipal() );
+                    }
+
+                    else if ( callbacks[ii] instanceof PasswordCallback )
+                    {
+                        PasswordCallback pcb = ( PasswordCallback ) callbacks[ii];
+                        pcb.setPassword( connectionInfo.getCredentials().toCharArray() );
+                    }
+                    
+                    else if ( callbacks[ii] instanceof RealmCallback )
+                    {
+                        RealmCallback rcb = ( RealmCallback ) callbacks[ii];
+                        rcb.setRealm( connectionInfo.getRealm() );
+                    }
+                    
+                    else if ( callbacks[ii] instanceof PolicyCallback )
+                    {
+                        PolicyCallback pcb = ( PolicyCallback ) callbacks[ii];
+                        pcb.setPolicy( policy );
+                    }
+                    
+                    else if ( callbacks[ii] instanceof PasscodeCallback )
+                    {
+                        PasscodeCallback pcb = ( PasscodeCallback ) callbacks[ii];
+                        pcb.setPasscode( connectionInfo.getPasscode() );
+                    }
+                }
+            }
+        };
+        Subject subject = new Subject();
+        SafehausLoginModule module = new SafehausLoginModule();
+        Map options = new HashMap();
+        options.put( SafehausLoginModule.ALLOW_ADMIN, "true" );
+        module.initialize( subject, handler, new HashMap(), options );
+        if ( ! module.login() )
+        {
+            throw new LoginException ( "Authentication failed!" );
+        }
+        module.commit();
+        
+        // -------------------------------------------------------------------
+        // Need to connect to the server as the user to initialize DAO factories
+        // -------------------------------------------------------------------
+
+        Properties env = new Properties();
+        env.put( DaoFactory.IMPLEMENTATION_CLASS, LdapDaoFactory.class.getName() );
+        env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
+        StringBuffer buf = new StringBuffer();
+        
+        buf.append( "ldap" );
+        if ( connectionInfo.isUseLdaps() )
+        {
+            buf.append( "s" );
+        }
+        buf.append( "://" ).append( connectionInfo.getHost() ).append( ":" ).append( connectionInfo.getLdapPort() );
+        buf.append( "/" ).append( connectionInfo.getLdapRealmBase() );
+        env.put( Context.PROVIDER_URL, buf.toString() );
+        
+        if ( connectionInfo.getPrincipal().equals( "admin" ) )
+        {
+            env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
+        }
+        else
+        {
+            SafehausPrincipal principal = ( SafehausPrincipal ) subject.getPrincipals().toArray()[0];
+            Profile profile = principal.getAuthorizationProfile();
+            StringBuffer principalDn = new StringBuffer();
+            principalDn.append( "uid=" ).append( profile.getUserName() ).append( ",ou=Users," )
+                .append( connectionInfo.getLdapRealmBase() );
+            env.put ( Context.SECURITY_PRINCIPAL, principalDn.toString() );
+        }
+        env.put( Context.SECURITY_AUTHENTICATION, "simple" );
+        env.put( Context.SECURITY_CREDENTIALS, connectionInfo.getCredentials() );
+        realm = connectionInfo.getRealm();
+        try
+        {
+            admin = new TriplesecAdmin( env );
+        }
+        catch ( Throwable t ) // @todo make sure we catch all sorts of subclasses and handle differently
+        {
+            log.error( "Failed to connect to triplesec server: " + connectionInfo, t );
+            lastFailure = t;
+            admin = null;
+            return false;
+        }
+        super.setChanged();
+        super.notifyObservers();
+        return true;
+    }
+
+    
+    public boolean disconnect()
+    {
+        if ( admin == null )
+        {
+            return true;
+        }
+        admin.close();
+        admin = null;
+        realm = null;
+        super.setChanged();
+        super.notifyObservers();
+        return true;
+    }
+
+    
+    public boolean connect( TriplesecStartupConfiguration config, Properties env )
+    {
+        Properties props = new Properties();
+        props.putAll( env );
+        props.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
+        props.put( DaoFactory.IMPLEMENTATION_CLASS, LdapDaoFactory.class.getName() );
+        StringBuffer buf = new StringBuffer();
+        buf.append( "ldap://localhost:" ).append( config.getLdapPort() );
+        buf.append( "/" ).append( props.getProperty( Context.PROVIDER_URL ) );
+        props.put( Context.PROVIDER_URL, buf.toString() );
+        props.remove( "java.naming.factory.object" );
+        props.remove( "java.naming.factory.state" );
+        
+        realm = props.getProperty( "kdc.primary.realm" );
+        try
+        {
+            admin = new TriplesecAdmin( props );
+        }
+        catch ( Throwable t )
+        {
+            log.error( "Failed to connect to triplesec server: " + env, t );
+            lastFailure = t;
+            admin = null;
+            realm = null;
+            return false;
+        }
+        
+        super.setChanged();
+        super.notifyObservers();
+        return true;
+    }
+
+    
+    public boolean isConnected()
+    {
+        return admin != null;
+    }
+    
+    
+    public TriplesecAdmin getTriplesecAdmin()
+    {
+        return admin;
+    }
+    
+    
+    public Throwable getLastFailure()
+    {
+        return lastFailure;
+    }
+
+
+    public String getRealm()
+    {
+        return realm;
+    }
+}

Added: directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/ExternalLinkPanel.java
URL: http://svn.apache.org/viewvc/directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/ExternalLinkPanel.java?view=auto&rev=486187
==============================================================================
--- directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/ExternalLinkPanel.java (added)
+++ directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/ExternalLinkPanel.java Tue Dec 12 07:23:31 2006
@@ -0,0 +1,240 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.safehaus.triplesec.admin.swing;
+
+
+import java.awt.BorderLayout;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
+import org.safehaus.triplesec.admin.ExternalUser;
+import org.safehaus.triplesec.admin.ExternalUserModifier;
+
+
+public class ExternalLinkPanel extends JPanel implements StatusObject, KeyListener, FocusListener
+{
+    private static final long serialVersionUID = -1447912774145082027L;
+    private JPanel jPanel1 = null;
+    private JPanel jPanel2 = null;
+    private JButton jButton = null;
+    private JLabel jLabel7 = null;
+    private JTextField linkUrlTextField = null;
+    private ExternalUser user = null;
+    private StatusListener listener;
+    private boolean lastStatusState = true;  // true = up to date, false means it was not up to date
+    private boolean newEntityMode = false;
+
+
+    /**
+     * This is the default constructor
+     */
+    public ExternalLinkPanel()
+    {
+        super();
+        initialize();
+    }
+
+    
+    public void setNewEntityMode ( boolean newEntityMode )
+    {
+        this.newEntityMode = newEntityMode;
+    }
+    
+
+    public void setFields( ExternalUser externalUser )
+    {
+        user = externalUser;
+        lastStatusState = true;
+        linkUrlTextField.setText( externalUser.getReferral() );
+    }
+    
+    
+    /**
+     * This method initializes this
+     * 
+     * @return void
+     */
+    private void initialize()
+    {
+        this.setSize(553, 225);
+        setLayout( new BorderLayout() );
+        add( getJPanel1(), java.awt.BorderLayout.CENTER );
+        add( getJPanel2(), java.awt.BorderLayout.SOUTH );
+    }
+
+
+    /**
+     * This method initializes jPanel1  
+     *  
+     * @return javax.swing.JPanel   
+     */
+    private JPanel getJPanel1()
+    {
+        if ( jPanel1 == null )
+        {
+            GridBagConstraints gridBagConstraints17 = new GridBagConstraints();
+            gridBagConstraints17.fill = java.awt.GridBagConstraints.HORIZONTAL;
+            gridBagConstraints17.gridy = 0;
+            gridBagConstraints17.weightx = 1.0;
+            gridBagConstraints17.insets = new java.awt.Insets( 0, 5, 0, 10 );
+            gridBagConstraints17.gridx = 1;
+            GridBagConstraints gridBagConstraints16 = new GridBagConstraints();
+            gridBagConstraints16.gridx = 0;
+            gridBagConstraints16.insets = new java.awt.Insets( 0, 10, 0, 0 );
+            gridBagConstraints16.fill = java.awt.GridBagConstraints.HORIZONTAL;
+            gridBagConstraints16.gridy = 0;
+            jLabel7 = new JLabel();
+            jLabel7.setText( "Link URL:" );
+            jLabel7.setHorizontalAlignment( javax.swing.SwingConstants.RIGHT );
+            jPanel1 = new JPanel();
+            jPanel1.setLayout( new GridBagLayout() );
+            jPanel1.add( jLabel7, gridBagConstraints16 );
+            jPanel1.add( getLinkUrlTextField(), gridBagConstraints17 );
+        }
+        return jPanel1;
+    }
+
+
+    /**
+     * This method initializes jPanel2  
+     *  
+     * @return javax.swing.JPanel   
+     */
+    private JPanel getJPanel2()
+    {
+        if ( jPanel2 == null )
+        {
+            jPanel2 = new JPanel();
+            jPanel2.add( getJButton(), null );
+        }
+        return jPanel2;
+    }
+
+
+    /**
+     * This method initializes jButton  
+     *  
+     * @return javax.swing.JButton  
+     */
+    private JButton getJButton()
+    {
+        if ( jButton == null )
+        {
+            jButton = new JButton();
+            jButton.setText( "Test" );
+        }
+        return jButton;
+    }
+
+
+    /**
+     * This method initializes jTextField   
+     *  
+     * @return javax.swing.JTextField   
+     */
+    private JTextField getLinkUrlTextField()
+    {
+        if ( linkUrlTextField == null )
+        {
+            linkUrlTextField = new JTextField();
+            linkUrlTextField.addFocusListener( this );
+            linkUrlTextField.addKeyListener( this );
+        }
+        return linkUrlTextField;
+    }
+
+
+    public void alterModifier( ExternalUserModifier modifier )
+    {
+        modifier.setReferral( linkUrlTextField.getText() );
+    }
+
+
+    public String getReferral()
+    {
+        return linkUrlTextField.getText();
+    }
+
+
+    public boolean isUpToDate()
+    {
+        if ( newEntityMode )
+        {
+            return UiUtils.isFieldUpToDate( linkUrlTextField, null );
+        }
+        return UiUtils.isFieldUpToDate( linkUrlTextField, user.getReferral() );
+    }
+
+
+    private void checkStatus()
+    {
+        boolean upToDate = isUpToDate();
+        if ( listener != null && lastStatusState != upToDate )
+        {
+            listener.statusChanged( ExternalLinkPanel.this );
+            lastStatusState = upToDate;
+        }
+    }
+
+    
+    public void focusGained( FocusEvent e )
+    {
+        checkStatus();
+    }
+
+
+    public void focusLost( FocusEvent e )
+    {
+        checkStatus();
+    }
+
+
+    public void keyTyped( KeyEvent e )
+    {
+        checkStatus();
+    }
+
+
+    public void keyPressed( KeyEvent e )
+    {
+        checkStatus();
+    }
+
+
+    public void keyReleased( KeyEvent e )
+    {
+        checkStatus();
+    }
+
+
+    public void setStatusListener( StatusListener listener )
+    {
+        this.listener = listener;
+    }
+}  //  @jve:decl-index=0:visual-constraint="10,10"

Added: directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/GeneralPanel.java
URL: http://svn.apache.org/viewvc/directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/GeneralPanel.java?view=auto&rev=486187
==============================================================================
--- directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/GeneralPanel.java (added)
+++ directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/GeneralPanel.java Tue Dec 12 07:23:31 2006
@@ -0,0 +1,218 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.safehaus.triplesec.admin.swing;
+
+
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
+import org.safehaus.triplesec.admin.AdministeredEntity;
+
+
+public class GeneralPanel extends JPanel
+{
+    private static final long serialVersionUID = 1L;
+    private JTextField creatorsNameTextField = null;
+    private JTextField createTimestampTextField = null;
+    private JTextField modifiersNameTextField = null;
+    private JTextField modifyTimestampTextField = null;
+    
+
+
+    /**
+     * This is the default constructor
+     */
+    public GeneralPanel()
+    {
+        super();
+        initialize();
+    }
+
+
+    /**
+     * This method initializes this
+     * 
+     * @return void
+     */
+    private void initialize()
+    {
+        this.setSize(518, 252);
+        GridBagConstraints gridBagConstraints13 = new GridBagConstraints();
+        gridBagConstraints13.fill = java.awt.GridBagConstraints.HORIZONTAL;
+        gridBagConstraints13.gridy = 3;
+        gridBagConstraints13.weightx = 1.0;
+        gridBagConstraints13.insets = new java.awt.Insets( 0, 5, 0, 5 );
+        gridBagConstraints13.gridx = 1;
+        GridBagConstraints gridBagConstraints12 = new GridBagConstraints();
+        gridBagConstraints12.fill = java.awt.GridBagConstraints.HORIZONTAL;
+        gridBagConstraints12.gridy = 2;
+        gridBagConstraints12.weightx = 1.0;
+        gridBagConstraints12.insets = new java.awt.Insets( 0, 5, 5, 5 );
+        gridBagConstraints12.gridx = 1;
+        GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
+        gridBagConstraints11.gridx = 0;
+        gridBagConstraints11.insets = new java.awt.Insets( 0, 5, 0, 0 );
+        gridBagConstraints11.fill = java.awt.GridBagConstraints.HORIZONTAL;
+        gridBagConstraints11.gridy = 3;
+        JLabel jLabel6 = new JLabel();
+        jLabel6.setText( "ModifyTimestamp:" );
+        jLabel6.setHorizontalAlignment( javax.swing.SwingConstants.RIGHT );
+        GridBagConstraints gridBagConstraints10 = new GridBagConstraints();
+        gridBagConstraints10.gridx = 0;
+        gridBagConstraints10.fill = java.awt.GridBagConstraints.HORIZONTAL;
+        gridBagConstraints10.gridy = 2;
+        JLabel jLabel5 = new JLabel();
+        jLabel5.setText( "Modifier's Name:" );
+        jLabel5.setHorizontalAlignment( javax.swing.SwingConstants.RIGHT );
+        GridBagConstraints gridBagConstraints9 = new GridBagConstraints();
+        gridBagConstraints9.fill = java.awt.GridBagConstraints.HORIZONTAL;
+        gridBagConstraints9.gridy = 1;
+        gridBagConstraints9.weightx = 1.0;
+        gridBagConstraints9.insets = new java.awt.Insets( 0, 5, 5, 5 );
+        gridBagConstraints9.gridx = 1;
+        GridBagConstraints gridBagConstraints8 = new GridBagConstraints();
+        gridBagConstraints8.gridx = 0;
+        gridBagConstraints8.insets = new java.awt.Insets( 0, 5, 0, 0 );
+        gridBagConstraints8.fill = java.awt.GridBagConstraints.HORIZONTAL;
+        gridBagConstraints8.gridy = 1;
+        JLabel jLabel4 = new JLabel();
+        jLabel4.setText( "Create Timestamp:" );
+        jLabel4.setHorizontalAlignment( javax.swing.SwingConstants.RIGHT );
+        GridBagConstraints gridBagConstraints7 = new GridBagConstraints();
+        gridBagConstraints7.fill = java.awt.GridBagConstraints.HORIZONTAL;
+        gridBagConstraints7.gridy = 0;
+        gridBagConstraints7.weightx = 1.0;
+        gridBagConstraints7.insets = new java.awt.Insets( 0, 5, 5, 5 );
+        gridBagConstraints7.gridx = 1;
+        GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
+        gridBagConstraints6.gridx = 0;
+        gridBagConstraints6.insets = new java.awt.Insets( 0, 5, 0, 0 );
+        gridBagConstraints6.fill = java.awt.GridBagConstraints.HORIZONTAL;
+        gridBagConstraints6.gridy = 0;
+        JLabel jLabel3 = new JLabel();
+        jLabel3.setText( "Creator's Name:" );
+        jLabel3.setHorizontalAlignment( javax.swing.SwingConstants.RIGHT );
+        setLayout( new GridBagLayout() );
+        setComponentOrientation( java.awt.ComponentOrientation.LEFT_TO_RIGHT );
+        add( jLabel3, gridBagConstraints6 );
+        add( getCreatorsNameTextField(), gridBagConstraints7 );
+        add( jLabel4, gridBagConstraints8 );
+        add( getCreateTimestampTextField(), gridBagConstraints9 );
+        add( jLabel5, gridBagConstraints10 );
+        add( jLabel6, gridBagConstraints11 );
+        add( getModifiersNameTextField(), gridBagConstraints12 );
+        add( getModifyTimestampTextField(), gridBagConstraints13 );
+    }
+
+
+
+
+    /**
+     * This method initializes jTextField3  
+     *  
+     * @return javax.swing.JTextField   
+     */
+    private JTextField getCreatorsNameTextField()
+    {
+        if ( creatorsNameTextField == null )
+        {
+            creatorsNameTextField = new JTextField();
+            creatorsNameTextField.setEditable( false );
+        }
+        return creatorsNameTextField;
+    }
+
+
+    /**
+     * This method initializes jTextField4  
+     *  
+     * @return javax.swing.JTextField   
+     */
+    private JTextField getCreateTimestampTextField()
+    {
+        if ( createTimestampTextField == null )
+        {
+            createTimestampTextField = new JTextField();
+            createTimestampTextField.setEditable( false );
+        }
+        return createTimestampTextField;
+    }
+
+
+    /**
+     * This method initializes jTextField5  
+     *  
+     * @return javax.swing.JTextField   
+     */
+    private JTextField getModifiersNameTextField()
+    {
+        if ( modifiersNameTextField == null )
+        {
+            modifiersNameTextField = new JTextField();
+            modifiersNameTextField.setEditable( false );
+        }
+        return modifiersNameTextField;
+    }
+
+
+    /**
+     * This method initializes jTextField6  
+     *  
+     * @return javax.swing.JTextField   
+     */
+    private JTextField getModifyTimestampTextField()
+    {
+        if ( modifyTimestampTextField == null )
+        {
+            modifyTimestampTextField = new JTextField();
+            modifyTimestampTextField.setEditable( false );
+        }
+        return modifyTimestampTextField;
+    }
+
+
+    public void setFields( AdministeredEntity entity )
+    {
+        creatorsNameTextField.setText( entity.getCreatorsName() );
+        modifiersNameTextField.setText( entity.getModifiersName() );
+
+        if ( entity.getCreateTimestamp() != null )
+        {
+            createTimestampTextField.setText( entity.getCreateTimestamp().toString() );
+        }
+        else
+        {
+            createTimestampTextField.setText( null );
+        }
+        
+        if ( entity.getModifyTimestamp() != null )
+        {
+            modifyTimestampTextField.setText( entity.getModifyTimestamp().toString() );
+        }
+        else
+        {
+            modifyTimestampTextField.setText( null );
+        }
+    }
+}  //  @jve:decl-index=0:visual-constraint="10,10"

Added: directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/GroupPanel.java
URL: http://svn.apache.org/viewvc/directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/GroupPanel.java?view=auto&rev=486187
==============================================================================
--- directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/GroupPanel.java (added)
+++ directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/GroupPanel.java Tue Dec 12 07:23:31 2006
@@ -0,0 +1,573 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.safehaus.triplesec.admin.swing;
+
+
+import javax.swing.JPanel;
+import java.awt.BorderLayout;
+
+import javax.swing.ImageIcon;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JTabbedPane;
+import javax.swing.JButton;
+import javax.swing.JTree;
+
+import java.awt.GridBagLayout;
+import java.awt.GridBagConstraints;
+
+import javax.swing.JTextField;
+import javax.swing.JTextArea;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.TreePath;
+
+import org.safehaus.triplesec.admin.DataAccessException;
+import org.safehaus.triplesec.admin.Group;
+import org.safehaus.triplesec.admin.GroupModifier;
+
+
+public class GroupPanel extends JPanel
+{
+    private static final long serialVersionUID = 1L;
+    private JPanel mainPanel = null;
+    private JPanel buttonPanel = null;
+    private JButton revertButton = null;
+    private JButton saveButton = null;
+    private JPanel aboveButtonPanel = null;
+    private JPanel northPanel = null;
+    private JTabbedPane centerTabbedPane = null;
+    private JPanel southPanel = null;
+    private GeneralPanel generalPanel = null;
+    private JLabel iconLabel = null;
+    private JPanel jPanel = null;
+    private JTextArea descriptionTextArea = null;
+    private JPanel jPanel4 = null;
+    private Group group = null;
+    private DefaultMutableTreeNode node = null;
+    private JTree tree = null;
+    private JLabel jLabel = null;
+    private JTextField statusField = null;
+    private JLabel jLabel1 = null;
+    private JTextField groupNameTextField = null;
+    private JButton deleteButton = null;
+    private GroupUsersPanel groupUsersPanel;
+
+
+    /**
+     * This is the default constructor
+     */
+    public GroupPanel()
+    {
+        super();
+        initialize();
+    }
+
+
+    /**
+     * This method initializes this
+     * 
+     * @return void
+     */
+    private void initialize()
+    {
+        GridBagConstraints gridBagConstraints = new GridBagConstraints();
+        gridBagConstraints.gridx = 0;
+        gridBagConstraints.weightx = 1.0D;
+        gridBagConstraints.weighty = 1.0D;
+        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
+        gridBagConstraints.insets = new java.awt.Insets( 10, 10, 10, 10 );
+        gridBagConstraints.gridy = 0;
+        this.setLayout( new GridBagLayout() );
+        this.setSize( 550, 417 );
+        this.setBorder( javax.swing.BorderFactory.createTitledBorder( null, "Existing Group",
+            javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION,
+            null, null ) );
+        this.add( getMainPanel(), gridBagConstraints );
+    }
+
+
+    /**
+     * This method initializes jPanel	
+     * 	
+     * @return javax.swing.JPanel	
+     */
+    private JPanel getMainPanel()
+    {
+        if ( mainPanel == null )
+        {
+            mainPanel = new JPanel();
+            mainPanel.setLayout( new BorderLayout() );
+            mainPanel.add( getButtonPanel(), java.awt.BorderLayout.SOUTH );
+            mainPanel.add( getAboveButtonPanel(), java.awt.BorderLayout.CENTER );
+        }
+        return mainPanel;
+    }
+
+
+    /**
+     * This method initializes jPanel	
+     * 	
+     * @return javax.swing.JPanel	
+     */
+    private JPanel getButtonPanel()
+    {
+        if ( buttonPanel == null )
+        {
+            buttonPanel = new JPanel();
+            buttonPanel.setBorder( javax.swing.BorderFactory.createEmptyBorder( 0, 0, 0, 0 ) );
+            buttonPanel.add(getDeleteButton(), null);
+            buttonPanel.add( getRevertButton(), null );
+            buttonPanel.add( getSaveButton(), null );
+        }
+        return buttonPanel;
+    }
+
+
+    /**
+     * This method initializes jButton	
+     * 	
+     * @return javax.swing.JButton	
+     */
+    private JButton getRevertButton()
+    {
+        if ( revertButton == null )
+        {
+            revertButton = new JButton();
+            revertButton.setText( "Revert" );
+            revertButton.addActionListener( new java.awt.event.ActionListener()
+            {
+                public void actionPerformed( java.awt.event.ActionEvent e )
+                {
+                    setGroupFields();
+                }
+            } );
+        }
+        return revertButton;
+    }
+
+
+    /**
+     * This method initializes jButton	
+     * 	
+     * @return javax.swing.JButton	
+     */
+    private JButton getSaveButton()
+    {
+        if ( saveButton == null )
+        {
+            saveButton = new JButton();
+            saveButton.setText( "Save" );
+            saveButton.addActionListener( new java.awt.event.ActionListener()
+            {
+                public void actionPerformed( java.awt.event.ActionEvent e )
+                {
+                    saveAction();
+                }
+            } );
+        }
+        return saveButton;
+    }
+
+
+    /**
+     * This method initializes jPanel	
+     * 	
+     * @return javax.swing.JPanel	
+     */
+    private JPanel getAboveButtonPanel()
+    {
+        if ( aboveButtonPanel == null )
+        {
+            aboveButtonPanel = new JPanel();
+            aboveButtonPanel.setLayout( new BorderLayout() );
+            aboveButtonPanel.add( getNorthPanel(), java.awt.BorderLayout.NORTH );
+            aboveButtonPanel.add( getCenterTabbedPane(), java.awt.BorderLayout.CENTER );
+            aboveButtonPanel.add( getSouthPanel(), java.awt.BorderLayout.SOUTH );
+        }
+        return aboveButtonPanel;
+    }
+
+
+    /**
+     * This method initializes jPanel	
+     * 	
+     * @return javax.swing.JPanel	
+     */
+    private JPanel getNorthPanel()
+    {
+        if ( northPanel == null )
+        {
+            GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
+            gridBagConstraints1.gridx = 1;
+            gridBagConstraints1.weightx = 1.0D;
+            gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
+            gridBagConstraints1.gridheight = 3;
+            gridBagConstraints1.insets = new java.awt.Insets( 0, 10, 0, 10 );
+            gridBagConstraints1.weighty = 1.0D;
+            gridBagConstraints1.gridy = 0;
+            northPanel = new JPanel();
+            northPanel.setLayout( new GridBagLayout() );
+            northPanel.setPreferredSize( new java.awt.Dimension( 179, 68 ) );
+            northPanel.add( getJPanel4(), new GridBagConstraints() );
+            northPanel.add( getJPanel(), gridBagConstraints1 );
+        }
+        return northPanel;
+    }
+
+
+    /**
+     * This method initializes jTabbedPane	
+     * 	
+     * @return javax.swing.JTabbedPane	
+     */
+    private JTabbedPane getCenterTabbedPane()
+    {
+        if ( centerTabbedPane == null )
+        {
+            centerTabbedPane = new JTabbedPane();
+            centerTabbedPane.addTab( "General", null, getGeneralPanel(), null );
+            centerTabbedPane.addTab( "Users", null, getGroupUsersPanel(), null );
+        }
+        return centerTabbedPane;
+    }
+    
+    
+    private GroupUsersPanel getGroupUsersPanel()
+    {
+        if ( groupUsersPanel == null )
+        {
+            groupUsersPanel = new GroupUsersPanel();
+        }
+        return groupUsersPanel;
+    }
+
+
+    /**
+     * This method initializes jPanel	
+     * 	
+     * @return javax.swing.JPanel	
+     */
+    private JPanel getSouthPanel()
+    {
+        if ( southPanel == null )
+        {
+            southPanel = new JPanel();
+            southPanel.setLayout( new BorderLayout() );
+            southPanel.setBorder( javax.swing.BorderFactory.createTitledBorder( null, "Description",
+                javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
+                javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null ) );
+            southPanel.add( getDescriptionTextArea(), java.awt.BorderLayout.NORTH );
+        }
+        return southPanel;
+    }
+
+
+    /**
+     * This method initializes jPanel	
+     * 	
+     * @return javax.swing.JPanel	
+     */
+    private GeneralPanel getGeneralPanel()
+    {
+        if ( generalPanel == null )
+        {
+            generalPanel = new GeneralPanel();
+        }
+        return generalPanel;
+    }
+
+
+    /**
+     * This method initializes iconLabel
+     * 	
+     * @return javax.swing.JLabel	
+     */
+    private JLabel getIconLabel()
+    {
+        if ( iconLabel == null )
+        {
+            iconLabel = new JLabel();
+            iconLabel.setIcon( new ImageIcon( getClass().getResource(
+                "/org/safehaus/triplesec/admin/swing/group_48x48.png" ) ) );
+            iconLabel.setPreferredSize( new java.awt.Dimension( 48, 48 ) );
+            iconLabel.setText( "" );
+            iconLabel.setVerticalTextPosition( javax.swing.SwingConstants.BOTTOM );
+            iconLabel.setVerticalAlignment( javax.swing.SwingConstants.BOTTOM );
+            iconLabel.setEnabled( true );
+        }
+        return iconLabel;
+    }
+
+
+    /**
+     * This method initializes jPanel	
+     * 	
+     * @return javax.swing.JPanel	
+     */
+    private JPanel getJPanel()
+    {
+        if ( jPanel == null )
+        {
+            GridBagConstraints gridBagConstraints15 = new GridBagConstraints();
+            gridBagConstraints15.fill = java.awt.GridBagConstraints.HORIZONTAL;
+            gridBagConstraints15.gridy = 1;
+            gridBagConstraints15.weightx = 1.0;
+            gridBagConstraints15.gridx = 1;
+            GridBagConstraints gridBagConstraints14 = new GridBagConstraints();
+            gridBagConstraints14.gridx = 0;
+            gridBagConstraints14.insets = new java.awt.Insets( 0, 0, 0, 5 );
+            gridBagConstraints14.fill = java.awt.GridBagConstraints.HORIZONTAL;
+            gridBagConstraints14.gridy = 1;
+            jLabel1 = new JLabel();
+            jLabel1.setText( "Group Name:" );
+            jLabel1.setHorizontalAlignment( javax.swing.SwingConstants.RIGHT );
+            GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
+            gridBagConstraints3.fill = java.awt.GridBagConstraints.HORIZONTAL;
+            gridBagConstraints3.insets = new java.awt.Insets( 0, 0, 5, 5 );
+            GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
+            gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
+            gridBagConstraints2.gridy = 0;
+            gridBagConstraints2.weightx = 1.0;
+            gridBagConstraints2.insets = new java.awt.Insets( 0, 0, 5, 0 );
+            gridBagConstraints2.gridx = 1;
+            jLabel = new JLabel();
+            jLabel.setText( "Status:" );
+            jLabel.setHorizontalAlignment( javax.swing.SwingConstants.RIGHT );
+            jPanel = new JPanel();
+            jPanel.setLayout( new GridBagLayout() );
+            jPanel.setPreferredSize( new java.awt.Dimension( 131, 88 ) );
+            jPanel.add( jLabel, gridBagConstraints3 );
+            jPanel.add( getStatusField(), gridBagConstraints2 );
+            jPanel.add( jLabel1, gridBagConstraints14 );
+            jPanel.add( getGroupNameTextField(), gridBagConstraints15 );
+        }
+        return jPanel;
+    }
+
+
+    /**
+     * This method initializes jTextArea	
+     * 	
+     * @return javax.swing.JTextArea	
+     */
+    private JTextArea getDescriptionTextArea()
+    {
+        if ( descriptionTextArea == null )
+        {
+            descriptionTextArea = new JTextArea();
+            descriptionTextArea.setRows( 3 );
+        }
+        return descriptionTextArea;
+    }
+
+
+    /**
+     * This method initializes jPanel4	
+     * 	
+     * @return javax.swing.JPanel	
+     */
+    private JPanel getJPanel4()
+    {
+        if ( jPanel4 == null )
+        {
+            jPanel4 = new JPanel();
+            jPanel4.setBorder( javax.swing.BorderFactory.createEtchedBorder( javax.swing.border.EtchedBorder.RAISED ) );
+            jPanel4.add( getIconLabel(), null );
+        }
+        return jPanel4;
+    }
+
+    
+    private void setGroupFields()
+    {
+        generalPanel.setFields( group );
+        groupNameTextField.setText( group.getName() );
+        // group does not have a description field and perhaps it should even
+        // if we need to use extensibleObject
+        //        descriptionTextArea.setText( group.getDescription() );
+
+        if ( node == null || node.getParent() == null || node.getParent().getParent() == null )
+        {
+            return;
+        }
+        
+        groupUsersPanel.populateLists( ( DefaultMutableTreeNode ) node.getParent().getParent(), group.getMembers() );
+    }
+
+
+    public void setTree( JTree tree )
+    {
+        this.tree = tree;
+    }
+
+
+    public void setTreeNode( DefaultMutableTreeNode node )
+    {
+        this.node = node;
+        this.group = ( Group ) node.getUserObject();
+        setGroupFields();
+    }
+
+
+    public String noNull( Object obj )
+    {
+        if ( obj == null )
+        {
+            return "";
+        }
+        return obj.toString();
+    }
+
+
+    public DefaultMutableTreeNode getTreeNode()
+    {
+        return node;
+    }
+
+
+    public void saveAction()
+    {
+        // groups do not yet have a description field
+        //        GroupModifier modifier = group.modifier().setDescription( descriptionTextArea.getText() );
+        //        if ( modifier.isUpdateNeeded() )
+        //        {
+        //            try
+        //            {
+        //                group = modifier.modify();
+        //            }
+        //            catch ( DataAccessException e )
+        //            {
+        //                JOptionPane.showMessageDialog( this, 
+        //                    UiUtils.wrap( "Failed to modify group:\n" + e.getMessage(), 79 ),
+        //                    "Group modification failure!", JOptionPane.ERROR_MESSAGE );
+        //                return;
+        //            }
+        //            node.setUserObject( group );
+        //        }
+
+        GroupModifier modifier = group.modifier();
+        for ( int ii = 0; ii < groupUsersPanel.getUsersInGroupModel().size(); ii++ )
+        {
+            modifier.addMember( ( String ) groupUsersPanel.getUsersInGroupModel().getElementAt( ii ) );
+        }
+        for ( int ii = 0; ii < groupUsersPanel.getAvailableUsersModel().size(); ii++ )
+        {
+            modifier.removeMember( ( String ) groupUsersPanel.getAvailableUsersModel().getElementAt( ii ) );
+        }
+        if ( modifier.isUpdateNeeded() )
+        {
+            try
+            {
+                group = modifier.modify();
+            }
+            catch ( DataAccessException e )
+            {
+                JOptionPane.showMessageDialog( this, UiUtils.wrap( "Failed to modify group members:\n" 
+                    + e.getMessage(), 79 ), "Group save failure!", JOptionPane.ERROR_MESSAGE );
+                return;
+            }
+        }
+        
+        if ( !group.getName().equals( groupNameTextField.getText() ) )
+        {
+            try
+            {
+                group = group.modifier().rename( groupNameTextField.getText() );
+            }
+            catch ( DataAccessException e )
+            {
+                JOptionPane.showMessageDialog( this, UiUtils.wrap( "Failed to rename group:\n" + e.getMessage(), 79 ),
+                    "Group rename failure!", JOptionPane.ERROR_MESSAGE );
+                return;
+            }
+        }
+
+        node.setUserObject( group );
+        setGroupFields();
+        ( ( DefaultTreeModel ) tree.getModel() ).valueForPathChanged( new TreePath( node.getPath() ), group );
+    }
+    /**
+     * This method initializes jTextField	
+     * 	
+     * @return javax.swing.JTextField	
+     */
+    private JTextField getStatusField()
+    {
+        if ( statusField == null )
+        {
+            statusField = new JTextField();
+            statusField.setEditable( false );
+        }
+        return statusField;
+    }
+
+
+    /**
+     * This method initializes jTextField	
+     * 	
+     * @return javax.swing.JTextField	
+     */
+    private JTextField getGroupNameTextField()
+    {
+        if ( groupNameTextField == null )
+        {
+            groupNameTextField = new JTextField();
+        }
+        return groupNameTextField;
+    }
+
+
+    /**
+     * This method initializes jButton	
+     * 	
+     * @return javax.swing.JButton	
+     */
+    private JButton getDeleteButton()
+    {
+        if ( deleteButton == null )
+        {
+            deleteButton = new JButton();
+            deleteButton.setText("Delete");
+            deleteButton.addActionListener( new java.awt.event.ActionListener()
+            {
+                public void actionPerformed( java.awt.event.ActionEvent e )
+                {
+                    try
+                    {
+                        group.modifier().delete();
+                        DefaultMutableTreeNode parentNode = ( DefaultMutableTreeNode ) node.getParent();
+                        DefaultTreeModel treeModel = ( DefaultTreeModel ) tree.getModel();
+                        treeModel.removeNodeFromParent( node );
+                        TreePath path = new TreePath( parentNode.getPath() );
+                        tree.setSelectionPaths( new TreePath[] { path } );
+                    }
+                    catch ( DataAccessException e1 )
+                    {
+                        JOptionPane.showMessageDialog( GroupPanel.this, 
+                            "Failed to delete group: " + e1.getMessage(), "Delete Failed", 
+                            JOptionPane.ERROR_MESSAGE );
+                    }
+                }
+            } );
+        }
+        return deleteButton;
+    }
+} //  @jve:decl-index=0:visual-constraint="10,10"

Added: directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/GroupUsersPanel.java
URL: http://svn.apache.org/viewvc/directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/GroupUsersPanel.java?view=auto&rev=486187
==============================================================================
--- directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/GroupUsersPanel.java (added)
+++ directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/GroupUsersPanel.java Tue Dec 12 07:23:31 2006
@@ -0,0 +1,360 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.safehaus.triplesec.admin.swing;
+
+
+import java.awt.BorderLayout;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.swing.DefaultListModel;
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
+import javax.swing.JList;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.tree.DefaultMutableTreeNode;
+
+import org.safehaus.triplesec.admin.User;
+
+
+public class GroupUsersPanel extends JPanel
+{
+    private static final long serialVersionUID = 1527321087922436546L;
+
+    private JPanel availableUsersPanel = null;
+    private JList availableUsersList = null;
+    private JPanel usersInGroupPanel = null;
+    private JList usersInGroupList = null;
+    private JPanel usersButtonPanel = null;
+    private JButton addUsersButton = null;
+    private JButton removeUsersButton = null;
+    private DefaultListModel usersInGroupListModel = null; //  @jve:decl-index=0:visual-constraint=""
+    private DefaultListModel availableUsersListModel = null;
+    private JScrollPane jScrollPane = null;
+    private JScrollPane jScrollPane1 = null;
+
+    
+    /**
+     * This is the default constructor
+     */
+    public GroupUsersPanel()
+    {
+        super();
+        initialize();
+    }
+
+    
+    public void populateLists( DefaultMutableTreeNode rootNode, Set users )
+    {
+        clear();
+        for ( Iterator ii = users.iterator(); ii.hasNext(); /**/)
+        {
+            usersInGroupListModel.add( 0, ii.next() );
+        }
+        
+        if ( rootNode == null )
+        {
+            return;
+        }
+        DefaultMutableTreeNode usersNode = null;
+        for ( Enumeration ii = rootNode.children(); ii.hasMoreElements(); /**/ )
+        {
+            DefaultMutableTreeNode child = ( DefaultMutableTreeNode ) ii.nextElement();
+            if ( ( ( String ) child.getUserObject() ).equalsIgnoreCase( "Users" ) )
+            {
+                usersNode = child;
+                break;
+            }
+        }
+
+        for ( Enumeration ii = usersNode.children(); ii.hasMoreElements(); /**/ )
+        {
+            DefaultMutableTreeNode userNode = ( DefaultMutableTreeNode ) ii.nextElement();
+            User user = ( User ) userNode.getUserObject();
+            if ( ! users.contains( user.getId() ) )
+            {
+                availableUsersListModel.addElement( user.getId() );
+            }
+        }
+    }
+    
+    
+    public DefaultListModel getUsersInGroupModel()
+    {
+        return usersInGroupListModel;
+    }
+    
+    
+    public DefaultListModel getAvailableUsersModel()
+    {
+        return availableUsersListModel;
+    }
+    
+
+    public void clear()
+    {
+        usersInGroupListModel.clear();
+        availableUsersListModel.clear();
+    }
+    
+    
+    /**
+     * This method initializes this
+     * 
+     * @return void
+     */
+    private void initialize()
+    {
+        this.setSize(548, 246);
+        setLayout( new BorderLayout() );
+        setName( "usersPanelTab" );
+        add( getAvailableUsersPanel(), java.awt.BorderLayout.WEST );
+        add( getUsersInGroupPanel(), java.awt.BorderLayout.EAST );
+        add( getUsersButtonPanel(), java.awt.BorderLayout.CENTER );
+    }
+
+
+    /**
+     * This method initializes jPanel3  
+     *  
+     * @return javax.swing.JPanel   
+     */
+    private JPanel getAvailableUsersPanel()
+    {
+        if ( availableUsersPanel == null )
+        {
+            availableUsersPanel = new JPanel();
+            availableUsersPanel.setLayout( new BorderLayout() );
+            availableUsersPanel.setBorder( javax.swing.BorderFactory.createTitledBorder( null, "Available Users",
+                javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
+                javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null ) );
+            availableUsersPanel.setPreferredSize( new java.awt.Dimension( 200, 35 ) );
+            availableUsersPanel.setToolTipText( "Available users that are not in the group" );
+            availableUsersPanel.add(getJScrollPane(), java.awt.BorderLayout.CENTER);
+        }
+        return availableUsersPanel;
+    }
+
+
+    /**
+     * This method initializes jList    
+     *  
+     * @return javax.swing.JList    
+     */
+    private JList getAvailableUsersList()
+    {
+        if ( availableUsersList == null )
+        {
+            availableUsersList = new JList();
+            availableUsersList.setModel( getAvailableUsersListModel() );
+            
+        }
+        return availableUsersList;
+    }
+
+
+    /**
+     * This method initializes jPanel3  
+     *  
+     * @return javax.swing.JPanel   
+     */
+    private JPanel getUsersInGroupPanel()
+    {
+        if ( usersInGroupPanel == null )
+        {
+            usersInGroupPanel = new JPanel();
+            usersInGroupPanel.setLayout( new BorderLayout() );
+            usersInGroupPanel.setPreferredSize( new java.awt.Dimension( 200, 10 ) );
+            usersInGroupPanel.setToolTipText( "Existing members of the group" );
+            usersInGroupPanel.setBorder( javax.swing.BorderFactory.createTitledBorder( null, "Group Members",
+                javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
+                javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null ) );
+            usersInGroupPanel.add(getJScrollPane1(), java.awt.BorderLayout.CENTER);
+        }
+        return usersInGroupPanel;
+    }
+
+
+    /**
+     * This method initializes jList    
+     *  
+     * @return javax.swing.JList    
+     */
+    private JList getUsersInGroupList()
+    {
+        if ( usersInGroupList == null )
+        {
+            usersInGroupList = new JList();
+            usersInGroupList.setModel( getUsersInGroupListModel() );
+        }
+        return usersInGroupList;
+    }
+
+
+    /**
+     * This method initializes jPanel3  
+     *  
+     * @return javax.swing.JPanel   
+     */
+    private JPanel getUsersButtonPanel()
+    {
+        if ( usersButtonPanel == null )
+        {
+            GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
+            gridBagConstraints5.gridx = 0;
+            gridBagConstraints5.insets = new java.awt.Insets( 10, 0, 0, 0 );
+            gridBagConstraints5.gridy = 1;
+            GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
+            gridBagConstraints4.gridx = 0;
+            gridBagConstraints4.gridy = 0;
+            usersButtonPanel = new JPanel();
+            usersButtonPanel.setLayout( new GridBagLayout() );
+            usersButtonPanel.add( getAddUsersButton(), gridBagConstraints4 );
+            usersButtonPanel.add( getRemoveUsersButton(), gridBagConstraints5 );
+        }
+        return usersButtonPanel;
+    }
+
+
+    /**
+     * This method initializes jButton  
+     *  
+     * @return javax.swing.JButton  
+     */
+    private JButton getAddUsersButton()
+    {
+        if ( addUsersButton == null )
+        {
+            addUsersButton = new JButton();
+            addUsersButton.setText( "" );
+            addUsersButton.setToolTipText( "Add selected users to group" );
+            addUsersButton.setIcon( new ImageIcon( getClass().getResource(
+                "/org/safehaus/triplesec/admin/swing/rightarrow_16x16.png" ) ) );
+            addUsersButton.addActionListener( new java.awt.event.ActionListener()
+            {
+                public void actionPerformed( java.awt.event.ActionEvent e )
+                {
+                    Object[] selectedUsers = availableUsersList.getSelectedValues();
+                    for ( int ii = 0; ii < selectedUsers.length; ii++ )
+                    {
+                        usersInGroupListModel.addElement( selectedUsers[ii] );
+                        availableUsersListModel.removeElement( selectedUsers[ii] );
+                    }
+                }
+            } );
+        }
+        return addUsersButton;
+    }
+
+
+    /**
+     * This method initializes jButton  
+     *  
+     * @return javax.swing.JButton  
+     */
+    private JButton getRemoveUsersButton()
+    {
+        if ( removeUsersButton == null )
+        {
+            removeUsersButton = new JButton();
+            removeUsersButton.setIcon( new ImageIcon( getClass().getResource(
+                "/org/safehaus/triplesec/admin/swing/leftarrow_16x16.png" ) ) );
+            removeUsersButton.addActionListener( new java.awt.event.ActionListener()
+            {
+                public void actionPerformed( java.awt.event.ActionEvent e )
+                {
+                    Object[] selectedUsers = usersInGroupList.getSelectedValues();
+                    for ( int ii = 0; ii < selectedUsers.length; ii++ )
+                    {
+                        usersInGroupListModel.removeElement( selectedUsers[ii] );
+                        availableUsersListModel.addElement( selectedUsers[ii] );
+                    }
+                }
+            } );
+        }
+        return removeUsersButton;
+    }
+
+
+    /**
+     * This method initializes defaultListModel 
+     *  
+     * @return javax.swing.DefaultListModel 
+     */
+    private DefaultListModel getUsersInGroupListModel()
+    {
+        if ( usersInGroupListModel == null )
+        {
+            usersInGroupListModel = new DefaultListModel();
+        }
+        return usersInGroupListModel;
+    }
+
+
+    /**
+     * This method initializes defaultListModel 
+     *  
+     * @return javax.swing.DefaultListModel 
+     */
+    private DefaultListModel getAvailableUsersListModel()
+    {
+        if ( availableUsersListModel == null )
+        {
+            availableUsersListModel = new DefaultListModel();
+        }
+        return availableUsersListModel;
+    }
+
+
+    /**
+     * This method initializes jScrollPane  
+     *  
+     * @return javax.swing.JScrollPane  
+     */
+    private JScrollPane getJScrollPane()
+    {
+        if ( jScrollPane == null )
+        {
+            jScrollPane = new JScrollPane();
+            jScrollPane.setViewportView(getAvailableUsersList());
+        }
+        return jScrollPane;
+    }
+
+
+    /**
+     * This method initializes jScrollPane1 
+     *  
+     * @return javax.swing.JScrollPane  
+     */
+    private JScrollPane getJScrollPane1()
+    {
+        if ( jScrollPane1 == null )
+        {
+            jScrollPane1 = new JScrollPane();
+            jScrollPane1.setViewportView(getUsersInGroupList());
+        }
+        return jScrollPane1;
+    }
+}  //  @jve:decl-index=0:visual-constraint="10,10"