directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1676001 - in /directory/apacheds/trunk: core-api/src/main/java/org/apache/directory/server/core/api/LdapCoreSessionConnection.java core-integ/src/test/java/org/apache/directory/server/core/api/LdapCoreSessionConnectionTest.java
Date Sat, 25 Apr 2015 08:56:06 GMT
Author: elecharny
Date: Sat Apr 25 08:56:06 2015
New Revision: 1676001

URL: http://svn.apache.org/r1676001
Log:
Fixed issue DIRSERVER-1934 : the controls are now injected into the BindOperationContext instance

Modified:
    directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/LdapCoreSessionConnection.java
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/api/LdapCoreSessionConnectionTest.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=1676001&r1=1676000&r2=1676001&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
Sat Apr 25 08:56:06 2015
@@ -1193,6 +1193,11 @@ public class LdapCoreSessionConnection e
         bindContext.setDn( bindRequest.getDn().apply( directoryService.getSchemaManager()
) );
         bindContext.setInterceptors( directoryService.getInterceptors( OperationEnum.BIND
) );
 
+        for ( Control control : bindRequest.getControls().values() )
+        {
+            bindContext.addRequestControl( control );
+        }
+
         OperationManager operationManager = directoryService.getOperationManager();
 
         BindResponse bindResp = new BindResponseImpl( newId );

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/api/LdapCoreSessionConnectionTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/api/LdapCoreSessionConnectionTest.java?rev=1676001&r1=1676000&r2=1676001&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/api/LdapCoreSessionConnectionTest.java
(original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/api/LdapCoreSessionConnectionTest.java
Sat Apr 25 08:56:06 2015
@@ -27,41 +27,45 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.directory.server.core.integ.FrameworkRunner;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 
-@RunWith( FrameworkRunner.class )
-@CreateLdapServer( transports = {
-        @CreateTransport( protocol = "LDAP" ) } )
+@RunWith(FrameworkRunner.class)
+@CreateLdapServer(transports =
+    {
+        @CreateTransport(protocol = "LDAP") })
 // disable changelog, for more info see DIRSERVER-1528
-@CreateDS( enableChangeLog = false, name = "LdapCoreSessionConnectionTest" )
+@CreateDS(enableChangeLog = false, name = "LdapCoreSessionConnectionTest")
 @ApplyLdifs(
-{
+    {
         // Add a non admin user
         "dn: cn=user,ou=system",
         "objectClass: top",
         "objectClass: person",
         "cn: user",
         "userPassword: secret",
-        "sn: user" } )
-public class LdapCoreSessionConnectionTest extends AbstractLdapTestUnit {
+        "sn: user" })
+public class LdapCoreSessionConnectionTest extends AbstractLdapTestUnit
+{
     private static Logger logger = LoggerFactory.getLogger( LdapCoreSessionConnection.class
);
     private static final LdapApiService codec = LdapApiServiceFactory.getSingleton();
     private static final PasswordPolicyDecorator passwordPolicyRequestControl =
-            new PasswordPolicyDecorator( codec, new PasswordPolicyImpl() );
+        new PasswordPolicyDecorator( codec, new PasswordPolicyImpl() );
+
 
     @Before
-    public void setPwdPolicy() throws LdapException {
+    public void setPwdPolicy() throws LdapException
+    {
         PasswordPolicyConfiguration policyConfig = new PasswordPolicyConfiguration();
         policyConfig.setPwdCheckQuality( CheckQualityEnum.CHECK_REJECT ); // DO NOT allow
the password if its quality can't be checked
 
-        Dn policyDn = new Dn( "ads-pwdId=test,ou=passwordPolicies,ads-interceptorId=authenticationInterceptor,ou=interceptors,ads-directoryServiceId=default,ou=config"
);
+        Dn policyDn = new Dn(
+            "ads-pwdId=test,ou=passwordPolicies,ads-interceptorId=authenticationInterceptor,ou=interceptors,ads-directoryServiceId=default,ou=config"
);
         PpolicyConfigContainer policyContainer = new PpolicyConfigContainer();
-        policyContainer.addPolicy(policyDn, policyConfig);
+        policyContainer.addPolicy( policyDn, policyConfig );
         policyContainer.setDefaultPolicyDn( policyDn );
 
         AuthenticationInterceptor authenticationInterceptor = ( AuthenticationInterceptor
) getService()
@@ -69,10 +73,13 @@ public class LdapCoreSessionConnectionTe
         authenticationInterceptor.setPwdPolicies( policyContainer );
     }
 
+
     @Test
-    public void testBindWithLdapNetworkConnection() throws LdapException {
+    public void testBindWithLdapNetworkConnection() throws LdapException
+    {
         LdapNetworkConnection connection = null;
-        try {
+        try
+        {
             connection = new LdapNetworkConnection( "localhost", getLdapServer().getPort()
);
 
             BindRequest bindRequest = new BindRequestImpl();
@@ -83,19 +90,23 @@ public class LdapCoreSessionConnectionTe
             BindResponse bindResponse = connection.bind( bindRequest );
             Control responseControl = bindResponse.getControls().get( passwordPolicyRequestControl.getOid()
);
             assertNotNull( responseControl );
-            PasswordPolicy passwordPolicy = ((PasswordPolicyDecorator) responseControl).getDecorated();
+            PasswordPolicy passwordPolicy = ( ( PasswordPolicyDecorator ) responseControl
).getDecorated();
             assertNotNull( passwordPolicy );
         }
-        finally {
+        finally
+        {
             safeClose( connection );
         }
     }
 
-    @Ignore
+
+    //@Ignore
     @Test
-    public void testBindWithLdapCoreSessionConnection() throws LdapException {
+    public void testBindWithLdapCoreSessionConnection() throws LdapException
+    {
         LdapCoreSessionConnection connection = null;
-        try {
+        try
+        {
             connection = new LdapCoreSessionConnection();
             connection.setDirectoryService( getService() );
 
@@ -107,20 +118,26 @@ public class LdapCoreSessionConnectionTe
             BindResponse bindResponse = connection.bind( bindRequest );
             Control responseControl = bindResponse.getControls().get( passwordPolicyRequestControl.getOid()
);
             assertNotNull( responseControl );
-            PasswordPolicy passwordPolicy = ((PasswordPolicyDecorator) responseControl).getDecorated();
+            PasswordPolicy passwordPolicy = ( ( PasswordPolicyDecorator ) responseControl
).getDecorated();
             assertNotNull( passwordPolicy );
         }
-        finally {
+        finally
+        {
             safeClose( connection );
         }
     }
 
-    private static void safeClose( LdapConnection... connections ) {
-        for ( LdapConnection connection : connections ) {
-            try {
+
+    private static void safeClose( LdapConnection... connections )
+    {
+        for ( LdapConnection connection : connections )
+        {
+            try
+            {
                 connection.close();
             }
-            catch ( Exception e ) {
+            catch ( Exception e )
+            {
                 logger.warn( "close failed, possible connection leak: {}", e.getMessage()
);
                 logger.debug( "close failed, possible connection leak: ", e );
             }



Mime
View raw message