directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r1214281 - in /directory/studio/trunk/plugins: connection.core/src/main/java/org/apache/directory/studio/connection/core/ connection.core/src/main/java/org/apache/directory/studio/connection/core/io/ connection.core/src/main/java/org/apache...
Date Wed, 14 Dec 2011 14:59:26 GMT
Author: pamarcelot
Date: Wed Dec 14 14:59:25 2011
New Revision: 1214281

URL: http://svn.apache.org/viewvc?rev=1214281&view=rev
Log:
Fix for DIRSTUDIO-413 (Add possibility to make connections read-only).

Modified:
    directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/ConnectionIO.java
    directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/DirectoryApiConnectionWrapper.java
    directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java
    directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/messages.properties
    directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java
    directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/messages.properties
    directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/messages_de.properties
    directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/messages_fr.properties

Modified: directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/ConnectionIO.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/ConnectionIO.java?rev=1214281&r1=1214280&r2=1214281&view=diff
==============================================================================
--- directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/ConnectionIO.java
(original)
+++ directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/ConnectionIO.java
Wed Dec 14 14:59:25 2011
@@ -77,6 +77,7 @@ public class ConnectionIO
     private static final String KRB5_REALM_TAG = "krb5Realm"; //$NON-NLS-1$
     private static final String KRB5_KDC_HOST_TAG = "krb5KdcHost"; //$NON-NLS-1$
     private static final String KRB5_KDC_PORT_TAG = "krb5KdcPort"; //$NON-NLS-1$
+    private static final String READ_ONLY_TAG = "readOnly"; //$NON-NLS-1$
 
     private static final String EXTENDED_PROPERTIES_TAG = "extendedProperties"; //$NON-NLS-1$
     private static final String EXTENDED_PROPERTY_TAG = "extendedProperty"; //$NON-NLS-1$
@@ -265,7 +266,16 @@ public class ConnectionIO
             }
             else
             {
-                connection.setSaslQop( SaslQoP.valueOf( saslQopAttribute.getValue() ) );
+                try
+                {
+                    connection.setSaslQop( SaslQoP.valueOf( saslQopAttribute.getValue() )
);
+                }
+                catch ( IllegalArgumentException e )
+                {
+                    throw new ConnectionIOException( "Unable to parse 'SASL Quality of Protection'
of connection '" //$NON-NLS-1$
+                        + connection.getName() + "' as int value. SASL Quality of Protection
value :" //$NON-NLS-1$
+                        + saslQopAttribute.getValue() );
+                }
             }
         }
 
@@ -273,7 +283,16 @@ public class ConnectionIO
         Attribute saslSecStrengthAttribute = element.attribute( SASL_SEC_STRENGTH_TAG );
         if ( saslSecStrengthAttribute != null )
         {
-            connection.setSaslSecurityStrength( SaslSecurityStrength.valueOf( saslSecStrengthAttribute.getValue()
) );
+            try
+            {
+                connection.setSaslSecurityStrength( SaslSecurityStrength.valueOf( saslSecStrengthAttribute.getValue()
) );
+            }
+            catch ( IllegalArgumentException e )
+            {
+                throw new ConnectionIOException( "Unable to parse 'SASL Security Strength'
of connection '" //$NON-NLS-1$
+                    + connection.getName() + "' as int value. SASL Security Strength value
:" //$NON-NLS-1$
+                    + saslSecStrengthAttribute.getValue() );
+            }
         }
 
         // SASL Mutual Authentication
@@ -287,15 +306,33 @@ public class ConnectionIO
         Attribute krb5CredentialsConf = element.attribute( KRB5_CREDENTIALS_CONF_TAG );
         if ( krb5CredentialsConf != null )
         {
-            connection.setKrb5CredentialConfiguration( Krb5CredentialConfiguration.valueOf(
krb5CredentialsConf
-                .getValue() ) );
+            try
+            {
+                connection.setKrb5CredentialConfiguration( Krb5CredentialConfiguration.valueOf(
krb5CredentialsConf
+                    .getValue() ) );
+            }
+            catch ( IllegalArgumentException e )
+            {
+                throw new ConnectionIOException( "Unable to parse 'KRB5 Credentials Conf'
of connection '" //$NON-NLS-1$
+                    + connection.getName() + "' as int value. KRB5 Credentials Conf value
:" //$NON-NLS-1$
+                    + krb5CredentialsConf.getValue() );
+            }
         }
 
         // KRB5 Configuration
         Attribute krb5Config = element.attribute( KRB5_CONFIG_TAG );
         if ( krb5Config != null )
         {
-            connection.setKrb5Configuration( Krb5Configuration.valueOf( krb5Config.getValue()
) );
+            try
+            {
+                connection.setKrb5Configuration( Krb5Configuration.valueOf( krb5Config.getValue()
) );
+            }
+            catch ( IllegalArgumentException e )
+            {
+                throw new ConnectionIOException( "Unable to parse 'KRB5 Configuration' of
connection '" //$NON-NLS-1$
+                    + connection.getName() + "' as int value. KRB5 Configuration value :"
//$NON-NLS-1$
+                    + krb5Config.getValue() );
+            }
         }
 
         // KRB5 Configuration File
@@ -323,7 +360,22 @@ public class ConnectionIO
         Attribute krb5KdcPort = element.attribute( KRB5_KDC_PORT_TAG );
         if ( krb5KdcPort != null )
         {
-            connection.setKrb5KdcPort( Integer.valueOf( krb5KdcPort.getValue() ) );
+            try
+            {
+                connection.setKrb5KdcPort( Integer.valueOf( krb5KdcPort.getValue() ) );
+            }
+            catch ( NumberFormatException e )
+            {
+                throw new ConnectionIOException( "Unable to parse 'KRB5 KDC Port' of connection
'" + connection.getName() //$NON-NLS-1$
+                    + "' as int value. KRB5 KDC Port value :" + krb5KdcPort.getValue() );
//$NON-NLS-1$
+            }
+        }
+
+        // Read Only
+        Attribute readOnly = element.attribute( READ_ONLY_TAG );
+        if ( readOnly != null )
+        {
+            connection.setReadOnly( Boolean.parseBoolean( readOnly.getValue() ) );
         }
 
         // Extended Properties
@@ -453,6 +505,9 @@ public class ConnectionIO
         // KRB5 KDC Port
         connectionElement.addAttribute( KRB5_KDC_PORT_TAG, "" + connection.getKrb5KdcPort()
); //$NON-NLS-1$
 
+        // Read Only
+        connectionElement.addAttribute( READ_ONLY_TAG, "" + connection.isReadOnly() ); //$NON-NLS-1$
+
         // Extended Properties
         Element extendedPropertiesElement = connectionElement.addElement( EXTENDED_PROPERTIES_TAG
);
         Map<String, String> extendedProperties = connection.getExtendedProperties();

Modified: directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/DirectoryApiConnectionWrapper.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/DirectoryApiConnectionWrapper.java?rev=1214281&r1=1214280&r2=1214281&view=diff
==============================================================================
--- directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/DirectoryApiConnectionWrapper.java
(original)
+++ directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/DirectoryApiConnectionWrapper.java
Wed Dec 14 14:59:25 2011
@@ -675,7 +675,8 @@ public class DirectoryApiConnectionWrapp
     {
         if ( connection.isReadOnly() )
         {
-            monitor.reportError( NLS.bind( Messages.error__connection_is_readonly, connection.getName()
) );
+            monitor
+                .reportError( new Exception( NLS.bind( Messages.error__connection_is_readonly,
connection.getName() ) ) );
             return;
         }
 
@@ -817,7 +818,8 @@ public class DirectoryApiConnectionWrapp
     {
         if ( connection.isReadOnly() )
         {
-            monitor.reportError( NLS.bind( Messages.error__connection_is_readonly, connection.getName()
) );
+            monitor
+                .reportError( new Exception( NLS.bind( Messages.error__connection_is_readonly,
connection.getName() ) ) );
             return;
         }
 
@@ -888,7 +890,8 @@ public class DirectoryApiConnectionWrapp
     {
         if ( connection.isReadOnly() )
         {
-            monitor.reportError( NLS.bind( Messages.error__connection_is_readonly, connection.getName()
) );
+            monitor
+                .reportError( new Exception( NLS.bind( Messages.error__connection_is_readonly,
connection.getName() ) ) );
             return;
         }
 
@@ -956,7 +959,8 @@ public class DirectoryApiConnectionWrapp
     {
         if ( connection.isReadOnly() )
         {
-            monitor.reportError( NLS.bind( Messages.error__connection_is_readonly, connection.getName()
) );
+            monitor
+                .reportError( new Exception( NLS.bind( Messages.error__connection_is_readonly,
connection.getName() ) ) );
             return;
         }
 

Modified: directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java?rev=1214281&r1=1214280&r2=1214281&view=diff
==============================================================================
--- directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java
(original)
+++ directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java
Wed Dec 14 14:59:25 2011
@@ -433,7 +433,8 @@ public class JNDIConnectionWrapper imple
     {
         if ( connection.isReadOnly() )
         {
-            monitor.reportError( NLS.bind( Messages.error__connection_is_readonly, connection.getName()
) );
+            monitor
+                .reportError( new Exception( NLS.bind( Messages.error__connection_is_readonly,
connection.getName() ) ) );
             return;
         }
 
@@ -539,7 +540,8 @@ public class JNDIConnectionWrapper imple
     {
         if ( connection.isReadOnly() )
         {
-            monitor.reportError( NLS.bind( Messages.error__connection_is_readonly, connection.getName()
) );
+            monitor
+                .reportError( new Exception( NLS.bind( Messages.error__connection_is_readonly,
connection.getName() ) ) );
             return;
         }
 
@@ -645,7 +647,8 @@ public class JNDIConnectionWrapper imple
     {
         if ( connection.isReadOnly() )
         {
-            monitor.reportError( NLS.bind( Messages.error__connection_is_readonly, connection.getName()
) );
+            monitor
+                .reportError( new Exception( NLS.bind( Messages.error__connection_is_readonly,
connection.getName() ) ) );
             return;
         }
 
@@ -747,7 +750,8 @@ public class JNDIConnectionWrapper imple
     {
         if ( connection.isReadOnly() )
         {
-            monitor.reportError( NLS.bind( Messages.error__connection_is_readonly, connection.getName()
) );
+            monitor
+                .reportError( new Exception( NLS.bind( Messages.error__connection_is_readonly,
connection.getName() ) ) );
             return;
         }
 

Modified: directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/messages.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/messages.properties?rev=1214281&r1=1214280&r2=1214281&view=diff
==============================================================================
--- directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/messages.properties
(original)
+++ directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/messages.properties
Wed Dec 14 14:59:25 2011
@@ -24,7 +24,7 @@ error__unable_to_create_connection_liste
 error__unable_to_create_jndi_logger=Unable to create JNDI logger.
 error__unable_to_get_plugin_properties=Unable to get the plugin properties.
 error__loop_detected=Loop detected while following referral: {0} 
-error__connection_is_readonly=Connection '{0}' is read only.
+error__connection_is_readonly=Connection ''{0}'' is read only.
 error__untrusted_certificate=Untrusted certificate.
 
 model__no_auth_handler=No authentification handler

Modified: directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java?rev=1214281&r1=1214280&r2=1214281&view=diff
==============================================================================
--- directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java
(original)
+++ directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java
Wed Dec 14 14:59:25 2011
@@ -97,6 +97,9 @@ public class NetworkParameterPage extend
     /** The button to check the connection parameters */
     private Button checkConnectionButton;
 
+    /** The checkbox to make the connection read-only */
+    private Button readOnlyConnectionCheckbox;
+
 
     /**
      * Creates a new instance of NetworkParameterPage.
@@ -191,6 +194,17 @@ public class NetworkParameterPage extend
 
 
     /**
+     * Gets read only flag.
+     * 
+     * @return the read only flag
+     */
+    private boolean isReadOnly()
+    {
+        return readOnlyConnectionCheckbox.getSelection();
+    }
+
+
+    /**
      * {@inheritDoc}
      */
     protected void createComposite( Composite parent )
@@ -247,6 +261,9 @@ public class NetworkParameterPage extend
         checkConnectionButton.setLayoutData( gd );
         checkConnectionButton.setText( Messages.getString( "NetworkParameterPage.CheckNetworkParameter"
) ); //$NON-NLS-1$
 
+        readOnlyConnectionCheckbox = BaseWidgetUtils.createCheckbox( composite,
+            Messages.getString( "NetworkParameterPage.ReadOnly" ), 1 ); //$NON-NLS-1$
+
         nameText.setFocus();
     }
 
@@ -299,6 +316,7 @@ public class NetworkParameterPage extend
         encryptionMethodCombo.select( encryptionMethodIndex );
         int networkProviderIndex = parameter.getNetworkProvider() == NetworkProvider.JNDI
? 0 : 1;
         networkProviderCombo.select( networkProviderIndex );
+        readOnlyConnectionCheckbox.setSelection( parameter.isReadOnly() );
     }
 
 
@@ -372,6 +390,14 @@ public class NetworkParameterPage extend
                 }
             }
         } );
+
+        readOnlyConnectionCheckbox.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent event )
+            {
+                connectionPageModified();
+            }
+        } );
     }
 
 
@@ -385,6 +411,7 @@ public class NetworkParameterPage extend
         parameter.setPort( getPort() );
         parameter.setEncryptionMethod( getEncyrptionMethod() );
         parameter.setNetworkProvider( getNetworkProvider() );
+        parameter.setReadOnly( isReadOnly() );
     }
 
 
@@ -421,10 +448,12 @@ public class NetworkParameterPage extend
      */
     public boolean isReconnectionRequired()
     {
-        return connectionParameter == null || !StringUtils.equals( connectionParameter.getHost(),
getHostName() )
-            || connectionParameter.getPort() != getPort()
-            || connectionParameter.getEncryptionMethod() != getEncyrptionMethod()
-            || connectionParameter.getNetworkProvider() != getNetworkProvider();
+        return ( connectionParameter == null )
+            || ( !StringUtils.equals( connectionParameter.getHost(), getHostName() ) )
+            || ( connectionParameter.getPort() != getPort() )
+            || ( connectionParameter.getEncryptionMethod() != getEncyrptionMethod() )
+            || ( connectionParameter.getNetworkProvider() != getNetworkProvider() )
+            || ( connectionParameter.isReadOnly() != isReadOnly() );
     }
 
 

Modified: directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/messages.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/messages.properties?rev=1214281&r1=1214280&r2=1214281&view=diff
==============================================================================
--- directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/messages.properties
(original)
+++ directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/messages.properties
Wed Dec 14 14:59:25 2011
@@ -117,6 +117,7 @@ NetworkParameterPage.PleaseEnterConnecti
 NetworkParameterPage.PleaseEnterHostname          = Please enter a hostname.
 NetworkParameterPage.PleaseEnterPort              = Please enter a port. The default LDAP
port is 389.
 NetworkParameterPage.Port                         = Port:
+NetworkParameterPage.ReadOnly                     = Read-Only (prevents any add, delete,
modify or rename operation) 
 NetworkParameterPage.UseSSLEncryption             = Use SSL encryption (ldaps://)
 NetworkParameterPage.UseStartTLS                  = Use StartTLS extension
 NetworkParameterPage.WarningCertificateValidation = Warning:\nCertificate validation is disabled,
\nbe aware of invalid certificates or man-in-the-middle attacks!

Modified: directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/messages_de.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/messages_de.properties?rev=1214281&r1=1214280&r2=1214281&view=diff
==============================================================================
--- directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/messages_de.properties
(original)
+++ directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/messages_de.properties
Wed Dec 14 14:59:25 2011
@@ -114,6 +114,7 @@ NetworkParameterPage.NoEncryption       
 NetworkParameterPage.PleaseEnterConnectionName    = Geben Sie bitte einen Verbindungsnamen
ein.
 NetworkParameterPage.PleaseEnterHostname          = Geben Sie bitte einen Hostnamen ein.
 NetworkParameterPage.PleaseEnterPort              = Geben Sie bitte einen Port ein. LDAP
Standard ist Port 389.
+NetworkParameterPage.ReadOnly                     = TODO:Read-Only (prevents any add, delete,
modify or rename operation) 
 NetworkParameterPage.UseSSLEncryption             = SSL Verschl\u00FCsselung (ldaps://)
 NetworkParameterPage.UseStartTLS                  = StartTLS Erweiterung
 NetworkParameterPage.WarningCertificateValidation = Warnung:\nZertifikat Validierung ist
deaktiviert,\nsind Sie sich der Gefahr von ung\u00FCltigen Zertifikaten\noder 'man-in-the-middle'
Angriffen bewusst!

Modified: directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/messages_fr.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/messages_fr.properties?rev=1214281&r1=1214280&r2=1214281&view=diff
==============================================================================
--- directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/messages_fr.properties
(original)
+++ directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/messages_fr.properties
Wed Dec 14 14:59:25 2011
@@ -114,6 +114,7 @@ NetworkParameterPage.NoEncryption       
 NetworkParameterPage.PleaseEnterConnectionName    = Veuillez entrer un nom de connexion.
 NetworkParameterPage.PleaseEnterHostname          = Veuillez entrer un nom d'h\u00F4te.
 NetworkParameterPage.PleaseEnterPort              = Veuillez entrer un port. Le port par
d\u00E9fault pour LDAP est 389.
+NetworkParameterPage.ReadOnly                     = Lecture seule (emp\u00E8che toute op\u00E9ration
d'ajout, suppression, modification ou renommage) 
 NetworkParameterPage.UseSSLEncryption             = Utilise l'encryption SSL (ldaps://)
 NetworkParameterPage.UseStartTLS                  = Utilise l'extension StartTLS
 NetworkParameterPage.WarningCertificateValidation = Attention :\n La validation des certificats
est d\u00E9sactiv\u00E9e, \nm\u00E9fiez-vous des certificats invalides ou des attaques par
interposition (man-in-the-middle)!



Mime
View raw message