directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1684847 - in /directory/studio/trunk/plugins/openldap.config.editor/src: main/java/org/apache/directory/studio/openldap/config/editor/dialogs/ main/java/org/apache/directory/studio/openldap/config/editor/pages/ main/java/org/apache/directo...
Date Thu, 11 Jun 2015 10:17:28 GMT
Author: elecharny
Date: Thu Jun 11 10:17:28 2015
New Revision: 1684847

URL: http://svn.apache.org/r1684847
Log:
o Added the SSF handling (olcSecurity parameter)
o Removed dead code
o Fixed comment and Javadoc typoes

Added:
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/SsfDialog.java
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/SsfLabelProvider.java
Modified:
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/SaslSecPropsDialog.java
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/TcpBufferDialog.java
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/SecurityPage.java
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/SsfWrapper.java
    directory/studio/trunk/plugins/openldap.config.editor/src/test/java/org/apache/directory/studio/openldap/config/wrappers/SsfWrapperTest.java

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/SaslSecPropsDialog.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/SaslSecPropsDialog.java?rev=1684847&r1=1684846&r2=1684847&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/SaslSecPropsDialog.java
(original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/SaslSecPropsDialog.java
Thu Jun 11 10:17:28 2015
@@ -45,7 +45,7 @@ import org.eclipse.swt.widgets.Text;
 
 /**
  * The SaslSecPropsDialog is used to edit the Sasl Security Properties. We manage
- * two kind of propertyes : with or without parameters. Here is the list of those properties
+ * two kind of properties : with or without parameters. Here is the list of those properties
  * 
  * <ul>
  * <li>none : the  flag properties default, "noanonymous,noplain", will be cleared</li>

Added: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/SsfDialog.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/SsfDialog.java?rev=1684847&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/SsfDialog.java
(added)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/SsfDialog.java
Thu Jun 11 10:17:28 2015
@@ -0,0 +1,567 @@
+/*
+ *  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.apache.directory.studio.openldap.config.editor.dialogs;
+
+
+import org.apache.directory.studio.common.ui.AddEditDialog;
+import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.openldap.common.ui.model.SsfFeatureEnum;
+import org.apache.directory.studio.openldap.common.ui.model.SsfStrengthEnum;
+import org.apache.directory.studio.openldap.config.editor.wrappers.SsfWrapper;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+
+/**
+ * A Dialog used to configure the OpenLDAP SSF. SSF (Security Strength Factors) associates
+ * a strength to a feature. Here is the list of feature that support a SSF :
+ * <ul>
+ * <li>ssf : global</li>
+ * <li>transport</li>
+ * <li>tls</li>
+ * <li>sasl</li>
+ * <li>simple_bind</li>
+ * <li>update_ssf</li>
+ * <li>update_transport</li>
+ * <li>update_tls</li>
+ * <li>update_sasl</li>
+ * </ul>
+ * The ssf value will generally depend on the number of bits used by the cipher to use,
+ * with two special values : 0 and 1. Here is a set of possible values :
+ * <ul>
+ * <li>0 : no protection</li>
+ * <li>1 : integrity check only</li>
+ * <li>56 : DES (key length is 56 bits)</li>
+ * <li>112 : 3DES (key length is 112 bits)</li>
+ * <li>128 : RC4, Blowish, AES-128</li>
+ * <li>256 : AES-256</li>
+ * </ul>
+ * 
+ * We will allow the user to select the feature to configure, and the value to set. Here
is 
+ * the layout :
+ * <pre>
+ * +-----------------------------------------------+
+ * | Security                                      |
+ * | .-------------------------------------------. |
+ * | | Feature :  [----------------------------] | |
+ * | |   [ ] No protection                       | |
+ * | |   [ ] Integrity                           | |
+ * | |   [ ] 56 bits (DES)                       | |
+ * | |   [ ] 112 bits (3DES)                     | |
+ * | |   [ ] 128 bits (RC4, Blowfish...)         | |
+ * | |   [ ] 256 bits (AES-256, ...)             | |
+ * | |   [     ] Other value                     | |
+ * | '-------------------------------------------' |
+ * | Resulting Security                            |
+ * | .-------------------------------------------. |
+ * | | Security  : <///////////////////////////> | |
+ * | '-------------------------------------------' |
+ * |                                               |
+ * |  (Cancel)                              (OK)   |
+ *-------------------------------------------------+
+ * </pre>
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class SsfDialog extends AddEditDialog<SsfWrapper>
+{
+    // UI widgets
+    private Combo featureCombo;
+    
+    /** The strength list */
+    private Button[] strengthCheckbox = new Button[6];
+    
+    /** The other strength list */
+    private Text otherText;
+    
+    // The resulting SSF
+    private Text ssfText;
+    
+    // The list of options in the combo
+    private String[] features = new String[]
+        {
+            SsfFeatureEnum.NONE.getText(),
+            SsfFeatureEnum.SASL.getText(),
+            SsfFeatureEnum.SIMPLE_BIND.getText(),
+            SsfFeatureEnum.SSF.getText(),
+            SsfFeatureEnum.TLS.getText(),
+            SsfFeatureEnum.TRANSPORT.getText(),
+            SsfFeatureEnum.UPDATE_SASL.getText(),
+            SsfFeatureEnum.UPDATE_SSF.getText(),
+            SsfFeatureEnum.UPDATE_TLS.getText(),
+            SsfFeatureEnum.UPDATE_TRANSPORT.getText(),
+            
+        };
+    
+    // An empty space
+    protected static final String TABULATION = " ";
+
+    /**
+     * The listener in charge of exposing the changes when some buttons are checked
+     */
+    private SelectionListener featureSelectionListener = new SelectionAdapter()
+    {
+        public void widgetSelected( SelectionEvent e )
+        {
+            Object object = e.getSource();
+            
+            if ( object instanceof Combo )
+            {
+                Combo featureCombo = (Combo)object;
+                Display display = ssfText.getDisplay();
+                Button okButton = getButton( IDialogConstants.OK_ID );
+                
+                String feature = featureCombo.getText();
+                SsfWrapper ssfWrapper = getEditedElement();
+                
+                SsfFeatureEnum ssfFeature = SsfFeatureEnum.getSsf( feature );
+                
+                // Check if it's not already part of the SSF
+                boolean present = false;
+                
+                for ( SsfWrapper ssf : getElements() )
+                {
+                    if ( ssfFeature == ssf.getFeature() )
+                    {
+                        present = true;
+                        break;
+                    }
+                }
+                
+                if ( !present )
+                {
+                    ssfWrapper.setFeature( SsfFeatureEnum.getSsf( feature ) );
+                    
+                    ssfText.setText( ssfWrapper.toString() );
+                    
+                    if ( ssfWrapper.isValid() )
+                    {
+                        okButton.setEnabled( true );
+                        ssfText.setForeground( display.getSystemColor( SWT.COLOR_BLACK )
);
+                    }
+                    else
+                    {
+                        okButton.setEnabled( false );
+                        ssfText.setForeground( display.getSystemColor( SWT.COLOR_RED ) );
+                    }
+                }
+                else
+                {
+                    // Come back to NONE
+                    featureCombo.setText( SsfFeatureEnum.NONE.getText() );
+                }
+            }
+        }
+    };
+    
+
+    /**
+     * The listener in charge of exposing the changes when some buttons are checked
+     */
+    private SelectionListener checkboxSelectionListener = new SelectionAdapter()
+    {
+        public void widgetSelected( SelectionEvent e )
+        {
+            Object object = e.getSource();
+            Display display = ssfText.getDisplay();
+            Button okButton = getButton( IDialogConstants.OK_ID );
+
+            if ( object instanceof Button )
+            {
+                Button selectedButton = (Button)object;
+                
+                SsfWrapper ssfWrapper = getEditedElement();
+
+                if ( selectedButton.getSelection() == true )
+                {
+                    for ( int i = 0; i < strengthCheckbox.length; i++ )
+                    {
+                        if ( selectedButton.equals( strengthCheckbox[i] ) )
+                        {
+                            
+                            switch ( i )
+                            {
+                                case 0 : 
+                                    ssfWrapper.setNbBits( SsfStrengthEnum.NO_PROTECTION.getNbBits()
);
+                                    break;
+                                    
+                                case 1 :
+                                    ssfWrapper.setNbBits( SsfStrengthEnum.INTEGRITY_CHECK.getNbBits()
);
+                                    break;
+                                    
+                                case 2 :
+                                    ssfWrapper.setNbBits( SsfStrengthEnum.DES.getNbBits()
);
+                                    break;
+                                    
+                                case 3 :
+                                    ssfWrapper.setNbBits( SsfStrengthEnum.THREE_DES.getNbBits()
);
+                                    break;
+                                    
+                                case 4 :
+                                    ssfWrapper.setNbBits( SsfStrengthEnum.AES_128.getNbBits()
);
+                                    break;
+                                    
+                                case 5 :
+                                    ssfWrapper.setNbBits( SsfStrengthEnum.AES_256.getNbBits()
);
+                                    break;
+                            }
+                        }
+                        else
+                        {
+                            // Not selected, uncheck it.
+                            strengthCheckbox[i].setSelection( false );
+                        }
+                    }
+                    
+                    // Erase teh content of the Other text
+                    otherText.setText( "" );
+                }
+
+                ssfText.setText( ssfWrapper.toString() );
+                
+                if ( ssfWrapper.isValid() )
+                {
+                    okButton.setEnabled( true );
+                    ssfText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
+                }
+                else
+                {
+                    okButton.setEnabled( false );
+                    ssfText.setForeground( display.getSystemColor( SWT.COLOR_RED ) );
+                }
+            }
+        }
+    };
+
+
+    /**
+     * The listener for the other Text
+     */
+    private ModifyListener otherTextListener = new ModifyListener()
+    {
+        public void modifyText( ModifyEvent e )
+        {
+            Display display = otherText.getDisplay();
+            Button okButton = getButton( IDialogConstants.OK_ID );
+            
+            // This button might be null when the dialog is called.
+            if ( okButton == null )
+            {
+                return;
+            }
+
+            try
+            {
+                int nbBits = Integer.parseInt( otherText.getText() );
+
+                // The nbBits must be between >=0
+                if ( nbBits < 0L )
+                {
+                    otherText.setForeground( display.getSystemColor( SWT.COLOR_RED ) );
+                    okButton.setEnabled( false );
+                    return;
+                }
+                
+                otherText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
+                getEditedElement().setNbBits( nbBits );
+                ssfText.setText( getEditedElement().toString() );
+                okButton.setEnabled( true );
+            }
+            catch ( NumberFormatException nfe )
+            {
+                // Not even a number
+                otherText.setForeground( display.getSystemColor( SWT.COLOR_RED ) );
+                ssfText.setText( getEditedElement().toString() );
+                okButton.setEnabled( false );
+            }
+        }
+    };
+
+
+    /**
+     * Creates a new instance of SsfDialog.
+     * 
+     * @param parentShell the parent shell
+     */
+    public SsfDialog( Shell parentShell )
+    {
+        super( parentShell );
+        super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    protected void configureShell( Shell shell )
+    {
+        super.configureShell( shell );
+        shell.setText( "OpenLDAP SSF" );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    protected void okPressed()
+    {
+        // Do nothing if the selected feature is NONE
+        if ( getEditedElement().getFeature() != SsfFeatureEnum.NONE )
+        {
+            super.okPressed();
+        }
+    }
+
+
+    /**
+     * Create the Dialog for the SSF :
+     * <pre>
+     * +-----------------------------------------------+
+     * | Security                                      |
+     * | .-------------------------------------------. |
+     * | | Feature :  [----------------------------] | |
+     * | |   [ ] No protection                       | |
+     * | |   [ ] Integrity                           | |
+     * | |   [ ] 56 bits (DES)                       | |
+     * | |   [ ] 112 bits (3DES)                     | |
+     * | |   [ ] 128 bits (RC4, Blowfish...)         | |
+     * | |   [ ] 256 bits (AES-256, ...)             | |
+     * | |   [     ] Other value                     | |
+     * | '-------------------------------------------' |
+     * | Resulting Security                            |
+     * | .-------------------------------------------. |
+     * | | Security  : <///////////////////////////> | |
+     * | '-------------------------------------------' |
+     * |                                               |
+     * |  (Cancel)                              (OK)   |
+     *-------------------------------------------------+
+     * </pre>
+     */
+    protected Control createDialogArea( Composite parent )
+    {
+        Composite composite = ( Composite ) super.createDialogArea( parent );
+        GridData gd = new GridData( GridData.FILL_BOTH );
+        composite.setLayoutData( gd );
+
+        createSsfEditArea( composite );
+        createSsfShowArea( composite );
+        
+        initDialog();
+        addListeners();
+        
+        applyDialogFont( composite );
+        
+        return composite;
+    }
+
+    
+    /**
+     * Overriding the createButton method, so that we can disable the OK button if no feature
is selected.
+     * 
+     * {@inheritDoc}
+     */
+    protected Button createButton(Composite parent, int id, String label, boolean defaultButton)

+    {
+        if (id == IDialogConstants.OK_ID) 
+        {
+            Button okButton = super.createButton(parent, id, label, defaultButton);
+            SsfWrapper ssfWrapper = (SsfWrapper)getEditedElement();
+
+            if ( ssfWrapper != null )
+            {
+                SsfFeatureEnum feature = ssfWrapper.getFeature();
+                
+                if ( feature == SsfFeatureEnum.NONE )
+                {
+                    okButton.setEnabled( false );
+                }
+            }
+            
+            return okButton;
+        }
+        else
+        {
+            return super.createButton(parent, id, label, defaultButton);
+        }
+    }
+    /**
+     * Initializes the Dialog with the values
+     */
+    protected void initDialog()
+    {
+        SsfWrapper ssfWrapper = (SsfWrapper)getEditedElement();
+        
+        if ( ssfWrapper != null )
+        {
+            SsfFeatureEnum feature = ssfWrapper.getFeature();
+            
+            if ( feature == SsfFeatureEnum.NONE )
+            {
+                featureCombo.setText( SsfFeatureEnum.NONE.getText() );
+
+                // Remove the feature that are already part of the list
+                for ( SsfWrapper element : getElements() )
+                {
+                    featureCombo.remove( element.getFeature().getText() );
+                }
+            }
+            else
+            {
+                // Remove all the other features, and inject the one being edited
+                featureCombo.removeAll();
+                featureCombo.add( feature.getText() );
+                featureCombo.setText( feature.getText() );
+                
+                // Disable the combo
+                featureCombo.setEnabled( false );
+            }
+            
+            SsfStrengthEnum ssfStrength = SsfStrengthEnum.getSsfStrength( ssfWrapper.getNbBits()
);
+            
+            switch ( ssfStrength )
+            {
+                case NO_PROTECTION :
+                    strengthCheckbox[0].setSelection( true );
+                    break;
+
+                case INTEGRITY_CHECK :
+                    strengthCheckbox[1].setSelection( true );
+                    break;
+                    
+                case DES :
+                    strengthCheckbox[2].setSelection( true );
+                    break;
+                    
+                case THREE_DES :
+                    strengthCheckbox[3].setSelection( true );
+                    break;
+                    
+                case AES_128 :
+                    strengthCheckbox[4].setSelection( true );
+                    break;
+                    
+                case AES_256 :
+                    strengthCheckbox[5].setSelection( true );
+                    break;
+                    
+                default :
+                    otherText.setText( Integer.toString( ssfWrapper.getNbBits() ) );
+                    break;
+            }
+            
+            ssfText.setText( ssfWrapper.toString() );
+        }
+    }
+
+
+    /**
+     * Creates the Ssf edit area.
+     *
+     * @param parent the parent composite
+     */
+    private void createSsfEditArea( Composite parent )
+    {
+        Group ssfEditGroup = BaseWidgetUtils.createGroup( parent, "Security Strength Factors",
1 );
+        ssfEditGroup.setLayout( new GridLayout( 2, false ) );
+
+        // The feature
+        featureCombo = BaseWidgetUtils.createCombo( ssfEditGroup, features, 0, 2 );
+        
+        // No-protection checkbox
+        strengthCheckbox[0] = BaseWidgetUtils.createCheckbox( ssfEditGroup, SsfStrengthEnum.NO_PROTECTION.getText(),
1 );
+        BaseWidgetUtils.createLabel( ssfEditGroup, TABULATION, 1 );
+        
+        // Integrity checkbox
+        strengthCheckbox[1] = BaseWidgetUtils.createCheckbox( ssfEditGroup, SsfStrengthEnum.INTEGRITY_CHECK.getText(),
1 );
+        BaseWidgetUtils.createLabel( ssfEditGroup, TABULATION, 1 );
+        
+        // DES checkbox
+        strengthCheckbox[2] = BaseWidgetUtils.createCheckbox( ssfEditGroup, SsfStrengthEnum.DES.getText(),
1 );
+        BaseWidgetUtils.createLabel( ssfEditGroup, TABULATION, 1 );
+        
+        // 3DES checkbox
+        strengthCheckbox[3] = BaseWidgetUtils.createCheckbox( ssfEditGroup, SsfStrengthEnum.THREE_DES.getText(),
1 );
+        BaseWidgetUtils.createLabel( ssfEditGroup, TABULATION, 1 );
+        
+        // AES-128 checkbox
+        strengthCheckbox[4] = BaseWidgetUtils.createCheckbox( ssfEditGroup, SsfStrengthEnum.AES_128.getText(),
1 );
+        BaseWidgetUtils.createLabel( ssfEditGroup, TABULATION, 1 );
+        
+        // AES-256 checkbox
+        strengthCheckbox[5] = BaseWidgetUtils.createCheckbox( ssfEditGroup, SsfStrengthEnum.AES_256.getText(),
1 );
+        BaseWidgetUtils.createLabel( ssfEditGroup, TABULATION, 1 );
+        
+        // Other Text
+        BaseWidgetUtils.createLabel( ssfEditGroup, "Other value :", 1 );
+        otherText = BaseWidgetUtils.createText( ssfEditGroup, "", 1 );
+        otherText.addModifyListener( otherTextListener );
+    }
+
+
+    /**
+     * Creates the SSF show area. It's not editable
+     *
+     * @param parent the parent composite
+     */
+    private void createSsfShowArea( Composite parent )
+    {
+        Group ssfValueGroup = BaseWidgetUtils.createGroup( parent, "SSF Value", 1 );
+        ssfText = BaseWidgetUtils.createText( ssfValueGroup, "", 1 );
+        ssfText.setEditable( false );
+    }
+
+
+    /**
+     * Adds listeners.
+     */
+    private void addListeners()
+    {
+        featureCombo.addSelectionListener( featureSelectionListener );
+        
+        for ( Button checkbox : strengthCheckbox )
+        {
+            checkbox.addSelectionListener( checkboxSelectionListener );
+        }
+
+        otherText.addModifyListener( otherTextListener );
+    }
+
+
+    @Override
+    public void addNewElement()
+    {
+        setEditedElement( new SsfWrapper( "" ) );
+    }
+}

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/TcpBufferDialog.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/TcpBufferDialog.java?rev=1684847&r1=1684846&r2=1684847&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/TcpBufferDialog.java
(original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/TcpBufferDialog.java
Thu Jun 11 10:17:28 2015
@@ -273,27 +273,6 @@ public class TcpBufferDialog extends Add
      */
     protected void okPressed()
     {
-        // Creating the new TcpBufferWrapper
-        /*
-        String sizeStr = sizeText.getText();
-        String url = listenerText.getText();
-        int sizeValue = Integer.valueOf( sizeStr );
-        
-        boolean read = readCheckbox.getSelection();
-        boolean write = writeCheckbox.getSelection();
-        TcpTypeEnum tcpType = null;
-        
-        if ( read && !write )
-        {
-            tcpType = TcpTypeEnum.READ;
-        }
-        else if ( !read && write )
-        {
-            tcpType = TcpTypeEnum.WRITE;
-        }
-        
-        setNewElement( new TcpBufferWrapper( sizeValue , tcpType, url ) );
-        */
         super.okPressed();
     }
 

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/SecurityPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/SecurityPage.java?rev=1684847&r1=1684846&r2=1684847&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/SecurityPage.java
(original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/SecurityPage.java
Thu Jun 11 10:17:28 2015
@@ -45,6 +45,8 @@ import org.apache.directory.studio.openl
 import org.apache.directory.studio.openldap.config.editor.dialogs.OverlayDialog;
 import org.apache.directory.studio.openldap.config.editor.dialogs.PasswordHashDialog;
 import org.apache.directory.studio.openldap.config.editor.dialogs.SaslSecPropsDialog;
+import org.apache.directory.studio.openldap.config.editor.dialogs.SsfDialog;
+import org.apache.directory.studio.openldap.config.editor.wrappers.SsfLabelProvider;
 import org.apache.directory.studio.openldap.config.editor.wrappers.SsfWrapper;
 import org.apache.directory.studio.openldap.config.editor.wrappers.TcpBufferWrapperLabelProvider;
 import org.apache.directory.studio.openldap.config.model.OlcGlobal;
@@ -543,8 +545,8 @@ public class SecurityPage extends OpenLD
         securityLabel.setLayoutData( new GridData( SWT.FILL, SWT.FILL, false, false, 4, 1
) );
         
         securityTableWidget = new TableWidget<SsfWrapper>();
-        securityTableWidget.setLabelProvider( new TcpBufferWrapperLabelProvider() );
-        //securityTableWidget.setElementDialog( "" );
+        securityTableWidget.setLabelProvider( new SsfLabelProvider() );
+        securityTableWidget.setElementDialog( new SsfDialog( null) );
 
         securityTableWidget.createWidgetWithEdit( miscSectionComposite, toolkit );
         securityTableWidget.getControl().setLayoutData( new GridData( SWT.FILL, SWT.NONE,
true, false, 4, 1 ) );

Added: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/SsfLabelProvider.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/SsfLabelProvider.java?rev=1684847&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/SsfLabelProvider.java
(added)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/SsfLabelProvider.java
Thu Jun 11 10:17:28 2015
@@ -0,0 +1,56 @@
+/*
+ *  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.apache.directory.studio.openldap.config.editor.wrappers;
+
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * This class defines a label provider for a SSF wrapper viewer.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class SsfLabelProvider extends LabelProvider
+{
+    /**
+     * Construct the label for a TCPBuffer. It can be one of :
+     * 
+     */
+    public String getText( Object element )
+    {
+        if ( element instanceof SsfWrapper )
+        {
+            String ssfText = ( ( SsfWrapper ) element ).toString();
+
+            return ssfText;
+        }
+
+        return super.getText( element );
+    };
+
+
+    /**
+     * Get the image. We have none (may be we could add one for URLs ?)
+     */
+    public Image getImage( Object element )
+    {
+        return null;
+    };
+}

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/SsfWrapper.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/SsfWrapper.java?rev=1684847&r1=1684846&r2=1684847&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/SsfWrapper.java
(original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/SsfWrapper.java
Thu Jun 11 10:17:28 2015
@@ -20,14 +20,14 @@
 package org.apache.directory.studio.openldap.config.editor.wrappers;
 
 import org.apache.directory.api.util.Strings;
-import org.apache.directory.studio.openldap.common.ui.model.SsfEnum;
+import org.apache.directory.studio.openldap.common.ui.model.SsfFeatureEnum;
 
 /**
  * This class wraps the olcSecurity parameter :
  * <pre>
  * olcSecurity ::= (<feature>=<size>)*
  * <feature> ::= 'ssf' | 'transport' | 'tls' | 'sasl' | 'simple_bind' | 
- *               'updates_ssf' | 'updates_transport' | 'updates_rls' | 'updates_sasl'
+ *               'update_ssf' | 'update_transport' | 'update_tls' | 'update_sasl'
  * </pre>
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
@@ -35,10 +35,10 @@ import org.apache.directory.studio.openl
 public class SsfWrapper implements Cloneable
 {
     /** The feature */
-    private SsfEnum feature;
+    private SsfFeatureEnum feature;
     
     /** The number of bits for this feature */
-    private int nbBits;
+    private int nbBits = 0;
     
     /**
      * Creates an instance using a name of a feature and its size
@@ -48,9 +48,9 @@ public class SsfWrapper implements Clone
      */
     public SsfWrapper( String feature, int nbBits )
     {
-        this.feature = SsfEnum.getSsf( feature );
+        this.feature = SsfFeatureEnum.getSsf( feature );
 
-        if ( this.feature == SsfEnum.NONE )
+        if ( this.feature == SsfFeatureEnum.NONE )
         {
             this.nbBits = 0;
         }
@@ -77,7 +77,7 @@ public class SsfWrapper implements Clone
     {
         if ( Strings.isEmpty( feature ) )
         {
-            this.feature = SsfEnum.NONE;
+            this.feature = SsfFeatureEnum.NONE;
             this.nbBits = 0;
         }
         else
@@ -86,14 +86,14 @@ public class SsfWrapper implements Clone
             
             if ( pos < 0 )
             {
-                this.feature = SsfEnum.NONE;
+                this.feature = SsfFeatureEnum.NONE;
                 this.nbBits = 0;
             }
 
             String name = Strings.trim( feature.substring( 0, pos ) );
-            this.feature = SsfEnum.getSsf( name );
+            this.feature = SsfFeatureEnum.getSsf( name );
             
-            if ( this.feature == SsfEnum.NONE )
+            if ( this.feature == SsfFeatureEnum.NONE )
             {
                 this.nbBits = 0;
             }
@@ -115,37 +115,49 @@ public class SsfWrapper implements Clone
     
     
     /**
+     * Tells if this is a valid SSF. The format is :
+     * feature = <nbBits> where nbBits >= 0.
+     * 
+     * @return true if valid
+     */
+    public boolean isValid()
+    {
+        return ( feature != null ) && ( feature != SsfFeatureEnum.NONE ) &&
( nbBits >= 0 );
+    }
+
+    
+    /**
      * Tells if the String is a valid SSF. The format is :
      * feature = <nbBits>
      * 
-     * @param feature The feature to check
+     * @param ssf The feature to check
      * @return true if valid
      */
-    public static boolean isValid(String feature )
+    public static boolean isValid( String ssf )
     {
-        if ( Strings.isEmpty( feature ) )
+        if ( Strings.isEmpty( ssf ) )
         {
             return false;
         }
         else
         {
-            int pos = feature.indexOf( '=' );
+            int pos = ssf.indexOf( '=' );
             
             if ( pos < 0 )
             {
                 return false;
             }
             
-            String name = Strings.trim( feature.substring( 0, pos ) );
-            SsfEnum ssf = SsfEnum.getSsf( name );
+            String name = Strings.trim( ssf.substring( 0, pos ) );
+            SsfFeatureEnum ssfFeature = SsfFeatureEnum.getSsf( name );
             
-            if ( ssf == SsfEnum.NONE )
+            if ( ssfFeature == SsfFeatureEnum.NONE )
             {
                 return false;
             }
             else
             {
-                String value = Strings.trim( feature.substring( pos + 1 ) );
+                String value = Strings.trim( ssf.substring( pos + 1 ) );
                 
                 try
                 {
@@ -163,13 +175,22 @@ public class SsfWrapper implements Clone
     /**
      * @return the feature
      */
-    public SsfEnum getFeature()
+    public SsfFeatureEnum getFeature()
     {
         return feature;
     }
 
 
     /**
+     * @param feature the feature to set
+     */
+    public void setFeature( SsfFeatureEnum feature )
+    {
+        this.feature = feature;
+    }
+
+
+    /**
      * @return the nbBits
      */
     public int getNbBits()
@@ -179,6 +200,15 @@ public class SsfWrapper implements Clone
     
     
     /**
+     * @param nbBits the nbBits to set
+     */
+    public void setNbBits( int nbBits )
+    {
+        this.nbBits = nbBits;
+    }
+
+
+    /**
      * @see Object#equals()
      */
     public boolean equals( Object that )
@@ -193,7 +223,8 @@ public class SsfWrapper implements Clone
             return false;
         }
         
-        return ( feature == ((SsfWrapper)that).getFeature() ) && ( nbBits == ((SsfWrapper)that).getNbBits()
);
+        // We don't use the nbBits
+        return ( feature == ((SsfWrapper)that).getFeature() );
     }
     
     
@@ -204,8 +235,8 @@ public class SsfWrapper implements Clone
     {
         int h = 37;
         
+        // We don't use the nbBits
         h += h*17 + feature.hashCode();
-        h += h*17 + nbBits;
         
         return h;
     }
@@ -232,7 +263,7 @@ public class SsfWrapper implements Clone
      */
     public String toString()
     {
-        if ( feature != SsfEnum.NONE )
+        if ( feature != SsfFeatureEnum.NONE )
         {
             return feature.getText() + '=' + nbBits;
         }

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/test/java/org/apache/directory/studio/openldap/config/wrappers/SsfWrapperTest.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/test/java/org/apache/directory/studio/openldap/config/wrappers/SsfWrapperTest.java?rev=1684847&r1=1684846&r2=1684847&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/test/java/org/apache/directory/studio/openldap/config/wrappers/SsfWrapperTest.java
(original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/test/java/org/apache/directory/studio/openldap/config/wrappers/SsfWrapperTest.java
Thu Jun 11 10:17:28 2015
@@ -23,7 +23,7 @@ import static org.junit.Assert.assertEqu
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.assertFalse;
 
-import org.apache.directory.studio.openldap.common.ui.model.SsfEnum;
+import org.apache.directory.studio.openldap.common.ui.model.SsfFeatureEnum;
 import org.apache.directory.studio.openldap.config.editor.wrappers.SsfWrapper;
 import org.junit.Test;
 
@@ -71,15 +71,15 @@ public class SsfWrapperTest
     public void testCreateSsf()
     {
         SsfWrapper ssfWrapper = new SsfWrapper( "ssf", 128 );
-        assertEquals( SsfEnum.SSF, ssfWrapper.getFeature() );
+        assertEquals( SsfFeatureEnum.SSF, ssfWrapper.getFeature() );
         assertEquals( 128, ssfWrapper.getNbBits() );
 
         ssfWrapper = new SsfWrapper( "ssf", -128 );
-        assertEquals( SsfEnum.SSF, ssfWrapper.getFeature() );
+        assertEquals( SsfFeatureEnum.SSF, ssfWrapper.getFeature() );
         assertEquals( 0, ssfWrapper.getNbBits() );
 
         ssfWrapper = new SsfWrapper( "SSF", 128 );
-        assertEquals( SsfEnum.SSF, ssfWrapper.getFeature() );
+        assertEquals( SsfFeatureEnum.SSF, ssfWrapper.getFeature() );
         assertEquals( 128, ssfWrapper.getNbBits() );
     }
 }



Mime
View raw message