Package org.apache.directory.api.asn1

Examples of org.apache.directory.api.asn1.EncoderException


     */
    public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
    {
        if ( buffer == null )
        {
            throw new EncoderException( I18n.err( I18n.ERR_04023 ) );
        }

        try
        {
            // The ExtensibleMatch Tag
            buffer.put( ( byte ) LdapConstants.EXTENSIBLE_MATCH_FILTER_TAG );
            buffer.put( TLV.getBytes( extensibleMatchLength ) );

            if ( ( matchingRule == null ) && ( type == null ) )
            {
                throw new EncoderException( I18n.err( I18n.ERR_04056 ) );
            }

            // The matching rule
            if ( matchingRule != null )
            {
                buffer.put( ( byte ) LdapConstants.MATCHING_RULE_ID_TAG );
                buffer.put( TLV.getBytes( matchingRuleBytes.length ) );
                buffer.put( matchingRuleBytes );
            }

            // The type
            if ( type != null )
            {
                buffer.put( ( byte ) LdapConstants.MATCHING_RULE_TYPE_TAG );
                buffer.put( TLV.getBytes( typeBytes.length ) );
                buffer.put( typeBytes );
            }

            // The match value
            if ( matchValue != null )
            {
                buffer.put( ( byte ) LdapConstants.MATCH_VALUE_TAG );

                byte[] bytes = matchValue.getBytes();
                int bytesLength = bytes.length;
                buffer.put( TLV.getBytes( bytesLength ) );

                if ( bytesLength != 0 )
                {
                    buffer.put( bytes );
                }

            }

            // The dnAttributes flag, if true only
            if ( dnAttributes )
            {
                buffer.put( ( byte ) LdapConstants.DN_ATTRIBUTES_FILTER_TAG );
                buffer.put( ( byte ) 1 );
                buffer.put( BerValue.TRUE_VALUE );
            }
        }
        catch ( BufferOverflowException boe )
        {
            throw new EncoderException( I18n.err( I18n.ERR_04005 ) );
        }

        return buffer;
    }
View Full Code Here


     */
    public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
    {
        if ( buffer == null )
        {
            throw new EncoderException( I18n.err( I18n.ERR_04023 ) );
        }

        try
        {
            // The PresentFilter Tag
            buffer.put( ( byte ) LdapConstants.PRESENT_FILTER_TAG );
            buffer.put( TLV.getBytes( attributeDescriptionBytes.length ) );
            buffer.put( attributeDescriptionBytes );
        }
        catch ( BufferOverflowException boe )
        {
            throw new EncoderException( I18n.err( I18n.ERR_04005 ) );
        }

        return buffer;
    }
View Full Code Here

     */
    public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
    {
        if ( buffer == null )
        {
            throw new EncoderException( I18n.err( I18n.ERR_04023 ) );
        }

        // encode each filter
        if ( ( filterSet != null ) && ( filterSet.size() != 0 ) )
        {
View Full Code Here

     */
    public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
    {
        if ( buffer == null )
        {
            throw new EncoderException( I18n.err( I18n.ERR_04023 ) );
        }

        try
        {
            // The AndFilter Tag
            buffer.put( ( byte ) LdapConstants.AND_FILTER_TAG );
            buffer.put( TLV.getBytes( filtersLength ) );
        }
        catch ( BufferOverflowException boe )
        {
            throw new EncoderException( I18n.err( I18n.ERR_04005 ) );
        }

        super.encode( buffer );

        return buffer;
View Full Code Here

     */
    public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
    {
        if ( buffer == null )
        {
            throw new EncoderException( I18n.err( I18n.ERR_04023 ) );
        }

        try
        {
            // The NotFilter Tag
            buffer.put( ( byte ) LdapConstants.NOT_FILTER_TAG );
            buffer.put( TLV.getBytes( filtersLength ) );
        }
        catch ( BufferOverflowException boe )
        {
            throw new EncoderException( I18n.err( I18n.ERR_04005 ) );
        }

        super.encode( buffer );

        return buffer;
View Full Code Here

     */
    public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
    {
        if ( buffer == null )
        {
            throw new EncoderException( I18n.err( I18n.ERR_04023 ) );
        }

        try
        {
            // The SubstringFilter Tag
            buffer.put( ( byte ) LdapConstants.SUBSTRINGS_FILTER_TAG );
            buffer.put( TLV.getBytes( substringsFilterLength ) );

            // The type
            BerValue.encode( buffer, type.getBytes() );

            // The SubstringSequenceFilter Tag
            buffer.put( UniversalTag.SEQUENCE.getValue() );
            buffer.put( TLV.getBytes( substringsFilterSequenceLength ) );

            if ( ( initialSubstrings == null ) && ( ( anySubstrings == null ) || ( anySubstrings.size() == 0 ) )
                && ( finalSubstrings == null ) )
            {
                throw new EncoderException( I18n.err( I18n.ERR_04058 ) );
            }

            // The initial substring
            if ( initialSubstrings != null )
            {
                byte[] initialBytes = Strings.getBytesUtf8( initialSubstrings );
                buffer.put( ( byte ) LdapConstants.SUBSTRINGS_FILTER_INITIAL_TAG );
                buffer.put( TLV.getBytes( initialBytes.length ) );
                buffer.put( initialBytes );
            }

            // The any substrings
            if ( anySubstrings != null )
            {
                for ( String any : anySubstrings )
                {
                    byte[] anyBytes = Strings.getBytesUtf8( any );
                    buffer.put( ( byte ) LdapConstants.SUBSTRINGS_FILTER_ANY_TAG );
                    buffer.put( TLV.getBytes( anyBytes.length ) );
                    buffer.put( anyBytes );
                }
            }

            // The final substring
            if ( finalSubstrings != null )
            {
                byte[] finalBytes = Strings.getBytesUtf8( finalSubstrings );
                buffer.put( ( byte ) LdapConstants.SUBSTRINGS_FILTER_FINAL_TAG );
                buffer.put( TLV.getBytes( finalBytes.length ) );
                buffer.put( finalBytes );
            }
        }
        catch ( BufferOverflowException boe )
        {
            throw new EncoderException( I18n.err( I18n.ERR_04005 ) );
        }

        return buffer;
    }
View Full Code Here

     */
    public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
    {
        if ( buffer == null )
        {
            throw new EncoderException( I18n.err( I18n.ERR_04023 ) );
        }

        try
        {
            // The OrFilter Tag
            buffer.put( ( byte ) LdapConstants.OR_FILTER_TAG );
            buffer.put( TLV.getBytes( filtersLength ) );
        }
        catch ( BufferOverflowException boe )
        {
            throw new EncoderException( I18n.err( I18n.ERR_04005 ) );
        }

        super.encode( buffer );

        return buffer;
View Full Code Here

     */
    public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
    {
        if ( buffer == null )
        {
            throw new EncoderException( I18n.err( I18n.ERR_04023 ) );
        }

        try
        {
            // The AttributeValueAssertion Tag
            switch ( filterType )
            {
                case LdapConstants.EQUALITY_MATCH_FILTER:
                    buffer.put( ( byte ) LdapConstants.EQUALITY_MATCH_FILTER_TAG );
                    break;

                case LdapConstants.LESS_OR_EQUAL_FILTER:
                    buffer.put( ( byte ) LdapConstants.LESS_OR_EQUAL_FILTER_TAG );
                    break;

                case LdapConstants.GREATER_OR_EQUAL_FILTER:
                    buffer.put( ( byte ) LdapConstants.GREATER_OR_EQUAL_FILTER_TAG );
                    break;

                case LdapConstants.APPROX_MATCH_FILTER:
                    buffer.put( ( byte ) LdapConstants.APPROX_MATCH_FILTER_TAG );
                    break;
            }

            buffer.put( TLV.getBytes( avaLength ) );
        }
        catch ( BufferOverflowException boe )
        {
            throw new EncoderException( I18n.err( I18n.ERR_04005 ) );
        }

        // The attribute desc
        BerValue.encode( buffer, assertion.getAttributeDesc() );

View Full Code Here

     */
    public static void encode( ByteBuffer buffer, String string ) throws EncoderException
    {
        if ( buffer == null )
        {
            throw new EncoderException( I18n.err( I18n.ERR_00003_CANNOT_PUT_PDU_IN_NULL_BUFFER ) );
        }

        try
        {
            buffer.put( UniversalTag.OCTET_STRING.getValue() );

            byte[] value = Asn1StringUtils.getBytesUtf8( string );

            buffer.put( TLV.getBytes( value.length ) );

            if ( value.length != 0 )
            {
                buffer.put( value );
            }
        }
        catch ( BufferOverflowException boe )
        {
            throw new EncoderException( I18n.err( I18n.ERR_00004_PDU_BUFFER_SIZE_TOO_SMALL ) );
        }
    }
View Full Code Here

     */
    public static void encode( ByteBuffer buffer, BitString bitString ) throws EncoderException
    {
        if ( buffer == null )
        {
            throw new EncoderException( I18n.err( I18n.ERR_00003_CANNOT_PUT_PDU_IN_NULL_BUFFER ) );
        }

        try
        {
            buffer.put( UniversalTag.BIT_STRING.getValue() );

            // The BitString length. We add one byte for the unused number
            // of bits
            byte[] bytes = bitString.getData();
            int length = bytes.length;

            buffer.put( TLV.getBytes( length ) );
            buffer.put( bytes );
        }
        catch ( BufferOverflowException boe )
        {
            throw new EncoderException( I18n.err( I18n.ERR_00004_PDU_BUFFER_SIZE_TOO_SMALL ) );
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.api.asn1.EncoderException

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.