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 2017/11/28 22:56:56 UTC

[directory-ldap-api] branch shared-value updated (1c8afb1 -> c5192d9)

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

elecharny pushed a change to branch shared-value
in repository https://gitbox.apache.org/repos/asf/directory-ldap-api.git.


    from 1c8afb1  Deal with the special case of empty HR attribute values : they were converted to byte[], leading to an error
     new 588ad97  Added the EXTERNAL mechanism
     new 496804d  o Fix for DIRSTUDIO-1160 (the isHR flag is set to TRUE by default) o Creted an initialize( AT ) method to simplify Value creations
     new c5192d9  Added support for SASL EXTERNAL (DIRAPI-105)

The 3 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:
 .../ldap/client/api/LdapNetworkConnection.java     |  57 ++++++++++++
 ...estMd5Request.java => SaslExternalRequest.java} |  23 +++--
 .../model/constants/SupportedSaslMechanisms.java   |   3 +
 .../directory/api/ldap/model/entry/Value.java      | 103 +++++----------------
 4 files changed, 92 insertions(+), 94 deletions(-)
 copy ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/{SaslDigestMd5Request.java => SaslExternalRequest.java} (70%)

-- 
To stop receiving notification emails like this one, please contact
['"commits@directory.apache.org" <co...@directory.apache.org>'].

[directory-ldap-api] 03/03: Added support for SASL EXTERNAL (DIRAPI-105)

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

elecharny pushed a commit to branch shared-value
in repository https://gitbox.apache.org/repos/asf/directory-ldap-api.git

commit c5192d9feb1ef0563a4690bf40b0fac7374e788d
Author: Emmanuel Lécharny <el...@symas.com>
AuthorDate: Tue Nov 28 23:49:34 2017 +0100

    Added support for SASL EXTERNAL (DIRAPI-105)
---
 .../ldap/client/api/LdapNetworkConnection.java     | 57 ++++++++++++++++++++++
 .../ldap/client/api/SaslExternalRequest.java       | 51 +++++++++++++++++++
 2 files changed, 108 insertions(+)

diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
index 8f9d138..e43a8f2 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
@@ -1707,6 +1707,63 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements Lda
 
 
     /**
+     * Bind to the server using a SaslExternalRequest object.
+     *
+     * @param request The SaslExternalRequest POJO containing all the needed parameters
+     * @return A LdapResponse containing the result
+     * @throws LdapException if some error occurred
+     */
+    public BindResponse bind( SaslExternalRequest request ) throws LdapException
+    {
+        if ( request == null )
+        {
+            String msg = "Cannot process a null request";
+            LOG.debug( msg );
+            throw new IllegalArgumentException( msg );
+        }
+
+        BindFuture bindFuture = bindAsync( request );
+
+        // Get the result from the future
+        try
+        {
+            // Read the response, waiting for it if not available immediately
+            // Get the response, blocking
+            BindResponse bindResponse = bindFuture.get( timeout, TimeUnit.MILLISECONDS );
+
+            if ( bindResponse == null )
+            {
+                // We didn't received anything : this is an error
+                LOG.error( "Bind failed : timeout occurred" );
+                throw new LdapException( TIME_OUT_ERROR );
+            }
+
+            if ( bindResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
+            {
+                authenticated.set( true );
+
+                // Everything is fine, return the response
+                LOG.debug( "Bind successful : {}", bindResponse );
+            }
+            else
+            {
+                // We have had an error
+                LOG.debug( "Bind failed : {}", bindResponse );
+            }
+
+            return bindResponse;
+        }
+        catch ( Exception ie )
+        {
+            // Catch all other exceptions
+            LOG.error( NO_RESPONSE_ERROR, ie );
+
+            throw new LdapException( NO_RESPONSE_ERROR, ie );
+        }
+    }
+
+
+    /**
      * Do an asynchronous bind, based on a GssApiRequest.
      *
      * @param request The GssApiRequest POJO containing all the needed parameters
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SaslExternalRequest.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SaslExternalRequest.java
new file mode 100644
index 0000000..c438d47
--- /dev/null
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SaslExternalRequest.java
@@ -0,0 +1,51 @@
+/*
+ *   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.ldap.client.api;
+
+
+import org.apache.directory.api.ldap.model.constants.SupportedSaslMechanisms;
+
+
+/**
+ * Holds the data required to complete the EXTERNAL SASL operation
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class SaslExternalRequest extends AbstractSaslRequest
+{
+    /**
+     * Creates a new instance of SaslExternalRequest.
+     */
+    public SaslExternalRequest()
+    {
+        super( SupportedSaslMechanisms.EXTERNAL );
+    }
+
+    
+    /**
+     * Creates a new instance of SaslExternalRequest.
+     */
+    public SaslExternalRequest( String authzId )
+    {
+        super( SupportedSaslMechanisms.EXTERNAL );
+        this.authorizationId = authzId;
+    }
+}

-- 
To stop receiving notification emails like this one, please contact
"commits@directory.apache.org" <co...@directory.apache.org>.

[directory-ldap-api] 02/03: o Fix for DIRSTUDIO-1160 (the isHR flag is set to TRUE by default) o Creted an initialize( AT ) method to simplify Value creations

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

elecharny pushed a commit to branch shared-value
in repository https://gitbox.apache.org/repos/asf/directory-ldap-api.git

commit 496804d484472aa68d1b940dbb51fc3e853017c8
Author: Emmanuel Lécharny <el...@symas.com>
AuthorDate: Tue Nov 28 23:47:34 2017 +0100

    o Fix for DIRSTUDIO-1160 (the isHR flag is set to TRUE by default)
    o Creted an initialize( AT ) method to simplify Value creations
---
 .../directory/api/ldap/model/entry/Value.java      | 103 +++++----------------
 1 file changed, 21 insertions(+), 82 deletions(-)

diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/Value.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/Value.java
index 3dc6e03..818da76 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/Value.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/Value.java
@@ -108,8 +108,6 @@ public class Value implements Cloneable, Externalizable, Comparable<Value>
      */
     public Value( String upValue )
     {
-        isHR = true;
-        
         this.upValue = upValue;
         
         // We can't normalize the value, we store it as is
@@ -131,8 +129,6 @@ public class Value implements Cloneable, Externalizable, Comparable<Value>
      */
     public Value( byte[] value )
     {
-        isHR = false;
-        
         if ( value != null )
         {
             bytes = new byte[value.length];
@@ -157,7 +153,7 @@ public class Value implements Cloneable, Externalizable, Comparable<Value>
      */
     public Value( AttributeType attributeType, byte[] upValue ) throws LdapInvalidAttributeValueException
     {
-        isHR = false;
+        init( attributeType );
         
         if ( upValue != null )
         {
@@ -168,8 +164,6 @@ public class Value implements Cloneable, Externalizable, Comparable<Value>
         {
             bytes = null;
         }
-
-        this.attributeType = attributeType;
         
         if ( ( attributeType != null ) && !attributeType.isRelaxed() )
         {
@@ -192,18 +186,10 @@ public class Value implements Cloneable, Externalizable, Comparable<Value>
 
         hashCode();
     }
-
-
-    /**
-     * Creates a schema aware binary Value with an initial value. This method is
-     * only to be used by deserializers.
-     *
-     * @param attributeType the schema type associated with this Value
-     * @param value the value to wrap
-     */
-    /* Package protected*/ Value( AttributeType attributeType )
+    
+    
+    private void init( AttributeType attributeType )
     {
-        // The AttributeType must have a Syntax
         if ( attributeType != null )
         {
             if ( attributeType.getSyntax() == null )
@@ -222,9 +208,22 @@ public class Value implements Cloneable, Externalizable, Comparable<Value>
         {
             LOG.warn( "The attributeType is null" );
         }
-
+        
         this.attributeType = attributeType;
     }
+
+
+    /**
+     * Creates a schema aware binary Value with an initial value. This method is
+     * only to be used by deserializers.
+     *
+     * @param attributeType the schema type associated with this Value
+     * @param value the value to wrap
+     */
+    /* Package protected*/ Value( AttributeType attributeType )
+    {
+        init( attributeType );
+    }
     
     
     /**
@@ -237,27 +236,7 @@ public class Value implements Cloneable, Externalizable, Comparable<Value>
      */
     public Value( AttributeType attributeType, String upValue ) throws LdapInvalidAttributeValueException
     {
-        // The AttributeType must have a Syntax
-        if ( attributeType != null )
-        {
-            if ( attributeType.getSyntax() == null )
-            {
-                // Some broken LDAP servers do not have proper syntax definitions, default to HR
-                LOG.info( I18n.err( I18n.ERR_04445_NO_SYNTAX ) );
-                isHR = true;
-                //throw new IllegalArgumentException( I18n.err( I18n.ERR_04445_NO_SYNTAX ) );
-            }
-            else
-            {
-                isHR = attributeType.getSyntax().isHumanReadable();
-            }
-        }
-        else
-        {
-            throw new IllegalArgumentException( I18n.err( I18n.ERR_04488_NULL_ATTRIBUTE_TYPE ) );
-        }
-
-        this.attributeType = attributeType;
+        init( attributeType );
         this.upValue = upValue;
         
         if ( upValue != null )
@@ -312,27 +291,7 @@ public class Value implements Cloneable, Externalizable, Comparable<Value>
      */
     public Value( AttributeType attributeType, String upValue, String normValue ) throws LdapInvalidAttributeValueException
     {
-        // The AttributeType must have a Syntax
-        if ( attributeType != null )
-        {
-            if ( attributeType.getSyntax() == null )
-            {
-                // Some broken LDAP servers do not have proper syntax definitions, default to HR
-                LOG.info( I18n.err( I18n.ERR_04445_NO_SYNTAX ) );
-                isHR = true;
-                //throw new IllegalArgumentException( I18n.err( I18n.ERR_04445_NO_SYNTAX ) );
-            }
-            else
-            {
-                isHR = attributeType.getSyntax().isHumanReadable();
-            }
-        }
-        else
-        {
-            throw new IllegalArgumentException( I18n.err( I18n.ERR_04488_NULL_ATTRIBUTE_TYPE ) );
-        }
-
-        this.attributeType = attributeType;
+        init( attributeType );
         this.upValue = upValue;
         
         if ( upValue != null )
@@ -376,27 +335,7 @@ public class Value implements Cloneable, Externalizable, Comparable<Value>
      */
     public Value( AttributeType attributeType, Value value ) throws LdapInvalidAttributeValueException
     {
-        // The AttributeType must have a Syntax
-        if ( attributeType != null )
-        {
-            if ( attributeType.getSyntax() == null )
-            {
-                // Some broken LDAP servers do not have proper syntax definitions, default to HR
-                LOG.info( I18n.err( I18n.ERR_04445_NO_SYNTAX ) );
-                isHR = true;
-                //throw new IllegalArgumentException( I18n.err( I18n.ERR_04445_NO_SYNTAX ) );
-            }
-            else
-            {
-                isHR = attributeType.getSyntax().isHumanReadable();
-            }
-        }
-        else
-        {
-            throw new IllegalArgumentException( I18n.err( I18n.ERR_04488_NULL_ATTRIBUTE_TYPE ) );
-        }
-        
-        this.attributeType = attributeType;
+        init( attributeType );
         
         if ( isHR )
         {

-- 
To stop receiving notification emails like this one, please contact
"commits@directory.apache.org" <co...@directory.apache.org>.

[directory-ldap-api] 01/03: Added the EXTERNAL mechanism

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

elecharny pushed a commit to branch shared-value
in repository https://gitbox.apache.org/repos/asf/directory-ldap-api.git

commit 588ad9719ca92bd70249d1d74a0c26e6209af9fb
Author: Emmanuel Lécharny <el...@symas.com>
AuthorDate: Tue Nov 28 23:38:16 2017 +0100

    Added the EXTERNAL mechanism
---
 .../directory/api/ldap/model/constants/SupportedSaslMechanisms.java    | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/constants/SupportedSaslMechanisms.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/constants/SupportedSaslMechanisms.java
index 5eb52ff..99a50f5 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/constants/SupportedSaslMechanisms.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/constants/SupportedSaslMechanisms.java
@@ -47,6 +47,9 @@ public final class SupportedSaslMechanisms
     /** Not a SASL JDK supported mechanism */
     public static final String GSS_SPNEGO = "GSS-SPNEGO";
 
+    /** EXTERNAL mechanism */
+    public static final String EXTERNAL = "EXTERNAL";
+
     /**
      *  Ensures no construction of this class, also ensures there is no need for final keyword above
      *  (Implicit super constructor is not visible for default constructor),

-- 
To stop receiving notification emails like this one, please contact
"commits@directory.apache.org" <co...@directory.apache.org>.