directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r696773 - in /directory/studio/trunk: connection-core/src/main/java/org/apache/directory/studio/connection/core/ connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/ connection-ui/src/main/java/org/apache/direc...
Date Thu, 18 Sep 2008 19:26:13 GMT
Author: seelmann
Date: Thu Sep 18 12:26:13 2008
New Revision: 696773

URL: http://svn.apache.org/viewvc?rev=696773&view=rev
Log:
Fix for DIRSTUDIO-228: mask userPassword in the log view

Modified:
    directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCoreConstants.java
    directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/LdifModificationLogger.java
    directory/studio/trunk/connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/BaseWidgetUtils.java
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/preferences/ModificationLogsPreferencePage.java

Modified: directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCoreConstants.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCoreConstants.java?rev=696773&r1=696772&r2=696773&view=diff
==============================================================================
--- directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCoreConstants.java
(original)
+++ directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCoreConstants.java
Thu Sep 18 12:26:13 2008
@@ -62,4 +62,7 @@
     /** The constant used to identify the "search log file size" preference  */
     public static final String PREFERENCE_SEARCHLOGS_FILE_SIZE = "searchLogsFileSize";
 
+    /** The constant used to identify the "masked attributes" preference  */
+    public static final String PREFERENCE_MODIFICATIONLOGS_MASKED_ATTRIBUTES = "modificationLogsMaskedAttributes";
+
 }

Modified: directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/LdifModificationLogger.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/LdifModificationLogger.java?rev=696773&r1=696772&r2=696773&view=diff
==============================================================================
--- directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/LdifModificationLogger.java
(original)
+++ directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/LdifModificationLogger.java
Thu Sep 18 12:26:13 2008
@@ -28,7 +28,9 @@
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
+import java.util.Set;
 import java.util.logging.FileHandler;
 import java.util.logging.Formatter;
 import java.util.logging.Handler;
@@ -273,6 +275,7 @@
 
         try
         {
+            Set<String> maskedAttributes = getMaskedAttributes();
             LdifChangeAddRecord record = new LdifChangeAddRecord( LdifDnLine.create( dn )
);
             addControlLines( record, controls );
             record.setChangeType( LdifChangeTypeLine.createAdd() );
@@ -285,13 +288,20 @@
                 while ( valueEnumeration.hasMore() )
                 {
                     Object o = valueEnumeration.next();
-                    if ( o instanceof String )
+                    if ( maskedAttributes.contains( attributeName.toLowerCase() ) )
                     {
-                        record.addAttrVal( LdifAttrValLine.create( attributeName, ( String
) o ) );
+                        record.addAttrVal( LdifAttrValLine.create( attributeName, "**********"
) );
                     }
-                    if ( o instanceof byte[] )
+                    else
                     {
-                        record.addAttrVal( LdifAttrValLine.create( attributeName, ( byte[]
) o ) );
+                        if ( o instanceof String )
+                        {
+                            record.addAttrVal( LdifAttrValLine.create( attributeName, ( String
) o ) );
+                        }
+                        if ( o instanceof byte[] )
+                        {
+                            record.addAttrVal( LdifAttrValLine.create( attributeName, ( byte[]
) o ) );
+                        }
                     }
                 }
             }
@@ -340,6 +350,7 @@
 
         try
         {
+            Set<String> maskedAttributes = getMaskedAttributes();
             LdifChangeModifyRecord record = new LdifChangeModifyRecord( LdifDnLine.create(
dn ) );
             addControlLines( record, controls );
             record.setChangeType( LdifChangeTypeLine.createModify() );
@@ -366,13 +377,20 @@
                 while ( valueEnumeration.hasMore() )
                 {
                     Object o = valueEnumeration.next();
-                    if ( o instanceof String )
+                    if ( maskedAttributes.contains( attributeDescription.toLowerCase() )
)
                     {
-                        modSpec.addAttrVal( LdifAttrValLine.create( attributeDescription,
( String ) o ) );
+                        modSpec.addAttrVal( LdifAttrValLine.create( attributeDescription,
"**********" ) );
                     }
-                    if ( o instanceof byte[] )
+                    else
                     {
-                        modSpec.addAttrVal( LdifAttrValLine.create( attributeDescription,
( byte[] ) o ) );
+                        if ( o instanceof String )
+                        {
+                            modSpec.addAttrVal( LdifAttrValLine.create( attributeDescription,
( String ) o ) );
+                        }
+                        if ( o instanceof byte[] )
+                        {
+                            modSpec.addAttrVal( LdifAttrValLine.create( attributeDescription,
( byte[] ) o ) );
+                        }
                     }
                 }
                 modSpec.finish( LdifModSpecSepLine.create() );
@@ -593,6 +611,27 @@
     }
 
 
+    /**
+     * Gets the masked attributes.
+     * 
+     * @return the masked attributes
+     */
+    private Set<String> getMaskedAttributes()
+    {
+        Set<String> maskedAttributes = new HashSet<String>();
+
+        String maskedAttributeString = ConnectionCorePlugin.getDefault().getPluginPreferences().getString(
+            ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_MASKED_ATTRIBUTES );
+        String[] splitted = maskedAttributeString.split( "," );
+        for ( String s : splitted )
+        {
+            maskedAttributes.add( s.toLowerCase() );
+        }
+
+        return maskedAttributes;
+    }
+
+
     public String getId()
     {
         return id;

Modified: directory/studio/trunk/connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/BaseWidgetUtils.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/BaseWidgetUtils.java?rev=696773&r1=696772&r2=696773&view=diff
==============================================================================
--- directory/studio/trunk/connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/BaseWidgetUtils.java
(original)
+++ directory/studio/trunk/connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/BaseWidgetUtils.java
Thu Sep 18 12:26:13 2008
@@ -121,9 +121,9 @@
     public static Label createWrappedLabel( Composite parent, String text, int span )
     {
         Label l = new Label( parent, SWT.WRAP );
-        GridData gd = new GridData();
+        GridData gd = new GridData( GridData.HORIZONTAL_ALIGN_FILL );
         gd.horizontalSpan = span;
-        // gd.verticalAlignment = SWT.BEGINNING;
+        gd.widthHint = 100;
         l.setLayoutData( gd );
         l.setText( text );
         return l;
@@ -293,6 +293,7 @@
         return t;
     }
 
+
     /**
      * Creates a SWT {@link Text} under the given parent.
      * The created text control behaves like a label: it has no border, 
@@ -306,7 +307,7 @@
      * @param widthHint the width hint
      * @return the created text
      */
-    public static Text createWrappedLabeledText( Composite parent, String text, int span,
int widthHint  )
+    public static Text createWrappedLabeledText( Composite parent, String text, int span,
int widthHint )
     {
         Text t = new Text( parent, SWT.WRAP );
         GridData gd = new GridData( GridData.FILL_HORIZONTAL );
@@ -321,6 +322,7 @@
         return t;
     }
 
+
     /**
      * Creates a SWT {@link Text} under the given parent.
      * The text is not modifyable, but the text is selectable 

Modified: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/preferences/ModificationLogsPreferencePage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/preferences/ModificationLogsPreferencePage.java?rev=696773&r1=696772&r2=696773&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/preferences/ModificationLogsPreferencePage.java
(original)
+++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/preferences/ModificationLogsPreferencePage.java
Thu Sep 18 12:26:13 2008
@@ -50,6 +50,7 @@
     private Button enableModificationLogging;
     private Text logFileCountText;
     private Text logFileSizeText;
+    private Text maskedAttributesText;
 
 
     /**
@@ -84,6 +85,22 @@
         enableModificationLogging.setSelection( ConnectionCorePlugin.getDefault().getPluginPreferences().getBoolean(
             ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_ENABLE ) );
 
+        BaseWidgetUtils.createSpacer( composite, 1 );
+        BaseWidgetUtils.createSpacer( composite, 1 );
+
+        Group maskedAttributesGroup = BaseWidgetUtils.createGroup( BaseWidgetUtils.createColumnContainer(
composite, 1,
+            1 ), "Masked Attributes", 1 );
+        Composite maskedAttributesComposite = BaseWidgetUtils.createColumnContainer( maskedAttributesGroup,
1, 1 );
+        maskedAttributesText = BaseWidgetUtils.createText( maskedAttributesComposite, "",
1 );
+        maskedAttributesText.setText( ConnectionCorePlugin.getDefault().getPluginPreferences().getString(
+            ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_MASKED_ATTRIBUTES ) );
+        String maskedAttributesHelp = "Enter a comma-separated list of attributes that should
be masked in the modification logs. "
+            + "A typical attribute to mask is userPassword.";
+        BaseWidgetUtils.createWrappedLabel( maskedAttributesComposite, maskedAttributesHelp,
1 );
+
+        BaseWidgetUtils.createSpacer( composite, 1 );
+        BaseWidgetUtils.createSpacer( composite, 1 );
+
         Group rotateGroup = BaseWidgetUtils.createGroup( BaseWidgetUtils.createColumnContainer(
composite, 1, 1 ),
             "Log File Rotation", 1 );
         Composite rotateComposite = BaseWidgetUtils.createColumnContainer( rotateGroup, 5,
1 );
@@ -141,6 +158,8 @@
             ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_FILE_COUNT, logFileCountText.getText()
);
         ConnectionCorePlugin.getDefault().getPluginPreferences().setValue(
             ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_FILE_SIZE, logFileSizeText.getText()
);
+        ConnectionCorePlugin.getDefault().getPluginPreferences().setValue(
+            ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_MASKED_ATTRIBUTES, maskedAttributesText.getText()
);
         return true;
     }
 
@@ -156,6 +175,8 @@
             ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_FILE_COUNT ) );
         logFileSizeText.setText( ConnectionCorePlugin.getDefault().getPluginPreferences().getDefaultString(
             ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_FILE_SIZE ) );
+        maskedAttributesText.setText( ConnectionCorePlugin.getDefault().getPluginPreferences().getDefaultString(
+            ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_MASKED_ATTRIBUTES ) );
         super.performDefaults();
     }
 



Mime
View raw message