You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2019/04/30 08:51:11 UTC

[directory-server] branch master updated (453b479 -> 2eab73c)

This is an automated email from the ASF dual-hosted git repository.

elecharny pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/directory-server.git.


    from 453b479  Fix flaky test
     new d97871c  Applied PR #2 (Upgrade signature hash of generate key)
     new 2eab73c  Fixed some compilation issues due to some update in LDAP API. Added a test for the Modify increment extension

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../core/operations/modify/ModifyIncrementIT.java  | 157 +++++++++++++++++++++
 .../server/core/security/TlsKeyGenerator.java      |   4 +-
 .../server/core/authn/DelegatingAuthenticator.java |  10 +-
 .../shared/client/api/operations/bind/Test.java    |  10 +-
 4 files changed, 162 insertions(+), 19 deletions(-)
 create mode 100644 core-integ/src/test/java/org/apache/directory/server/core/operations/modify/ModifyIncrementIT.java


[directory-server] 01/02: Applied PR #2 (Upgrade signature hash of generate key)

Posted by el...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

elecharny pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/directory-server.git

commit d97871c6a6045443248e249c899b2f2c3e3e5767
Author: emmanuel lecharny <el...@apache.org>
AuthorDate: Tue Apr 30 10:50:06 2019 +0200

    Applied PR #2 (Upgrade signature hash of generate key)
---
 .../org/apache/directory/server/core/security/TlsKeyGenerator.java    | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/core/src/main/java/org/apache/directory/server/core/security/TlsKeyGenerator.java b/core/src/main/java/org/apache/directory/server/core/security/TlsKeyGenerator.java
index c6e2188..9404cf6 100644
--- a/core/src/main/java/org/apache/directory/server/core/security/TlsKeyGenerator.java
+++ b/core/src/main/java/org/apache/directory/server/core/security/TlsKeyGenerator.java
@@ -94,7 +94,7 @@ public final class TlsKeyGenerator
      * 
      *    http://www.apache.org/licenses/exports
      */
-    private static final int KEY_SIZE = 512;
+    private static final int KEY_SIZE = 1024;
     public static final long YEAR_MILLIS = 365L * 24L * 3600L * 1000L;
 
     static
@@ -307,7 +307,7 @@ public final class TlsKeyGenerator
         certGen.setNotAfter( expiryDate );
         certGen.setSubjectDN( subjectName );
         certGen.setPublicKey( publicKey );
-        certGen.setSignatureAlgorithm( "SHA1With" + keyAlgo );
+        certGen.setSignatureAlgorithm( "SHA256With" + keyAlgo );
         
 
         try


[directory-server] 02/02: Fixed some compilation issues due to some update in LDAP API. Added a test for the Modify increment extension

Posted by el...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

elecharny pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/directory-server.git

commit 2eab73ccc822a3f769669f635bfbe461d3ad4ef3
Author: emmanuel lecharny <el...@apache.org>
AuthorDate: Tue Apr 30 10:51:02 2019 +0200

    Fixed some compilation issues due to some update in LDAP API. Added a test for the Modify increment extension
---
 .../core/operations/modify/ModifyIncrementIT.java  | 157 +++++++++++++++++++++
 .../server/core/authn/DelegatingAuthenticator.java |  10 +-
 .../shared/client/api/operations/bind/Test.java    |  10 +-
 3 files changed, 160 insertions(+), 17 deletions(-)

diff --git a/core-integ/src/test/java/org/apache/directory/server/core/operations/modify/ModifyIncrementIT.java b/core-integ/src/test/java/org/apache/directory/server/core/operations/modify/ModifyIncrementIT.java
new file mode 100644
index 0000000..ce66c9c
--- /dev/null
+++ b/core-integ/src/test/java/org/apache/directory/server/core/operations/modify/ModifyIncrementIT.java
@@ -0,0 +1,157 @@
+/*
+ *  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.server.core.operations.modify;
+
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.directory.api.ldap.model.entry.Attribute;
+import org.apache.directory.api.ldap.model.entry.DefaultAttribute;
+import org.apache.directory.api.ldap.model.entry.DefaultModification;
+import org.apache.directory.api.ldap.model.entry.Entry;
+import org.apache.directory.api.ldap.model.entry.Modification;
+import org.apache.directory.api.ldap.model.entry.ModificationOperation;
+import org.apache.directory.api.ldap.model.message.ModifyRequest;
+import org.apache.directory.api.ldap.model.message.ModifyRequestImpl;
+import org.apache.directory.api.ldap.model.name.Dn;
+import org.apache.directory.ldap.client.api.LdapConnection;
+import org.apache.directory.server.core.annotations.ApplyLdifs;
+import org.apache.directory.server.core.annotations.CreateDS;
+import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
+import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.server.core.integ.IntegrationUtils;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+ 
+
+/**
+ * Tests the modify() methods of the provider, for the Increment operation.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@RunWith ( FrameworkRunner.class )
+@CreateDS(name = "ModifyAddIT")
+@ApplyLdifs(
+    {
+        "dn: m-oid=2.2.0, ou=attributeTypes, cn=apachemeta, ou=schema",
+        "objectclass: metaAttributeType",
+        "objectclass: metaTop",
+        "objectclass: top",
+        "m-oid: 2.2.0",
+        "m-name: integerAttribute",
+        "m-description: the precursor for all integer attributes",
+        "m-equality: integerMatch",
+        "m-ordering: integerOrderingMatch",
+        "m-syntax: 1.3.6.1.4.1.1466.115.121.1.27",
+        "m-length: 0",
+        "",
+        "dn: ou=testing00,ou=system",
+        "objectClass: top",
+        "objectClass: organizationalUnit",
+        "objectClass: extensibleObject",
+        "ou: testing00",
+        "integerAttribute: 0",
+        "",
+        "dn: ou=testing01,ou=system",
+        "objectClass: top",
+        "objectClass: organizationalUnit",
+        "objectClass: extensibleObject",
+        "ou: testing01",
+        "integerAttribute: 2147483647",     // Integer.MAX_VALUE
+    }
+)
+public class ModifyIncrementIT extends AbstractLdapTestUnit
+{
+    //---------------------------------------------------------------------------------------------
+    // Increment operation
+    //---------------------------------------------------------------------------------------------
+    // 1 Entry exists
+    //  1.1 AT does not exist.
+    //  1.2 AT exists but is not an Integer
+    //  1.3 AT exists and is an Integer
+    //  1.4 AT exists and is an Integer, but its value is INTEGER.MAX
+    //---------------------------------------------------------------------------------------------
+    @Test
+    public void testModifyIncrement() throws Exception
+    {
+        LdapConnection connection = IntegrationUtils.getAdminConnection( getService() );
+        Dn dn = new Dn( "ou=testing00,ou=system" );
+
+        ModifyRequest modRequest = new ModifyRequestImpl();
+        modRequest.setName( dn );
+        Modification modification = new DefaultModification();
+        Attribute attribute = new DefaultAttribute( "integerAttribute" );
+
+        modification.setAttribute( attribute );
+        modification.setOperation( ModificationOperation.INCREMENT_ATTRIBUTE );
+        modRequest.addModification( modification );
+
+        connection.modify( modRequest );
+
+        // Verify that the attribute value has been incremented
+        Entry modified = connection.lookup( dn );
+        
+        assertEquals( "1", modified.get( "integerAttribute" ).getString() );
+
+        // Do it again 10 times
+        for ( int i=0; i < 10; i++ ) 
+        {
+            connection.modify( modRequest );
+        }
+
+        modified = connection.lookup( dn );
+        
+        assertEquals( "11", modified.get( "integerAttribute" ).getString() );
+    }
+    
+    
+    @Test
+    public void testModifyIncrementNumber() throws Exception
+    {
+        LdapConnection connection = IntegrationUtils.getAdminConnection( getService() );
+        Dn dn = new Dn( "ou=testing00,ou=system" );
+
+        ModifyRequest modRequest = new ModifyRequestImpl();
+        modRequest.setName( dn );
+        Modification modification = new DefaultModification();
+        Attribute attribute = new DefaultAttribute( "integerAttribute", "3" );
+
+        modification.setAttribute( attribute );
+        modification.setOperation( ModificationOperation.INCREMENT_ATTRIBUTE );
+        modRequest.addModification( modification );
+
+        connection.modify( modRequest );
+
+        // Verify that the attribute value has been incremented
+        Entry modified = connection.lookup( dn );
+        
+        assertEquals( "3", modified.get( "integerAttribute" ).getString() );
+
+        // Do it again 10 times
+        for ( int i=0; i < 10; i++ ) 
+        {
+            connection.modify( modRequest );
+        }
+
+        modified = connection.lookup( dn );
+        
+        assertEquals( "33", modified.get( "integerAttribute" ).getString() );
+    }
+}
diff --git a/interceptors/authn/src/main/java/org/apache/directory/server/core/authn/DelegatingAuthenticator.java b/interceptors/authn/src/main/java/org/apache/directory/server/core/authn/DelegatingAuthenticator.java
index 4650a9d..1dd8773 100644
--- a/interceptors/authn/src/main/java/org/apache/directory/server/core/authn/DelegatingAuthenticator.java
+++ b/interceptors/authn/src/main/java/org/apache/directory/server/core/authn/DelegatingAuthenticator.java
@@ -20,7 +20,6 @@
 package org.apache.directory.server.core.authn;
 
 
-import java.io.IOException;
 import java.net.SocketAddress;
 
 import org.apache.directory.api.ldap.model.constants.AuthenticationLevel;
@@ -321,14 +320,7 @@ public class DelegatingAuthenticator extends AbstractAuthenticator
         }
         finally
         {
-            try
-            {
-                ldapConnection.close();
-            }
-            catch ( IOException ioe )
-            {
-                throw new LdapException( ioe.getMessage(), ioe );
-            }
+            ldapConnection.close();
         }
     }
 
diff --git a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/Test.java b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/Test.java
index 9c01e49..5e162e7 100644
--- a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/Test.java
+++ b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/Test.java
@@ -26,7 +26,6 @@ package org.apache.directory.shared.client.api.operations.bind;
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-import java.io.IOException;
 import java.security.KeyStore;
 import java.security.KeyStoreException;
 import java.security.NoSuchAlgorithmException;
@@ -52,7 +51,7 @@ public class Test
     public SaslGssApiRequest saslGssApiRequest;
 
 
-    public static void main( String[] args ) throws LdapException, CursorException, IOException,
+    public static void main( String[] args ) throws LdapException, CursorException,
         NoSuchAlgorithmException, CertificateException, KeyStoreException
     {
         String keystore = "C:\\bea\\jrockit_160_05\\jre\\lib\\security\\ETHIXNetAdmin.pfx";
@@ -144,14 +143,9 @@ public class Test
             ldapNetworkConnection.unBind();
             ldapNetworkConnection.close();
         }
-        catch ( IOException e )
-        {
-            e.printStackTrace();
-        }
-
         catch ( LdapException e )
         {
             e.printStackTrace();
         }
     }
-}
\ No newline at end of file
+}