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 2013/05/22 16:40:14 UTC
svn commit: r1485231 - in /directory:
apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/
shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/
Author: elecharny
Date: Wed May 22 14:40:14 2013
New Revision: 1485231
URL: http://svn.apache.org/r1485231
Log:
o The connect() and various bind() method don't throw an IoException anymore
Modified:
directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/LdapCoreSessionConnection.java
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/AbstractLdapConnection.java
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/DefaultSchemaLoader.java
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/LdapCoreSessionConnection.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/LdapCoreSessionConnection.java?rev=1485231&r1=1485230&r2=1485231&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/LdapCoreSessionConnection.java (original)
+++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/LdapCoreSessionConnection.java Wed May 22 14:40:14 2013
@@ -154,7 +154,7 @@ public class LdapCoreSessionConnection e
/**
* {@inheritDoc}
*/
- public boolean connect() throws LdapException, IOException
+ public boolean connect() throws LdapException
{
return true;
}
@@ -1152,7 +1152,7 @@ public class LdapCoreSessionConnection e
/**
* {@inheritDoc}
*/
- public void bind() throws LdapException, IOException
+ public void bind() throws LdapException
{
throw new UnsupportedOperationException(
"Bind operation using LdapConnectionConfig are not supported on CoreSession based connection" );
@@ -1162,7 +1162,7 @@ public class LdapCoreSessionConnection e
/**
* {@inheritDoc}
*/
- public void anonymousBind() throws LdapException, IOException
+ public void anonymousBind() throws LdapException
{
BindRequest bindRequest = new BindRequestImpl();
bindRequest.setName( "" );
@@ -1177,7 +1177,7 @@ public class LdapCoreSessionConnection e
/**
* {@inheritDoc}
*/
- public BindResponse bind( BindRequest bindRequest ) throws LdapException, IOException
+ public BindResponse bind( BindRequest bindRequest ) throws LdapException
{
if ( bindRequest == null )
{
Modified: directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/AbstractLdapConnection.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/AbstractLdapConnection.java?rev=1485231&r1=1485230&r2=1485231&view=diff
==============================================================================
--- directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/AbstractLdapConnection.java (original)
+++ directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/AbstractLdapConnection.java Wed May 22 14:40:14 2013
@@ -19,9 +19,9 @@
*/
package org.apache.directory.ldap.client.api;
+
import static org.apache.directory.api.ldap.model.message.ResultCodeEnum.processResponse;
-import java.io.IOException;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.directory.api.ldap.codec.api.LdapApiService;
@@ -39,6 +39,7 @@ import org.apache.mina.core.service.IoHa
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
/**
* An abstract LdapConnection class gathering the common behavior of LdapConnection
* concrete classes.
@@ -59,7 +60,7 @@ public abstract class AbstractLdapConnec
/** the ldap codec service */
protected LdapApiService codec = LdapApiServiceFactory.getSingleton();
-
+
/**
* Creates a new instance of an AbstractLdapConnection
*/
@@ -67,12 +68,12 @@ public abstract class AbstractLdapConnec
{
messageId = new AtomicInteger( 0 );
}
-
-
+
+
/**
* {@inheritDoc}
*/
- public void bind( Dn name ) throws LdapException, IOException
+ public void bind( Dn name ) throws LdapException
{
byte[] credBytes = StringConstants.EMPTY_BYTES;
@@ -89,7 +90,7 @@ public abstract class AbstractLdapConnec
/**
* {@inheritDoc}
*/
- public void bind( String name ) throws LdapException, IOException
+ public void bind( String name ) throws LdapException
{
LOG.debug( "Bind request : {}", name );
@@ -100,7 +101,7 @@ public abstract class AbstractLdapConnec
/**
* {@inheritDoc}
*/
- public void bind( String name, String credentials ) throws LdapException, IOException
+ public void bind( String name, String credentials ) throws LdapException
{
bind( new Dn( schemaManager, name ), credentials );
}
@@ -109,7 +110,7 @@ public abstract class AbstractLdapConnec
/**
* {@inheritDoc}
*/
- public void bind( Dn name, String credentials ) throws LdapException, IOException
+ public void bind( Dn name, String credentials ) throws LdapException
{
byte[] credBytes = ( credentials == null ? StringConstants.EMPTY_BYTES : Strings.getBytesUtf8( credentials ) );
Modified: directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/DefaultSchemaLoader.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/DefaultSchemaLoader.java?rev=1485231&r1=1485230&r2=1485231&view=diff
==============================================================================
--- directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/DefaultSchemaLoader.java (original)
+++ directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/DefaultSchemaLoader.java Wed May 22 14:40:14 2013
@@ -132,7 +132,8 @@ public class DefaultSchemaLoader extends
}
// Getting the subschemaSubentry DN from the rootDSE
- Entry rootDse = connection.lookup( Dn.ROOT_DSE, SchemaConstants.SUBSCHEMA_SUBENTRY_AT, SchemaConstants.VENDOR_NAME_AT );
+ Entry rootDse = connection.lookup( Dn.ROOT_DSE, SchemaConstants.SUBSCHEMA_SUBENTRY_AT,
+ SchemaConstants.VENDOR_NAME_AT );
if ( rootDse != null )
{
@@ -146,7 +147,7 @@ public class DefaultSchemaLoader extends
{
subschemaSubentryDn = new Dn( connection.getSchemaManager(),
subschemaSubentryAttribute.getString() );
-
+
loadSchemas();
}
}
@@ -156,10 +157,6 @@ public class DefaultSchemaLoader extends
}
}
}
- catch ( IOException e )
- {
- throw new LdapException( e );
- }
finally
{
// Checking if the connection needs to be closed
Modified: directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java?rev=1485231&r1=1485230&r2=1485231&view=diff
==============================================================================
--- directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java (original)
+++ directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java Wed May 22 14:40:14 2013
@@ -55,8 +55,8 @@ import org.apache.directory.api.ldap.mod
import org.apache.directory.api.ldap.model.name.Rdn;
import org.apache.directory.api.ldap.model.schema.SchemaManager;
+
// TODO: all the SASL bind methods are not declared in this interface, but implemented in LdapNetworkConnection. Is that intended?
-// TODO: why do connect() and bind() methods throw an IOException, the other methods not?
// TODO: why do connect() and close() return a boolean? What is the difference between false and an Exception?
// TODO: think about usage of abbrevisions (Dn/Rdn) vs. spelled out (relative distinguished name) in javadoc
// TODO: describe better which type of LdapException are thrown in which case?
@@ -92,9 +92,8 @@ public interface LdapConnection
*
* @return <code>true</code> if the connection is established, false otherwise
* @throws LdapException if some error occurred
- * @throws IOException if an I/O exception occurred
*/
- boolean connect() throws LdapException, IOException;
+ boolean connect() throws LdapException;
/**
@@ -155,16 +154,15 @@ public interface LdapConnection
* @throws LdapException if some error occurred
* @throws IOException if an I/O exception occurred
*/
- void bind() throws LdapException, IOException;
+ void bind() throws LdapException;
/**
* Anonymous bind on a server.
*
* @throws LdapException if some error occurred
- * @throws IOException if an I/O exception occurred
*/
- void anonymousBind() throws LdapException, IOException;
+ void anonymousBind() throws LdapException;
/**
@@ -173,9 +171,8 @@ public interface LdapConnection
* @param name The name we use to authenticate the user. It must be a
* valid {@link Dn}
* @throws LdapException if some error occurred
- * @throws IOException if an I/O exception occurred
*/
- void bind( String name ) throws LdapException, IOException;
+ void bind( String name ) throws LdapException;
/**
@@ -185,9 +182,8 @@ public interface LdapConnection
* valid {@link Dn}
* @param credentials The password, it can't be <code>null</code>
* @throws LdapException if some error occurred
- * @throws IOException if an I/O exception occurred
*/
- void bind( String name, String credentials ) throws LdapException, IOException;
+ void bind( String name, String credentials ) throws LdapException;
/**
@@ -197,10 +193,9 @@ public interface LdapConnection
* @param credentials The password, it can't be null
* @return The BindResponse LdapResponse
* @throws LdapException if some error occurred
- * @throws IOException if an I/O exception occurred
*/
// Not yet available on the CoreConnection
- //BindResponse bindSaslPlain( String authcid, String credentials ) throws LdapException, IOException;
+ //BindResponse bindSaslPlain( String authcid, String credentials ) throws LdapException;
/**
* SASL PLAIN Bind on a server.
@@ -210,19 +205,17 @@ public interface LdapConnection
* @param credentials The password. It can't be null
* @return The BindResponse LdapResponse
* @throws LdapException if some error occurred
- * @throws IOException if an I/O exception occurred
*/
// Not yet available on the CoreConnection
- //BindResponse bindSaslPlain( String authzid, String authcid, String credentials ) throws LdapException, IOException;
+ //BindResponse bindSaslPlain( String authzid, String authcid, String credentials ) throws LdapException;
/**
* Unauthenticated authentication bind on a server.
*
* @param name The name we use to authenticate the user.
* @throws LdapException if some error occurred
- * @throws IOException if an I/O exception occurred
*/
- void bind( Dn name ) throws LdapException, IOException;
+ void bind( Dn name ) throws LdapException;
/**
@@ -231,9 +224,8 @@ public interface LdapConnection
* @param name The name we use to authenticate the user.
* @param credentials The password, it can't be null
* @throws LdapException if some error occurred
- * @throws IOException if an I/O exception occurred
*/
- void bind( Dn name, String credentials ) throws LdapException, IOException;
+ void bind( Dn name, String credentials ) throws LdapException;
/**
@@ -242,9 +234,8 @@ public interface LdapConnection
* @param bindRequest The bind request object containing all the needed parameters
* @return A {@link BindResponse} containing the result
* @throws LdapException if some error occurred
- * @throws IOException if an I/O exception occurred
*/
- BindResponse bind( BindRequest bindRequest ) throws LdapException, IOException;
+ BindResponse bind( BindRequest bindRequest ) throws LdapException;
/**
Modified: directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java?rev=1485231&r1=1485230&r2=1485231&view=diff
==============================================================================
--- directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java (original)
+++ directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java Wed May 22 14:40:14 2013
@@ -486,7 +486,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
- public boolean connect() throws LdapException, IOException
+ public boolean connect() throws LdapException
{
if ( ( ldapSession != null ) && connected.get() )
{
@@ -927,7 +927,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
- public void bind() throws LdapException, IOException
+ public void bind() throws LdapException
{
LOG.debug( "Bind request" );
@@ -943,7 +943,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
- public void anonymousBind() throws LdapException, IOException
+ public void anonymousBind() throws LdapException
{
LOG.debug( "Anonymous Bind request" );
@@ -959,7 +959,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
- public BindFuture bindAsync() throws LdapException, IOException
+ public BindFuture bindAsync() throws LdapException
{
LOG.debug( "Asynchronous Bind request" );
@@ -973,7 +973,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
- public BindFuture anonymousBindAsync() throws LdapException, IOException
+ public BindFuture anonymousBindAsync() throws LdapException
{
LOG.debug( "Anonymous asynchronous Bind request" );
@@ -991,9 +991,8 @@ public class LdapNetworkConnection exten
* valid Dn
* @return The BindResponse LdapResponse
* @throws LdapException if some error occurred
- * @throws IOException if an I/O exception occurred
*/
- public BindFuture bindAsync( String name ) throws LdapException, IOException
+ public BindFuture bindAsync( String name ) throws LdapException
{
LOG.debug( "Bind request : {}", name );
@@ -1007,7 +1006,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
- public BindFuture bindAsync( String name, String credentials ) throws LdapException, IOException
+ public BindFuture bindAsync( String name, String credentials ) throws LdapException
{
LOG.debug( "Bind request : {}", name );
@@ -1032,9 +1031,8 @@ public class LdapNetworkConnection exten
* valid Dn
* @return The BindResponse LdapResponse
* @throws LdapException if some error occurred
- * @throws IOException if an I/O exception occurred
*/
- public BindFuture bindAsync( Dn name ) throws LdapException, IOException
+ public BindFuture bindAsync( Dn name ) throws LdapException
{
LOG.debug( "Bind request : {}", name );
@@ -1048,7 +1046,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
- public BindFuture bindAsync( Dn name, String credentials ) throws LdapException, IOException
+ public BindFuture bindAsync( Dn name, String credentials ) throws LdapException
{
LOG.debug( "Bind request : {}", name );
@@ -1069,7 +1067,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
- public BindResponse bind( BindRequest bindRequest ) throws LdapException, IOException
+ public BindResponse bind( BindRequest bindRequest ) throws LdapException
{
if ( bindRequest == null )
{
@@ -1145,7 +1143,7 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
- public BindFuture bindAsync( BindRequest bindRequest ) throws LdapException, IOException
+ public BindFuture bindAsync( BindRequest bindRequest ) throws LdapException
{
if ( bindRequest == null )
{
@@ -1188,9 +1186,8 @@ public class LdapNetworkConnection exten
* @param credentials The password. It can't be null
* @return The BindResponse LdapResponse
* @throws {@link LdapException} if some error occurred
- * @throws IOException if an I/O exception occurred
*/
- public BindResponse bindSaslPlain( String authcid, String credentials ) throws LdapException, IOException
+ public BindResponse bindSaslPlain( String authcid, String credentials ) throws LdapException
{
return bindSaslPlain( null, authcid, credentials );
}
@@ -1204,10 +1201,8 @@ public class LdapNetworkConnection exten
* @param credentials The password. It can't be null
* @return The BindResponse LdapResponse
* @throws {@link LdapException} if some error occurred
- * @throws IOException if an I/O exception occurred
*/
- public BindResponse bindSaslPlain( String authzid, String authcid, String credentials ) throws LdapException,
- IOException
+ public BindResponse bindSaslPlain( String authzid, String authcid, String credentials ) throws LdapException
{
LOG.debug( "SASL PLAIN Bind request" );
@@ -1270,9 +1265,8 @@ public class LdapNetworkConnection exten
* @param request The CramMd5Request POJO containing all the needed parameters
* @return A LdapResponse containing the result
* @throws LdapException if some error occurred
- * @throws IOException if an I/O exception occurred
*/
- public BindResponse bind( SaslCramMd5Request request ) throws LdapException, IOException
+ public BindResponse bind( SaslCramMd5Request request ) throws LdapException
{
if ( request == null )
{
@@ -1334,10 +1328,9 @@ public class LdapNetworkConnection exten
* @param request The SaslPlainRequest POJO containing all the needed parameters
* @return The bind operation's future
* @throws LdapException if some error occurred
- * @throws IOException if an I/O exception occurred
*/
public BindFuture bindAsync( SaslRequest request )
- throws LdapException, IOException
+ throws LdapException
{
return bindSasl( request );
}
@@ -1349,9 +1342,8 @@ public class LdapNetworkConnection exten
* @param request The DigestMd5Request POJO containing all the needed parameters
* @return A LdapResponse containing the result
* @throws LdapException if some error occurred
- * @throws IOException if an I/O exception occurred
*/
- public BindResponse bind( SaslDigestMd5Request request ) throws LdapException, IOException
+ public BindResponse bind( SaslDigestMd5Request request ) throws LdapException
{
if ( request == null )
{
@@ -1413,9 +1405,8 @@ public class LdapNetworkConnection exten
* @param request The GssApiRequest POJO containing all the needed parameters
* @return A LdapResponse containing the result
* @throws LdapException if some error occurred
- * @throws IOException if an I/O exception occurred
*/
- public BindResponse bind( SaslGssApiRequest request ) throws LdapException, IOException
+ public BindResponse bind( SaslGssApiRequest request ) throws LdapException
{
if ( request == null )
{
@@ -1477,10 +1468,9 @@ public class LdapNetworkConnection exten
* @param request The GssApiRequest POJO containing all the needed parameters
* @return The bind operation's future
* @throws LdapException if some error occurred
- * @throws IOException if an I/O exception occurred
*/
public BindFuture bindAsync( SaslGssApiRequest request )
- throws LdapException, IOException
+ throws LdapException
{
// Krb5.conf file
if ( request.getKrb5ConfFilePath() != null )
@@ -1491,10 +1481,17 @@ public class LdapNetworkConnection exten
else if ( ( request.getRealmName() != null ) && ( request.getKdcHost() != null )
&& ( request.getKdcPort() != 0 ) )
{
- // Using a custom krb5.conf we create from the settings provided by the user
- String krb5ConfPath = createKrb5ConfFile( request.getRealmName(), request.getKdcHost(),
- request.getKdcPort() );
- System.setProperty( "java.security.krb5.conf", krb5ConfPath );
+ try
+ {
+ // Using a custom krb5.conf we create from the settings provided by the user
+ String krb5ConfPath = createKrb5ConfFile( request.getRealmName(), request.getKdcHost(),
+ request.getKdcPort() );
+ System.setProperty( "java.security.krb5.conf", krb5ConfPath );
+ }
+ catch ( IOException ioe )
+ {
+ throw new LdapException( ioe );
+ }
}
else
{
@@ -3728,7 +3725,7 @@ public class LdapNetworkConnection exten
* a response and the, if this response is a challenge, continue by sending a new BindRequest with
* the requested informations.
*/
- private BindFuture bindSasl( SaslRequest saslRequest ) throws LdapException, IOException
+ private BindFuture bindSasl( SaslRequest saslRequest ) throws LdapException
{
// First switch to anonymous state
authenticated.set( false );