Examples of BindRequestImpl


Examples of org.apache.directory.shared.ldap.model.message.BindRequestImpl

    @Ignore // The SASL Plain mechanism is ot supported
    public void testSaslBindPLAIN() throws Exception
    {
        Dn userDn = new Dn( "uid=hnelson,ou=users,dc=example,dc=com" );
        LdapConnection connection = new LdapNetworkConnection( "localhost", getLdapServer().getPort() );
        BindRequest bindReq = new BindRequestImpl();
        bindReq.setCredentials( "secret" );
        bindReq.setName( userDn );
        bindReq.setSaslMechanism( SupportedSaslMechanisms.PLAIN );

        BindResponse resp = connection.bind( bindReq );
        assertEquals( ResultCodeEnum.SUCCESS, resp.getLdapResult().getResultCode() );

        Entry entry = connection.lookup( userDn );
View Full Code Here

Examples of org.apache.directory.shared.ldap.model.message.BindRequestImpl

    @Ignore("Activate and fix when DIRAPI-36 (Provide a SaslBindRequest extending BindRequest that can be used in LdapConnection.bind(...) method) is solved")
    public void testSaslBindNoMech() throws Exception
    {
        Dn userDn = new Dn( "uid=hnelson,ou=users,dc=example,dc=com" );
        LdapConnection connection = new LdapNetworkConnection( "localhost", getLdapServer().getPort() );
        BindRequest bindReq = new BindRequestImpl();
        bindReq.setCredentials( "secret" );
        bindReq.setName( userDn );
        bindReq.setSaslMechanism( "" ); // invalid mechanism
        bindReq.setSimple( false );

        try
        {
            connection.bind( bindReq );
            fail();
View Full Code Here

Examples of org.apache.directory.shared.ldap.model.message.BindRequestImpl

    /**
     * {@inheritDoc}
     */
    public void anonymousBind() throws LdapException, IOException
    {
        BindRequest bindRequest = new BindRequestImpl();
        bindRequest.setName( Dn.EMPTY_DN );
        bindRequest.setCredentials( ( byte[] ) null );

        BindResponse bindResponse = bind( bindRequest );

        processResponse( bindResponse );
    }
View Full Code Here

Examples of org.apache.directory.shared.ldap.model.message.BindRequestImpl

     */
    public void bind( Dn name ) throws LdapException, IOException
    {
        byte[] credBytes = StringConstants.EMPTY_BYTES;

        BindRequest bindRequest = new BindRequestImpl();
        bindRequest.setName( name );
        bindRequest.setCredentials( credBytes );

        BindResponse bindResponse = bind( bindRequest );

        processResponse( bindResponse );
    }
View Full Code Here

Examples of org.apache.directory.shared.ldap.model.message.BindRequestImpl

     */
    public void bind( Dn name, String credentials ) throws LdapException, IOException
    {
        byte[] credBytes = ( credentials == null ? StringConstants.EMPTY_BYTES : Strings.getBytesUtf8(credentials) );

        BindRequest bindRequest = new BindRequestImpl();
        bindRequest.setName( name );
        bindRequest.setCredentials( credBytes );

        BindResponse bindResponse = bind( bindRequest );

        processResponse( bindResponse );
    }
View Full Code Here

Examples of org.apache.directory.shared.ldap.model.message.BindRequestImpl

        int i = 0;
        int nbLoop = 10;

        for ( ; i < nbLoop; i++ )
        {
            BindRequest bindRequest = new BindRequestImpl();
            bindRequest.setName( new Dn( "uid=admin,ou=system" ) );
            bindRequest.setCredentials( "secret" );

            BindFuture bindFuture = connection.bindAsync( bindRequest );

            BindResponse bindResponse = bindFuture.get( 1000, TimeUnit.MILLISECONDS );
View Full Code Here

Examples of org.apache.directory.shared.ldap.model.message.BindRequestImpl

     * Test a successful simple bind request.
     */
    @Test
    public void testSimpleBindRequest() throws Exception
    {
        BindRequest bindRequest = new BindRequestImpl();
        bindRequest.setName( new Dn( "uid=admin,ou=system" ) );
        bindRequest.setCredentials( "secret" );

        BindResponse bindResponse = connection.bind( bindRequest );

        assertNotNull( bindResponse );
        assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode() );
View Full Code Here

Examples of org.apache.directory.shared.ldap.model.message.BindRequestImpl

     * Test a successful blank (anonymous) bind request.
     */
    @Test
    public void testBlankBindRequest() throws Exception
    {
        BindRequest bindRequest = new BindRequestImpl();

        BindResponse bindResponse = connection.bind( bindRequest );

        assertNotNull( bindResponse );
        assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode() );
View Full Code Here

Examples of org.apache.directory.shared.ldap.model.message.BindRequestImpl

     * Test a valid bind followed by another valid bind
     */
    @Test
    public void testDoubleSimpleBindValid() throws Exception
    {
        BindRequest br1 = new BindRequestImpl();
        br1.setName( new Dn( "uid=admin,ou=system" ) );
        br1.setCredentials( Strings.getBytesUtf8( "secret" ) );

        BindResponse response1 = connection.bind( br1 );
        assertTrue( connection.isAuthenticated() );
        int messageId1 = response1.getMessageId();

        // The messageId must have been incremented
        BindRequest br2 = new BindRequestImpl();
        br2.setName( new Dn( "uid=admin,ou=system" ) );
        br2.setCredentials( Strings.getBytesUtf8( "secret" ) );

        BindResponse response2 = connection.bind( br2 );
        int messageId2 = response2.getMessageId();

        assertTrue( messageId2 > messageId1 );
        assertTrue( connection.isAuthenticated() );

        // Now, unbind
        connection.unBind();
        assertFalse( connection.isAuthenticated() );
        assertFalse( connection.isConnected() );

        // And Bind again. The messageId should be 1
        BindRequest br3 = new BindRequestImpl();
        br3.setName( new Dn( "uid=admin,ou=system" ) );
        br3.setCredentials( Strings.getBytesUtf8( "secret" ) );

        BindResponse response3 = connection.bind( br3 );
        int messageId = response3.getMessageId();
        assertEquals( 1, messageId );
        assertTrue( connection.isAuthenticated() );
View Full Code Here

Examples of org.apache.directory.shared.ldap.model.message.BindRequestImpl

                    next.bind( bindContext );
                }
            } );

            // Send another BindRequest
            BindRequest bindRequest = new BindRequestImpl();
            bindRequest.setName( new Dn( "uid=admin,ou=system" ) );
            bindRequest.setCredentials( "secret" );

            BindFuture bindFuture = connection.bindAsync( bindRequest );

            // Wait a bit to be sure the server is processing the bind request
            Thread.sleep( 200 );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.