Package org.apache.directory.api.asn1

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


        {
            String msg = I18n.err( I18n.ERR_04011 );
            LOG.error( msg );

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

        ResultResponse response = ( ResultResponse ) container.getMessage();
        LdapResult ldapResult = response.getLdapResult();
View Full Code Here


        }
        catch ( IntegerDecoderException ide )
        {
            LOG.error( I18n.err( I18n.ERR_04018, Strings.dumpBytes( value.getData() ), ide.getMessage() ) );

            throw new DecoderException( ide.getMessage() );
        }

        if ( IS_DEBUG )
        {
            LOG.debug( "The result code is set to " + resultCode );
View Full Code Here

                }
                catch ( LdapURLEncodingException luee )
                {
                    String badUrl = Strings.utf8ToString( tlv.getValue().getData() );
                    LOG.error( I18n.err( I18n.ERR_04015, badUrl, luee.getMessage() ) );
                    throw new DecoderException( I18n.err( I18n.ERR_04016, luee.getMessage() ) );
                }
            }
            else
            {
                LOG.warn( "The Referral error message is not allowed when havind an error code no equals to REFERRAL" );
View Full Code Here

        {
            String msg = I18n.err( I18n.ERR_04077 );
            LOG.error( msg );

            // This will generate a PROTOCOL_ERROR
            throw new DecoderException( msg );
        }
    }
View Full Code Here

        {
            LOG.error( I18n
                .err( I18n.ERR_04078, Strings.dumpBytes( value.getData() ), ide.getMessage() ) );

            // This will generate a PROTOCOL_ERROR
            throw new DecoderException( ide.getMessage() );
        }
    }
View Full Code Here

     */
    public void setOid( byte[] oid ) throws DecoderException
    {
        if ( oid == null )
        {
            throw new DecoderException( I18n.err( I18n.ERR_00032_NULL_OID ) );
        }

        if ( oid.length < 1 )
        {
            throw new DecoderException( I18n.err( I18n.ERR_00033_INVALID_OID, Asn1StringUtils.dumpBytes( oid ) ) );
        }

        // First, we have to calculate the number of int to allocate
        int nbValues = 1;
        int pos = 0;
View Full Code Here

     */
    public void setOid( String oid ) throws DecoderException
    {
        if ( ( oid == null ) || ( oid.length() == 0 ) )
        {
            throw new DecoderException( I18n.err( I18n.ERR_00032_NULL_OID ) );
        }

        int nbValues = 1;
        char[] chars = oid.toCharArray();
        boolean dotSeen = false;

        // Count the number of int to allocate.
        for ( char c : chars )
        {
            if ( c == '.' )
            {
                if ( dotSeen )
                {
                    // Two dots, that's an error !
                    throw new DecoderException( I18n.err( I18n.ERR_00033_INVALID_OID, oid ) );
                }

                nbValues++;
                dotSeen = true;
            }
            else
            {
                dotSeen = false;
            }
        }

        // We must have at least 2 ints
        if ( nbValues < 2 )
        {
            throw new DecoderException( I18n.err( I18n.ERR_00033_INVALID_OID, oid ) );
        }

        oidValues = new long[nbValues];

        int pos = 0;
        int intPos = 0;

        // This flag is used to forbid a second value above 39 if the
        // first value is 0 or 1 (itu_t or iso arcs)
        boolean ituOrIso = false;

        // The first value
        switch ( chars[pos] )
        {
            case '0': // itu-t
            case '1': // iso
            case '2': // joint-iso-itu-t
                ituOrIso = true;
                oidValues[intPos++] = chars[pos++] - '0';
                break;

            default: // error, this value is not allowed
                throw new DecoderException( I18n.err( I18n.ERR_00033_INVALID_OID, oid ) );
        }

        // We must have a dot
        if ( chars[pos++] != '.' )
        {
            throw new DecoderException( I18n.err( I18n.ERR_00033_INVALID_OID, oid ) );
        }

        dotSeen = true;

        int value = 0;

        for ( int i = pos; i < chars.length; i++ )
        {
            if ( chars[i] == '.' )
            {
                if ( dotSeen )
                {
                    // Two dots, that's an error !
                    throw new DecoderException( I18n.err( I18n.ERR_00033_INVALID_OID, oid ) );
                }

                if ( ituOrIso && ( value > 39 ) )
                {
                    throw new DecoderException( I18n.err( I18n.ERR_00033_INVALID_OID, oid ) );
                }
                else
                {
                    ituOrIso = false;
                }

                nbValues++;
                dotSeen = true;
                oidValues[intPos++] = value;
                value = 0;
            }
            else if ( ( chars[i] >= 0x30 ) && ( chars[i] <= 0x39 ) )
            {
                dotSeen = false;
                value = ( ( value * 10 ) + chars[i] ) - '0';
            }
            else
            {
                // We don't have a number, this is an error
                throw new DecoderException( I18n.err( I18n.ERR_00033_INVALID_OID, oid ) );
            }
        }

        oidValues[intPos] = value;
        hash = computeHashCode();
View Full Code Here

        {
            String msg = I18n.err( I18n.ERR_04082, Strings.dumpBytes( tlv.getValue().getData() ) );
            LOG.error( msg );

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

        // Store the current operation.
        modifyRequestDecorator.setCurrentOperation( operation );
View Full Code Here

        // OID
        if ( tlv.getLength() == 0 )
        {
            String msg = I18n.err( I18n.ERR_04017 );
            LOG.error( msg );
            throw new DecoderException( msg );
        }
        else
        {
            String responseName = new Oid( Strings.asciiBytesToString( tlv.getValue().getData() ) )
                .toString();
View Full Code Here

        {
            LOG.error( I18n
                .err( I18n.ERR_04100, Strings.dumpBytes( value.getData() ), bde.getMessage() ) );

            // This will generate a PROTOCOL_ERROR
            throw new DecoderException( bde.getMessage() );
        }

        // We can have an END transition
        container.setGrammarEndAllowed( true );
View Full Code Here

TOP

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

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.