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

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


    /**
     * Creates a new getDecoratedMessage() of CompareResponseDsml.
     */
    public CompareResponseDsml( LdapCodecService codec )
    {
        super( codec, new CompareResponseImpl() );
    }
View Full Code Here


    /**
     * Creates a new getDecoratedMessage() of CompareResponseDsml.
     */
    public CompareResponseDsml( LdapCodecService codec )
    {
        super( codec, new CompareResponseImpl() );
    }
View Full Code Here

                        {
                            String msg = "Invalid Dn given : " + dnStr + " (" + Strings.dumpBytes(dnBytes)
                                + ") is invalid";
                            LOG.error( "{} : {}", msg, ine.getMessage() );

                            CompareResponseImpl response = new CompareResponseImpl( compareRequest.getMessageId() );
                            throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_DN_SYNTAX,
                                Dn.EMPTY_DN, ine );
                        }

                        compareRequest.setName( entry );
                    }

                    if ( IS_DEBUG )
                    {
                        LOG.debug( "Comparing Dn {}", entry );
                    }
                }
            } );

        // --------------------------------------------------------------------------------------------
        // Transition from entryComp to ava
        // --------------------------------------------------------------------------------------------
        // CompareRequest ::= [APPLICATION 14] SEQUENCE {
        //     ...
        //     ava AttributeValueAssertion }
        //
        // AttributeValueAssertion ::= SEQUENCE {
        //
        // Nothing to do
        super.transitions[LdapStatesEnum.ENTRY_COMP_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
            LdapStatesEnum.ENTRY_COMP_STATE, LdapStatesEnum.AVA_STATE, UniversalTag.SEQUENCE.getValue(), null );

        // --------------------------------------------------------------------------------------------
        // Transition from ava to AttributeDesc
        // --------------------------------------------------------------------------------------------
        // AttributeValueAssertion ::= SEQUENCE {
        //     attributeDesc AttributeDescription,
        //     ...
        //
        // AttributeDescription LDAPString
        //
        // Stores the attribute description
        super.transitions[LdapStatesEnum.AVA_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
            LdapStatesEnum.AVA_STATE, LdapStatesEnum.ATTRIBUTE_DESC_STATE, UniversalTag.OCTET_STRING.getValue(),
            new GrammarAction<LdapMessageContainer<CompareRequestDecorator>>( "Store attribute desc" )
            {
                public void action( LdapMessageContainer<CompareRequestDecorator> container ) throws DecoderException
                {
                    // Get the CompareRequest Object
                    CompareRequest compareRequest = container.getMessage();

                    // Get the Value and store it in the CompareRequest
                    TLV tlv = container.getCurrentTLV();

                    // We have to handle the special case of a 0 length matched
                    // Dn
                    if ( tlv.getLength() == 0 )
                    {
                        String msg = I18n.err( I18n.ERR_04093 );
                        LOG.error( msg );
                        CompareResponseImpl response = new CompareResponseImpl( compareRequest.getMessageId() );

                        throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX,
                            compareRequest.getName(), null );
                    }

                    String type = getType(tlv.getValue().getData());
                    compareRequest.setAttributeId( type );

                    if ( IS_DEBUG )
                    {
                        LOG.debug( "Comparing attribute description {}", compareRequest.getAttributeId() );
                    }
                }
            } );

        // --------------------------------------------------------------------------------------------
        // Transition from AttributeDesc to Assertion Value
        // --------------------------------------------------------------------------------------------
        // AttributeValueAssertion ::= SEQUENCE {
        //     ...
        //     assertionValue AssertionValue }
        //
        // AssertionValue OCTET STRING
        //
        // Stores the attribute value
        super.transitions[LdapStatesEnum.ATTRIBUTE_DESC_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
            LdapStatesEnum.ATTRIBUTE_DESC_STATE, LdapStatesEnum.ASSERTION_VALUE_STATE, UniversalTag.OCTET_STRING.getValue(),
            new GrammarAction<LdapMessageContainer<CompareRequestDecorator>>( "Store assertion value" )
            {
                public void action( LdapMessageContainer<CompareRequestDecorator> container )
                {
                    // Get the CompareRequest Object
                    CompareRequest compareRequest = container.getMessage();

                    // Get the Value and store it in the CompareRequest
                    TLV tlv = container.getCurrentTLV();

                    // We have to handle the special case of a 0 length value
                    if ( tlv.getLength() == 0 )
                    {
                        compareRequest.setAssertionValue( "" );
                    }
                    else
                    {
                        if ( container.isBinary( compareRequest.getAttributeId() ) )
                        {
                            compareRequest.setAssertionValue( tlv.getValue().getData() );

                            if ( IS_DEBUG )
                            {
                                LOG.debug( "Comparing attribute value {}", Strings.dumpBytes(compareRequest
                                        .getAssertionValue().getBytes()) );
                            }
                        }
                        else
                        {
                            compareRequest.setAssertionValue( Strings.utf8ToString(tlv.getValue().getData()) );

                            if ( LOG.isDebugEnabled() )
                            {
                                LOG.debug( "Comparing attribute value {}", compareRequest.getAssertionValue() );
                            }
                        }
                    }

                    // We can have an END transition
                    container.setGrammarEndAllowed( true );
                }
            } );

        // --------------------------------------------------------------------------------------------
        // Transition from Assertion Value to Controls
        // --------------------------------------------------------------------------------------------
        // AttributeValueAssertion ::= SEQUENCE {
        //     ...
        //     assertionValue AssertionValue }
        //
        // AssertionValue OCTET STRING
        //
        // Stores the attribute value
        super.transitions[LdapStatesEnum.ASSERTION_VALUE_STATE.ordinal()][LdapConstants.CONTROLS_TAG] = new GrammarTransition(
            LdapStatesEnum.ASSERTION_VALUE_STATE, LdapStatesEnum.CONTROLS_STATE, LdapConstants.CONTROLS_TAG,
            new ControlsInitAction() );

        // --------------------------------------------------------------------------------------------
        // CompareResponse Message.
        // --------------------------------------------------------------------------------------------
        // LdapMessage ::= ... CompareResponse ...
        // CompareResponse ::= [APPLICATION 15] LDAPResult
        // We have to switch to the CompareResponse grammar
        super.transitions[LdapStatesEnum.MESSAGE_ID_STATE.ordinal()][LdapConstants.COMPARE_RESPONSE_TAG] = new GrammarTransition(
            LdapStatesEnum.MESSAGE_ID_STATE, LdapStatesEnum.COMPARE_RESPONSE_STATE, LdapConstants.COMPARE_RESPONSE_TAG,
            new GrammarAction<LdapMessageContainer<CompareResponseDecorator>>( "Init CompareResponse" )
            {
                public void action( LdapMessageContainer<CompareResponseDecorator> container ) throws DecoderException
                {
                    // Now, we can allocate the CompareResponse Object
                    CompareResponseDecorator compareResponse = new CompareResponseDecorator(
                        container.getLdapCodecService(), new CompareResponseImpl( container.getMessageId() ) );
                    container.setMessage( compareResponse );

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

            throw new IllegalArgumentException( msg );
        }

        int newId = messageId.incrementAndGet();

        CompareResponse resp = new CompareResponseImpl( newId );
        resp.getLdapResult().setResultCode( ResultCodeEnum.COMPARE_TRUE );

        try
        {
            session.compare( compareRequest );
        }
        catch ( Exception e )
        {
            resp.getLdapResult().setResultCode( ResultCodeEnum.getResultCode( e ) );
        }

        return resp;
    }
View Full Code Here

    /**
     * Creates a new getDecoratedMessage() of CompareResponseDsml.
     */
    public CompareResponseDsml( LdapApiService codec )
    {
        super( codec, new CompareResponseImpl() );
    }
View Full Code Here

            throw new IllegalArgumentException( msg );
        }

        int newId = messageId.incrementAndGet();

        CompareResponse resp = new CompareResponseImpl( newId );
        resp.getLdapResult().setResultCode( ResultCodeEnum.COMPARE_TRUE );

        try
        {
            session.compare( compareRequest );
        }
        catch ( Exception e )
        {
            resp.getLdapResult().setResultCode( ResultCodeEnum.getResultCode( e ) );
        }

        return resp;
    }
View Full Code Here

        // Dn
        if ( tlv.getLength() == 0 )
        {
            String msg = I18n.err( I18n.ERR_04093 );
            LOG.error( msg );
            CompareResponseImpl response = new CompareResponseImpl( compareRequest.getMessageId() );

            throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX,
                compareRequest.getName(), null );
        }
View Full Code Here

            {
                String msg = "Invalid Dn given : " + dnStr + " (" + Strings.dumpBytes(dnBytes)
                    + ") is invalid";
                LOG.error( "{} : {}", msg, ine.getMessage() );

                CompareResponseImpl response = new CompareResponseImpl( compareRequest.getMessageId() );
                throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_DN_SYNTAX,
                    Dn.EMPTY_DN, ine );
            }

            compareRequest.setName( entry );
View Full Code Here

     */
    public void action( LdapMessageContainer<CompareResponseDecorator> container ) throws DecoderException
    {
        // Now, we can allocate the CompareResponse Object
        CompareResponseDecorator compareResponse = new CompareResponseDecorator(
            container.getLdapCodecService(), new CompareResponseImpl( container.getMessageId() ) );
        container.setMessage( compareResponse );

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

View Full Code Here

        // Dn
        if ( tlv.getLength() == 0 )
        {
            String msg = I18n.err( I18n.ERR_04093 );
            LOG.error( msg );
            CompareResponseImpl response = new CompareResponseImpl( compareRequest.getMessageId() );

            throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX,
                compareRequest.getName(), null );
        }
View Full Code Here

TOP

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

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.