Examples of LDAPMessage


Examples of org.apache.directory.shared.ldap.codec.LdapMessage

        //    - Getting a new request
        //    - Checking if the request is well formed
        //    - Sending the request to the server
        //    - Getting and converting reponse(s) as XML
        //    - Looping until last request
        LdapMessage request = null;
        try
        {
            request = parser.getNextRequest();
        }
        catch ( XmlPullParserException e )
        {
            // We create a new ErrorResponse and return the XML response.
            ErrorResponse errorResponse = new ErrorResponse( 0, ErrorResponseType.MALFORMED_REQUEST, e.getMessage()
                + " - Line " + e.getLineNumber() + " - Column " + e.getColumnNumber() );
            batchResponse.addResponse( errorResponse );
            return batchResponse.toDsml();
        }

        while ( request != null ) // (Request == null when there's no more request to process)
        {
            // Checking the request has a requestID attribute if Processing = Parallel and ResponseOrder = Unordered
            if ( ( batchRequest.getProcessing().equals( Processing.PARALLEL ) )
                && ( batchRequest.getResponseOrder().equals( ResponseOrder.UNORDERED ) )
                && ( request.getMessageId() == 0 ) )
            {
                // Then we have to send an errorResponse
                ErrorResponse errorResponse = new ErrorResponse( 0, ErrorResponseType.MALFORMED_REQUEST,
                    "A requestID must be specified to each request when Processing is Parallel and ReponseOrder is Unordered." );
                batchResponse.addResponse( errorResponse );
View Full Code Here

Examples of org.apache.directory.shared.ldap.codec.LdapMessage

     * @throws DecoderException
     */
    private void processRequest( LdapMessage request ) throws EncoderException, IOException, DecoderException,
        NamingException
    {
        LdapMessage message = new LdapMessage();

        message.setProtocolOP( request );

        message.setMessageId( request.getMessageId() );

        ByteBuffer bb = null;

        bb = message.encode( null );

        bb.flip();

        sendMessage( bb );

        bb.clear();
        bb.position( bb.capacity() );
        // Get the response
        LdapMessage response = null;

        response = readResponse( bb );

        if ( LdapConstants.ADD_RESPONSE == response.getMessageType() )
        {
            AddResponse addResponse = response.getAddResponse();
            copyMessageIdAndControls( response, addResponse );

            AddResponseDsml addResponseDsml = new AddResponseDsml( addResponse );
            batchResponse.addResponse( addResponseDsml );
        }
        else if ( LdapConstants.BIND_RESPONSE == response.getMessageType() )
        {
            BindResponse bindResponse = response.getBindResponse();
            copyMessageIdAndControls( response, bindResponse );

            AuthResponseDsml authResponseDsml = new AuthResponseDsml( bindResponse );
            batchResponse.addResponse( authResponseDsml );
        }
        else if ( LdapConstants.COMPARE_RESPONSE == response.getMessageType() )
        {
            CompareResponse compareResponse = response.getCompareResponse();
            copyMessageIdAndControls( response, compareResponse );

            CompareResponseDsml authResponseDsml = new CompareResponseDsml( compareResponse );
            batchResponse.addResponse( authResponseDsml );
        }
        else if ( LdapConstants.DEL_RESPONSE == response.getMessageType() )
        {
            DelResponse delResponse = response.getDelResponse();
            copyMessageIdAndControls( response, delResponse );

            DelResponseDsml delResponseDsml = new DelResponseDsml( delResponse );
            batchResponse.addResponse( delResponseDsml );
        }
        else if ( LdapConstants.MODIFY_RESPONSE == response.getMessageType() )
        {
            ModifyResponse modifyResponse = response.getModifyResponse();
            copyMessageIdAndControls( response, modifyResponse );

            ModifyResponseDsml modifyResponseDsml = new ModifyResponseDsml( modifyResponse );
            batchResponse.addResponse( modifyResponseDsml );
        }
        else if ( LdapConstants.MODIFYDN_RESPONSE == response.getMessageType() )
        {
            ModifyDNResponse modifyDNResponse = response.getModifyDNResponse();
            copyMessageIdAndControls( response, modifyDNResponse );

            ModDNResponseDsml modDNResponseDsml = new ModDNResponseDsml( modifyDNResponse );
            batchResponse.addResponse( modDNResponseDsml );
        }
        else if ( LdapConstants.EXTENDED_RESPONSE == response.getMessageType() )
        {
            ExtendedResponse extendedResponse = response.getExtendedResponse();
            copyMessageIdAndControls( response, extendedResponse );

            ExtendedResponseDsml extendedResponseDsml = new ExtendedResponseDsml( extendedResponse );
            batchResponse.addResponse( extendedResponseDsml );
        }
        else if ( ( LdapConstants.SEARCH_RESULT_ENTRY == response.getMessageType() )
            || ( LdapConstants.SEARCH_RESULT_REFERENCE == response.getMessageType() )
            || ( LdapConstants.SEARCH_RESULT_DONE == response.getMessageType() ) )
        {
            // A SearchResponse can contains multiple responses of 3 types:
            //     - 0 to n SearchResultEntry
            //     - O to n SearchResultReference
            //     - 1 (only) SearchResultDone
            // So we have to include those individual reponses in a "General" SearchResponse
            //            Element searchResponse = xmlResponse.getRootElement().addElement( "searchResponse" );
            SearchResponseDsml searchResponseDsml = new SearchResponseDsml();

            // RequestID
            int requestID = response.getMessageId();
            if ( requestID != 0 )
            {
                searchResponseDsml.setMessageId( requestID );
            }

            while ( LdapConstants.SEARCH_RESULT_DONE != response.getMessageType() )
            {
                if ( LdapConstants.SEARCH_RESULT_ENTRY == response.getMessageType() )
                {
                    SearchResultEntry sre = response.getSearchResultEntry();
                    copyMessageIdAndControls( response, sre );

                    SearchResultEntryDsml searchResultEntryDsml = new SearchResultEntryDsml( sre );
                    searchResponseDsml.addResponse( searchResultEntryDsml );
                }
                else if ( LdapConstants.SEARCH_RESULT_REFERENCE == response.getMessageType() )
                {
                    SearchResultReference srr = response.getSearchResultReference();
                    copyMessageIdAndControls( response, srr );

                    SearchResultReferenceDsml searchResultReferenceDsml = new SearchResultReferenceDsml( srr );
                    searchResponseDsml.addResponse( searchResultReferenceDsml );
                }

                response = readResponse( bb );
            }

            SearchResultDone srd = response.getSearchResultDone();
            copyMessageIdAndControls( response, srd );

            SearchResultDoneDsml searchResultDoneDsml = new SearchResultDoneDsml( response );
            searchResponseDsml.addResponse( searchResultDoneDsml );
        }

        LdapResponse realResponse = response.getLdapResponse();

        if ( !continueOnError )
        {
            if ( ( realResponse.getLdapResult().getResultCode() != ResultCodeEnum.SUCCESS )
                && ( realResponse.getLdapResult().getResultCode() != ResultCodeEnum.COMPARE_TRUE )
View Full Code Here

Examples of org.apache.directory.shared.ldap.codec.LdapMessage

        BatchRequest batchRequest = parser.getBatchRequest();

        assertEquals( 1, batchRequest.getRequests().size() );

        LdapMessage request = batchRequest.getCurrentRequest();

        if ( request instanceof BindRequest )
        {
            assertTrue( true );
        }
View Full Code Here

Examples of org.apache.directory.shared.ldap.codec.LdapMessage

        BatchRequest batchRequest = parser.getBatchRequest();

        assertEquals( 1, batchRequest.getRequests().size() );

        LdapMessage request = batchRequest.getCurrentRequest();

        if ( request instanceof AddRequest )
        {
            assertTrue( true );
        }
View Full Code Here

Examples of org.apache.directory.shared.ldap.codec.LdapMessage

        BatchRequest batchRequest = parser.getBatchRequest();

        assertEquals( 1, batchRequest.getRequests().size() );

        LdapMessage request = batchRequest.getCurrentRequest();

        if ( request instanceof CompareRequest )
        {
            assertTrue( true );
        }
View Full Code Here

Examples of org.apache.directory.shared.ldap.codec.LdapMessage

        BatchRequest batchRequest = parser.getBatchRequest();

        assertEquals( 1, batchRequest.getRequests().size() );

        LdapMessage request = batchRequest.getCurrentRequest();

        if ( request instanceof AbandonRequest )
        {
            assertTrue( true );
        }
View Full Code Here

Examples of org.apache.directory.shared.ldap.codec.LdapMessage

        BatchRequest batchRequest = parser.getBatchRequest();

        assertEquals( 1, batchRequest.getRequests().size() );

        LdapMessage request = batchRequest.getCurrentRequest();

        if ( request instanceof DelRequest )
        {
            assertTrue( true );
        }
View Full Code Here

Examples of org.apache.directory.shared.ldap.codec.LdapMessage

        BatchRequest batchRequest = parser.getBatchRequest();

        assertEquals( 1, batchRequest.getRequests().size() );

        LdapMessage request = batchRequest.getCurrentRequest();

        if ( request instanceof ExtendedRequest )
        {
            assertTrue( true );
        }
View Full Code Here

Examples of org.apache.directory.shared.ldap.codec.LdapMessage

        BatchRequest batchRequest = parser.getBatchRequest();

        assertEquals( 1, batchRequest.getRequests().size() );

        LdapMessage request = batchRequest.getCurrentRequest();

        if ( request instanceof ModifyDNRequest )
        {
            assertTrue( true );
        }
View Full Code Here

Examples of org.apache.directory.shared.ldap.codec.LdapMessage

        BatchRequest batchRequest = parser.getBatchRequest();

        assertEquals( 1, batchRequest.getRequests().size() );

        LdapMessage request = batchRequest.getCurrentRequest();

        if ( request instanceof ModifyRequest )
        {
            assertTrue( true );
        }
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.