Package org.apache.directory.ldap.client.api.message

Examples of org.apache.directory.ldap.client.api.message.BindResponse


            {
                connection = new LdapConnection( providerHost, port );
            }

            // Do a bind
            BindResponse bindResponse = connection.bind( config.getBindDn(), config.getCredentials() );

            // Check that it' not null and valid
            if ( bindResponse == null )
            {
                LOG.error( "Failed to bind with the given bindDN and credentials", bindResponse );
                return false;
            }

            // Now get the result
            LdapResult ldapResult = bindResponse.getLdapResult();

            if ( ldapResult.getResultCode() != ResultCodeEnum.SUCCESS )
            {
                LOG.warn( "Failed to bind on the server : {}", ldapResult );
            }
View Full Code Here


    {
        LdapConnection connection = null;
        try
        {
            connection = new LdapConnection( config );
            BindResponse bindResponse = connection.bind( "uid=admin,ou=system", "secret" );
           
            assertNotNull( bindResponse );
           
            connection.unBind();
        }
View Full Code Here

    public void testBindRequest() throws Exception
    {
        LdapConnection connection = new LdapConnection( "localhost", ldapServer.getPort() );
        try
        {
            BindResponse bindResponse = connection.bind( ADMIN_DN, "secret" );
           
            assertNotNull( bindResponse );
           
            //connection.unBind();
        }
View Full Code Here

    /**
     * Convert a BindResponseCodec to a BindResponse message
     */
    private BindResponse convert( BindResponseCodec bindResponseCodec )
    {
        BindResponse bindResponse = new BindResponse();

        bindResponse.setMessageId( bindResponseCodec.getMessageId() );
        bindResponse.setServerSaslCreds( bindResponseCodec.getServerSaslCreds() );
        bindResponse.setLdapResult( convert( bindResponseCodec.getLdapResult() ) );

        return bindResponse;
    }
View Full Code Here

        {
            // Read the response, waiting for it if not available immediately
            long timeout = getTimeout( bindRequest.getTimeout() );

            // Get the response, blocking
            BindResponse bindResponse = ( BindResponse ) bindFuture.get( timeout, TimeUnit.MILLISECONDS );
           
            if ( bindResponse == null )
            {
                // We didn't received anything : this is an error
                LOG.error( "Bind failed : timeout occured" );
                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 );
View Full Code Here

            case BIND_RESPONSE:
                // Transform the response
                BindResponseCodec bindResponseCodec = (BindResponseCodec)response;
                bindResponseCodec.setMessageId( messageId );
                bindResponseCodec.addControl( response.getCurrentControl() );
                BindResponse bindResponse = convert( bindResponseCodec );

                BindFuture bindFuture = (BindFuture)responseFuture;

                if ( bindFuture == null )
                {
                    LOG.error( "BindFuture is null" );
                    throw new LdapException( "BindFuture is null"  );
                }
               
                // remove the listener from the listener map
                if ( bindResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
                {
                    authenticated.set( true );

                    // Everything is fine, return the response
                    LOG.debug( "Bind successful : {}", bindResponse );
View Full Code Here

     * Test a successful synchronous bind request. the server allows it.
     */
    @Test
    public void testSyncBindRequest() throws Exception
    {
        BindResponse bindResponse = connection.bind( "uid=admin,ou=system", "secret" );
       
        assertNotNull( bindResponse );
        assertNotNull( bindResponse.getLdapResult() );
        assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode() );
        assertEquals( 1, bindResponse.getMessageId() );
        assertTrue( connection.isAuthenticated() );
    }
View Full Code Here

           
            BindFuture bindFuture = connection.bindAsync( bindRequest );
           
            try
            {
                BindResponse bindResponse = bindFuture.get( 1000, TimeUnit.MILLISECONDS );
               
                assertNotNull( bindResponse );
                assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode() );
                assertTrue( connection.isAuthenticated() );
            }
            catch ( TimeoutException toe )
            {
                fail();
View Full Code Here

            //System.out.println( "------------------Create connection" + i + "-------------" );
            LdapConnection connection = new LdapConnection( "localhost", ldapServer.getPort() );
            //System.out.println( "------------------Bind" + i + "-------------" );
           
            // Try with no parameters
            BindResponse bindResponse = connection.bind();
           
            assertNotNull( bindResponse );
            assertNotNull( bindResponse.getLdapResult() );
            assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode() );
            assertEquals( 1, bindResponse.getMessageId() );
            assertTrue( connection.isAuthenticated() );
   
            //System.out.println( "----------------Unbind" + i + "-------------" );
            connection.unBind();
            assertFalse( connection.isConnected() );
   
            // Try with empty strings
            connection = new LdapConnection( "localhost", ldapServer.getPort() );
            bindResponse = connection.bind( "", "" );
           
            assertNotNull( bindResponse );
            assertNotNull( bindResponse.getLdapResult() );
            assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode() );
            assertEquals( 1, bindResponse.getMessageId() );
            assertTrue( connection.isAuthenticated() );
   
            connection.unBind();
            assertFalse( connection.isConnected() );
   
            // Try with null parameters
            connection = new LdapConnection( "localhost", ldapServer.getPort() );
            bindResponse = connection.bind( (String)null, (String)null );
           
            assertNotNull( bindResponse );
            assertNotNull( bindResponse.getLdapResult() );
            assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode() );
            assertEquals( 1, bindResponse.getMessageId() );
            assertTrue( connection.isAuthenticated() );
            assertTrue( connection.isConnected() );

            connection.unBind();
            assertFalse( connection.isConnected() );
View Full Code Here

     * A bind with no name and a password is invalid
     */
    @Test
    public void testSimpleBindNoNamePassword() throws Exception
    {
        BindResponse response = connection.bind((String)null, "abc" );
        LdapResult ldapResult = response.getLdapResult();
        assertEquals( ResultCodeEnum.INVALID_CREDENTIALS, ldapResult.getResultCode() );
        assertEquals( 1, response.getMessageId() );
        assertFalse( connection.isAuthenticated() );
        assertTrue( connection.isConnected() );
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.ldap.client.api.message.BindResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.