Examples of AddRequestDecorator


Examples of org.apache.directory.api.ldap.codec.decorators.AddRequestDecorator

            case ABANDON_REQUEST:
                decorator = new AbandonRequestDecorator( codec, ( AbandonRequest ) decoratedMessage );
                break;

            case ADD_REQUEST:
                decorator = new AddRequestDecorator( codec, ( AddRequest ) decoratedMessage );
                break;

            case ADD_RESPONSE:
                decorator = new AddResponseDecorator( codec, ( AddResponse ) decoratedMessage );
                break;
View Full Code Here

Examples of org.apache.directory.api.ldap.codec.decorators.AddRequestDecorator

            case ABANDON_REQUEST:
                decorator = new AbandonRequestDecorator( codec, ( AbandonRequest ) decoratedMessage );
                break;

            case ADD_REQUEST:
                decorator = new AddRequestDecorator( codec, ( AddRequest ) decoratedMessage );
                break;

            case ADD_RESPONSE:
                decorator = new AddResponseDecorator( codec, ( AddResponse ) decoratedMessage );
                break;
View Full Code Here

Examples of org.apache.directory.api.ldap.codec.decorators.AddRequestDecorator

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

        TLV tlv = container.getCurrentTLV();

        // Store the entry. It can't be null
        if ( tlv.getLength() == 0 )
        {
            String msg = I18n.err( I18n.ERR_04085 );
            LOG.error( msg );

            AddResponseImpl response = new AddResponseImpl( addRequest.getMessageId() );

            // I guess that trying to add an entry which Dn is empty is a naming violation...
            // Not 100% sure though ...
            throw new ResponseCarryingException( msg, response, ResultCodeEnum.NAMING_VIOLATION,
                Dn.EMPTY_DN, null );
        }
        else
        {
            Dn entryDn = null;
            byte[] dnBytes = tlv.getValue().getData();
            String dnStr = Strings.utf8ToString( dnBytes );

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

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

            addRequest.setEntryDn( entryDn );
        }

        LOG.debug( "Adding an entry with Dn : {}", addRequest.getEntry() );
    }
View Full Code Here

Examples of org.apache.directory.api.ldap.codec.decorators.AddRequestDecorator

    /**
     * {@inheritDoc}
     */
    public void action( LdapMessageContainer<AddRequestDecorator> container )
    {
        AddRequestDecorator addRequest = container.getMessage();

        TLV tlv = container.getCurrentTLV();

        // Store the value. It can't be null
        Object value = null;

        try
        {
            if ( tlv.getLength() == 0 )
            {
                addRequest.addAttributeValue( "" );
            }
            else
            {
                if ( container.isBinary( addRequest.getCurrentAttributeType() ) )
                {
                    value = tlv.getValue().getData();

                    if ( IS_DEBUG )
                    {
                        LOG.debug( "Adding value {}", Strings.dumpBytes( ( byte[] ) value ) );
                    }

                    addRequest.addAttributeValue( ( byte[] ) value );
                }
                else
                {
                    value = Strings.utf8ToString( tlv.getValue().getData() );

                    if ( IS_DEBUG )
                    {
                        LOG.debug( "Adding value {}" + value );
                    }

                    addRequest.addAttributeValue( ( String ) value );
                }
            }
        }
        catch ( LdapException le )
        {
View Full Code Here

Examples of org.apache.directory.api.ldap.codec.decorators.AddRequestDecorator

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

        TLV tlv = container.getCurrentTLV();

        // Store the type. It can't be null.
        if ( tlv.getLength() == 0 )
        {
            String msg = I18n.err( I18n.ERR_04086 );
            LOG.error( msg );

            AddResponseImpl response = new AddResponseImpl( addRequest.getMessageId() );

            throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX,
                addRequest.getEntry().getDn(), null );
        }

        String type = Strings.utf8ToString( tlv.getValue().getData() );

        try
        {
            addRequest.addAttributeType( type );
        }
        catch ( LdapException ne )
        {
            String msg = I18n.err( I18n.ERR_04087 );
            LOG.error( msg );

            AddResponseImpl response = new AddResponseImpl( addRequest.getMessageId() );
            throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX,
                addRequest.getEntry().getDn(), ne );
        }

        if ( IS_DEBUG )
        {
            LOG.debug( "Adding type {}", type );
View Full Code Here

Examples of org.apache.directory.api.ldap.codec.decorators.AddRequestDecorator

    {
        // Now, we can allocate the AddRequest Object
        int messageId = container.getMessageId();
        AddRequest internalAddRequest = new AddRequestImpl();
        internalAddRequest.setMessageId( messageId );
        AddRequestDecorator addRequest = new AddRequestDecorator(
            container.getLdapCodecService(), internalAddRequest );
        container.setMessage( addRequest );

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

Examples of org.apache.directory.api.ldap.codec.decorators.AddRequestDecorator

            case ABANDON_REQUEST:
                decorator = new AbandonRequestDecorator( codec, ( AbandonRequest ) decoratedMessage );
                break;

            case ADD_REQUEST:
                decorator = new AddRequestDecorator( codec, ( AddRequest ) decoratedMessage );
                break;

            case ADD_RESPONSE:
                decorator = new AddResponseDecorator( codec, ( AddResponse ) decoratedMessage );
                break;
View Full Code Here

Examples of org.apache.directory.shared.ldap.codec.decorators.AddRequestDecorator

            case ABANDON_REQUEST:
                decorator = new AbandonRequestDecorator( codec, ( AbandonRequest ) decoratedMessage );
                break;

            case ADD_REQUEST:
                decorator = new AddRequestDecorator( codec, ( AddRequest ) decoratedMessage );
                break;
               
            case ADD_RESPONSE:
                decorator = new AddResponseDecorator( codec, ( AddResponse ) decoratedMessage );
                break;
View Full Code Here

Examples of org.apache.directory.shared.ldap.codec.decorators.AddRequestDecorator

            {
                public void action( LdapMessageContainer<AddRequestDecorator> container ) throws DecoderException
                {
                    // Now, we can allocate the AddRequest Object
                    int messageId = container.getMessageId();
                    AddRequestDecorator addRequest = new AddRequestDecorator(
                        container.getLdapCodecService(), new AddRequestImpl( messageId ) );
                    container.setMessage( addRequest );

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

                    if ( tlv.getLength() == 0 )
                    {
                        String msg = I18n.err( I18n.ERR_04084 );
                        LOG.error( msg );

                        // Will generate a PROTOCOL_ERROR
                        throw new DecoderException( msg );
                    }
                }
            } );

        // --------------------------------------------------------------------------------------------
        // Transition from Add Request to Entry
        // --------------------------------------------------------------------------------------------
        // AddRequest ::= [APPLICATION 8] SEQUENCE {
        //     entry           LDAPDN,
        //     ...
        //
        // Stores the Dn
        super.transitions[LdapStatesEnum.ADD_REQUEST_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
            LdapStatesEnum.ADD_REQUEST_STATE, LdapStatesEnum.ENTRY_STATE, UniversalTag.OCTET_STRING.getValue(),
            new GrammarAction<LdapMessageContainer<AddRequestDecorator>>( "Store add request object Value" )
            {
                public void action( LdapMessageContainer<AddRequestDecorator> container ) throws DecoderException
                {
                    AddRequestDecorator addRequest = container.getMessage();

                    TLV tlv = container.getCurrentTLV();

                    // Store the entry. It can't be null
                    if ( tlv.getLength() == 0 )
                    {
                        String msg = I18n.err( I18n.ERR_04085 );
                        LOG.error( msg );

                        AddResponseImpl response = new AddResponseImpl( addRequest.getMessageId() );

                        // I guess that trying to add an entry which Dn is empty is a naming violation...
                        // Not 100% sure though ...
                        throw new ResponseCarryingException( msg, response, ResultCodeEnum.NAMING_VIOLATION,
                            Dn.EMPTY_DN, null );
                    }
                    else
                    {
                        Dn entryDn = null;
                        byte[] dnBytes = tlv.getValue().getData();
                        String dnStr = Strings.utf8ToString(dnBytes);

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

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

                        addRequest.setEntryDn( entryDn );
                    }

                    LOG.debug( "Adding an entry with Dn : {}", addRequest.getEntry() );
                }
            } );

        // --------------------------------------------------------------------------------------------
        // Transition from Entry to Attributes
        // --------------------------------------------------------------------------------------------
        // AddRequest ::= [APPLICATION 8] SEQUENCE {
        //     ...
        //    attributes AttributeList }
        //
        // AttributeList ::= SEQUENCE OF ...
        //
        // Initialize the attribute list
        super.transitions[LdapStatesEnum.ENTRY_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
            LdapStatesEnum.ENTRY_STATE, LdapStatesEnum.ATTRIBUTES_STATE, UniversalTag.SEQUENCE.getValue(), null );

        // --------------------------------------------------------------------------------------------
        // Transition from Attributes to Attribute
        // --------------------------------------------------------------------------------------------
        // AttributeList ::= SEQUENCE OF SEQUENCE {
        //
        // We don't do anything in this transition. The attribute will be created when we met the type
        super.transitions[LdapStatesEnum.ATTRIBUTES_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
            LdapStatesEnum.ATTRIBUTES_STATE, LdapStatesEnum.ATTRIBUTE_STATE, UniversalTag.SEQUENCE.getValue(), null );

        // --------------------------------------------------------------------------------------------
        // Transition from Attribute to type
        // --------------------------------------------------------------------------------------------
        // AttributeList ::= SEQUENCE OF SEQUENCE {
        //     type    AttributeDescription,
        //     ...
        //
        // AttributeDescription LDAPString
        //
        // We store the type in the current attribute
        super.transitions[LdapStatesEnum.ATTRIBUTE_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
            LdapStatesEnum.ATTRIBUTE_STATE, LdapStatesEnum.TYPE_STATE, UniversalTag.OCTET_STRING.getValue(),
            new GrammarAction<LdapMessageContainer<AddRequestDecorator>>( "Store attribute type" )
            {
                public void action( LdapMessageContainer<AddRequestDecorator> container ) throws DecoderException
                {
                    AddRequestDecorator addRequest = container.getMessage();

                    TLV tlv = container.getCurrentTLV();

                    // Store the type. It can't be null.
                    if ( tlv.getLength() == 0 )
                    {
                        String msg = I18n.err( I18n.ERR_04086 );
                        LOG.error( msg );

                        AddResponseImpl response = new AddResponseImpl( addRequest.getMessageId() );

                        throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX,
                            addRequest.getEntry().getDn(), null );
                    }

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

                    try
                    {
                        addRequest.addAttributeType( type );
                    }
                    catch ( LdapException ne )
                    {
                        String msg = I18n.err( I18n.ERR_04087 );
                        LOG.error( msg );

                        AddResponseImpl response = new AddResponseImpl( addRequest.getMessageId() );
                        throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX,
                            addRequest.getEntry().getDn(), ne );
                    }

                    if ( IS_DEBUG )
                    {
                        LOG.debug( "Adding type {}", type );
View Full Code Here

Examples of org.apache.directory.shared.ldap.codec.decorators.AddRequestDecorator

    /**
     * {@inheritDoc}
     */
    public void action( LdapMessageContainer<AddRequestDecorator> container )
    {
        AddRequestDecorator addRequest = container.getMessage();

        TLV tlv = container.getCurrentTLV();

        // Store the value. It can't be null
        Object value = null;

        if ( tlv.getLength() == 0 )
        {
            addRequest.addAttributeValue( "" );
        }
        else
        {
            if ( container.isBinary( addRequest.getCurrentAttributeType() ) )
            {
                value = tlv.getValue().getData();

                if ( IS_DEBUG )
                {
                    LOG.debug( "Adding value {}", Strings.dumpBytes((byte[]) value) );
                }

                addRequest.addAttributeValue( ( byte[] ) value );
            }
            else
            {
                value = Strings.utf8ToString(tlv.getValue().getData());

                if ( IS_DEBUG )
                {
                    LOG.debug( "Adding value {}" + value );
                }

                addRequest.addAttributeValue( ( String ) value );
            }

        }

        // We can have an END transition
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.