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

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


     * {@inheritDoc}
     */
    public void action( LdapMessageContainer<CompareRequestDecorator> container )
    {
        // Now, we can allocate the CompareRequest Object
        CompareRequest internalCompareRequest = new CompareRequestImpl();
        internalCompareRequest.setMessageId( container.getMessageId() );
        CompareRequestDecorator compareRequest = new CompareRequestDecorator(
            container.getLdapCodecService(), internalCompareRequest );
        container.setMessage( compareRequest );

        LOG.debug( "Compare Request" );
View Full Code Here


     * {@inheritDoc}
     */
    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
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public void action( LdapMessageContainer<CompareRequestDecorator> container ) throws DecoderException
    {
        CompareRequest compareRequest = container.getMessage();

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

        // We have to handle the special case of a 0 length matched
        // Dn
        if ( tlv.getLength() == 0 )
        {
            // This will generate a PROTOCOL_ERROR
            throw new DecoderException( I18n.err( I18n.ERR_04089 ) );
        }
        else
        {
            byte[] dnBytes = tlv.getValue().getData();
            String dnStr = Strings.utf8ToString(dnBytes);

            try
            {
                entry = new Dn( dnStr );
            }
            catch ( LdapInvalidDnException ine )
            {
                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 );
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public boolean compare( Dn dn, String attributeName, String value ) throws LdapException
    {
        CompareRequest compareRequest = new CompareRequestImpl();
        compareRequest.setName( dn );
        compareRequest.setAttributeId( attributeName );
        compareRequest.setAssertionValue( value );

        CompareResponse compareResponse = compare( compareRequest );

        return processResponse( compareResponse );
    }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public boolean compare( Dn dn, String attributeName, byte[] value ) throws LdapException
    {
        CompareRequest compareRequest = new CompareRequestImpl();
        compareRequest.setName( dn );
        compareRequest.setAttributeId( attributeName );
        compareRequest.setAssertionValue( value );

        CompareResponse compareResponse = compare( compareRequest );

        return processResponse( compareResponse );
    }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public boolean compare( Dn dn, String attributeName, Value<?> value ) throws LdapException
    {
        CompareRequest compareRequest = new CompareRequestImpl();
        compareRequest.setName( dn );
        compareRequest.setAttributeId( attributeName );

        if ( value.isHumanReadable() )
        {
            compareRequest.setAssertionValue( value.getString() );
        }
        else
        {
            compareRequest.setAssertionValue( value.getBytes() );
        }

        CompareResponse compareResponse = compare( compareRequest );

        return processResponse( compareResponse );
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public boolean compare( Dn dn, String attributeName, String value ) throws LdapException
    {
        CompareRequest compareRequest = new CompareRequestImpl();
        compareRequest.setName( dn );
        compareRequest.setAttributeId( attributeName );
        compareRequest.setAssertionValue( value );

        CompareResponse compareResponse = compare( compareRequest );
       
        return processResponse( compareResponse );
    }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public boolean compare( Dn dn, String attributeName, byte[] value ) throws LdapException
    {
        CompareRequest compareRequest = new CompareRequestImpl();
        compareRequest.setName( dn );
        compareRequest.setAttributeId( attributeName );
        compareRequest.setAssertionValue( value );

        CompareResponse compareResponse = compare( compareRequest );
       
        return processResponse( compareResponse );
    }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public boolean compare( Dn dn, String attributeName, Value<?> value ) throws LdapException
    {
        CompareRequest compareRequest = new CompareRequestImpl();
        compareRequest.setName( dn );
        compareRequest.setAttributeId( attributeName );

        if ( value.isHumanReadable() )
        {
            compareRequest.setAssertionValue( value.getString() );
        }
        else
        {
            compareRequest.setAssertionValue( value.getBytes() );
        }

        CompareResponse compareResponse = compare( compareRequest );
       
        return processResponse( compareResponse );
View Full Code Here

            de.printStackTrace();
            fail( de.getMessage() );
        }

        // Check the decoded CompareRequest PDU
        CompareRequest compareRequest = container.getMessage();

        assertEquals( 1, compareRequest.getMessageId() );
        assertEquals( "cn=testModify,ou=users,ou=system", compareRequest.getName().toString() );
        assertEquals( "test", compareRequest.getAttributeId() );
        assertEquals( "value", compareRequest.getAssertionValue().toString() );

        // Check the encoding
        try
        {
            ByteBuffer bb = encoder.encodeMessage( compareRequest );
View Full Code Here

TOP

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

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.