Package org.apache.directory.shared.ldap.model.message

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


        AddResponse addResp = adminConnection.add( addRequest );
        assertEquals( ResultCodeEnum.SUCCESS, addResp.getLdapResult().getResultCode() );
        PasswordPolicy respCtrl = getPwdRespCtrl( addResp );
        assertNull( respCtrl );

        BindRequest bindReq = new BindRequestImpl();
        bindReq.setDn( userDn );
        bindReq.setCredentials( "1234" ); // wrong password
        bindReq.addControl( PP_REQ_CTRL );
       
        LdapConnection userConnection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );

        for( int i=0; i< 4; i++ )
        {
            Thread.sleep( 1000 );
            userConnection.bind( bindReq );
            assertFalse( userConnection.isAuthenticated() );
        }
       
        userEntry = adminConnection.lookup( userDn, "+" );
        Attribute pwdAccountLockedTime = userEntry.get( PasswordPolicySchemaConstants.PWD_ACCOUNT_LOCKED_TIME_AT );
        assertNotNull( pwdAccountLockedTime );
        assertEquals( "000001010000Z", pwdAccountLockedTime.getString() );
       
        bindReq = new BindRequestImpl();
        bindReq.setDn( userDn );
        bindReq.setCredentials( "12345" ); // correct password
        bindReq.addControl( PP_REQ_CTRL );
        userConnection.bind( bindReq );
        assertFalse( userConnection.isAuthenticated() ); // but still fails cause account is locked
       
        userConnection.close();
    }
View Full Code Here


        addRequest.setEntry( userEntry );
        addRequest.addControl( PP_REQ_CTRL );

        connection.add( addRequest );

        BindRequest bindReq = new BindRequestImpl();
        bindReq.setDn( userDn );
        bindReq.setCredentials( password.getBytes() );
        bindReq.addControl( PP_REQ_CTRL );
       
        LdapConnection userCon= new LdapNetworkConnection( "localhost", ldapServer.getPort() );
        userCon.setTimeOut(0);

        Thread.sleep( 1000 ); // sleep for one second so that the password expire warning will be sent
View Full Code Here

    /**
     * Opens the dao's connection. Dn and credentials are used for authentication. Throws an {@link LdapDaoException} in
     * case of IO error or invalid dn.
     * */
    public void connect(String dn, String credentials) {
        BindRequest bindRequest = new BindRequestImpl();
        bindRequest.setCredentials(credentials);
        try {
            bindRequest.setDn(new Dn(dn));
            connection.connect();
            connection.bind(bindRequest);
            ((LdapNetworkConnection) connection).loadSchema(new DefaultSchemaLoader(connection));
        } catch (Exception e) {
            throw new LdapDaoException(e);
View Full Code Here

        clearDIT();
        closeConnection();
    }

    private void setupConnection() throws Exception {
        BindRequest bindRequest = new BindRequestImpl();
        bindRequest.setCredentials("secret");
        bindRequest.setDn(new Dn("uid=admin,ou=system"));
        connection = new LdapNetworkConnection("localhost", 10389);
        connection.setTimeOut(0);
        connection.connect();
        connection.bind(bindRequest);
        ((LdapNetworkConnection) connection).loadSchema(new DefaultSchemaLoader(connection));
View Full Code Here

        long t0 = System.currentTimeMillis();

        for ( int i = 0; i < nbLoops; i++ )
        {
            // Check the decoded BindRequest
            BindRequest bindRequest = new BindRequestImpl( 1 );

            bindRequest.setSimple( true );
            bindRequest.setName( name );
            bindRequest.setCredentials( Strings.getBytesUtf8("password") );
            Control control = new OpaqueControl( "2.16.840.1.113730.3.4.2" );

            bindRequest.addControl( control );

            // Check the encoding
            try
            {
                encoder.encodeMessage( bindRequest );
View Full Code Here

     */
    private BindRequest createBindRequest( Dn name, byte[] credentials, String saslMechanism, Control... controls )
        throws LdapException
    {
        // Set the new messageId
        BindRequest bindRequest = new BindRequestImpl();

        // Set the version
        bindRequest.setVersion3( true );

        // Set the name
        bindRequest.setName( name );

        // Set the credentials
        if ( Strings.isEmpty( saslMechanism ) )
        {
            // Simple bind
            bindRequest.setSimple( true );
            bindRequest.setCredentials( credentials );
        }
        else
        {
            // SASL bind
            bindRequest.setSimple( false );
            bindRequest.setCredentials( credentials );
            bindRequest.setSaslMechanism( saslMechanism );
        }

        // Add the controls
        if ( ( controls != null ) && ( controls.length != 0 ) )
        {
            bindRequest.addAllControls( controls );
        }

        return bindRequest;
    }
View Full Code Here

     */
    public void action( LdapMessageContainer<BindRequestDecorator> container ) throws DecoderException
    {
        // Create the BindRequest LdapMessage instance and store it in the container
        BindRequestDecorator bindRequest = new BindRequestDecorator(
            container.getLdapCodecService(), new BindRequestImpl( container.getMessageId() ) );
        container.setMessage( bindRequest );

        // We will check that the request is not null
        TLV tlv = container.getCurrentTLV();

View Full Code Here

        long t0 = System.currentTimeMillis();

        for ( int i = 0; i < nbLoops; i++ )
        {
            // Check the decoded BindRequest
            BindRequest bindRequest = new BindRequestImpl( 1 );

            bindRequest.setSimple( true );
            bindRequest.setName( name );
            bindRequest.setCredentials( Strings.getBytesUtf8("password") );
            Control control = new OpaqueControl( "2.16.840.1.113730.3.4.2" );

            bindRequest.addControl( control );

            // Check the encoding
            try
            {
                encoder.encodeMessage( bindRequest );
View Full Code Here

                result = bindResponse.getLdapResult().getResultCode();
            }
            else
            {
                // Copy the bindRequest without setting the credentials
                BindRequest bindRequestCopy = new BindRequestImpl( newId );
                bindRequestCopy.setName( bindRequest.getName() );
                bindRequestCopy.setSaslMechanism( bindRequest.getSaslMechanism() );
                bindRequestCopy.setSimple( bindRequest.isSimple() );
                bindRequestCopy.setVersion3( bindRequest.getVersion3() );
                bindRequestCopy.addAllControls( bindRequest.getControls().values().toArray( new Control[0] ) );

                writeBindRequest( bindRequestCopy );

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

     * @throws DecoderException
     * @throws IOException
     */
    private void bind( int messageId ) throws LdapException, EncoderException, DecoderException, IOException
    {
        BindRequest bindRequest = new BindRequestImpl();
        bindRequest.setSimple( true );
        bindRequest.setCredentials( Strings.getBytesUtf8(password) );
        bindRequest.setName( new Dn( user ) );
        bindRequest.setVersion3( true );
        bindRequest.setMessageId( messageId );

        BindResponse bindResponse = connection.bind( bindRequest );

        if ( bindResponse.getLdapResult().getResultCode() != ResultCodeEnum.SUCCESS )
        {
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.model.message.BindRequestImpl

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.