Skip to content
Permalink
Browse files
o Catch more than just LdapException when feeding an Entry
o Improved the error message for when an attribute is syntactically
incorrect
o Added the exceptionCaught() method in LdapConnection, to get a precise
information about any potential error that could have occurred
That solves DIRAPI-359
  • Loading branch information
emmanuel lecharny committed May 25, 2020
1 parent b32aaaa commit 253211caad1c53e47687137fe36e009d61b1b623
Showing 7 changed files with 39 additions and 4 deletions.
@@ -526,7 +526,7 @@ ERR_13243_ENTRY_IMMUTABLE_CANT_DESERIALIZE=Cannot deserialize the entry {0} is i
ERR_13244_ID_AT_NOT_COMPATIBLE=ID ''{0}'' and AttributeType ''{1}'' are not compatible
ERR_13245_AT_PARAMETER_NULL=The AttributeType parameter should not be null
ERR_13246_INVALID_VALUE_PER_SYNTAX=Invalid upValue per syntax
ERR_13247_INVALID_VALUE_CANT_NORMALIZE=Invalid upValue, it can''t be normalized
ERR_13247_INVALID_VALUE_CANT_NORMALIZE=Invalid upValue ''{0}'', it can''t be normalized
ERR_13248_CANNOT_READ_ENTRY=Cannot read an entry
ERR_13249_NO_COMPARATOR_FOR_AT=No comparator for attributeType {0}
ERR_13250_VALUE_MISSING_AT_THE_END=A value is missing at the end
@@ -92,6 +92,15 @@ public interface LdapConnection extends Closeable
* @throws LdapException if some error occurred
*/
boolean connect() throws LdapException;


/**
* tell if an exception was caught while processing the request or a response.
*
* @return The exception if there was one thrown while processing a
* request or a response
*/
Throwable exceptionCaught();


/**
@@ -119,6 +119,15 @@ public boolean connect() throws LdapException
return connection.connect();
}


/**
* {@inheritDoc}
*/
public Throwable exceptionCaught()
{
return connection.exceptionCaught();
}


/**
* {@inheritDoc}
@@ -563,6 +563,16 @@ public boolean isSecured()
}


/**
* {@inheritDoc}
*/
@Override
public Throwable exceptionCaught()
{
return ( Throwable ) ioSession.getAttribute( EXCEPTION_KEY );
}


/**
* Check that a session is valid, ie we can send requests to the
* server
@@ -389,7 +389,14 @@ public boolean isAuthenticated()
{
return false;
}


@Override
public Throwable exceptionCaught()
{
return null;
}


@Override
public List<String> getSupportedControls() throws LdapException
@@ -326,7 +326,7 @@ public DefaultEntry( SchemaManager schemaManager, Entry entry ) throws LdapExcep
// And store it
add( serverAttribute );
}
catch ( LdapException ne )
catch ( Exception ne )
{
// Just log a warning
if ( LOG.isWarnEnabled() )
@@ -271,7 +271,7 @@ public Value( AttributeType attributeType, String upValue ) throws LdapInvalidAt
catch ( LdapException le )
{
LOG.error( le.getMessage() );
throw new IllegalArgumentException( I18n.err( I18n.ERR_13247_INVALID_VALUE_CANT_NORMALIZE ) );
throw new IllegalArgumentException( I18n.err( I18n.ERR_13247_INVALID_VALUE_CANT_NORMALIZE, upValue ) );
}

if ( !attributeType.isRelaxed() )
@@ -376,7 +376,7 @@ public Value( AttributeType attributeType, Value value ) throws LdapInvalidAttri
catch ( LdapException le )
{
LOG.error( le.getMessage() );
throw new IllegalArgumentException( I18n.err( I18n.ERR_13247_INVALID_VALUE_CANT_NORMALIZE ) );
throw new IllegalArgumentException( I18n.err( I18n.ERR_13247_INVALID_VALUE_CANT_NORMALIZE, upValue ) );
}

// Check the normValue

0 comments on commit 253211c

Please sign in to comment.