Package org.apache.directory.shared.asn1

Examples of org.apache.directory.shared.asn1.AbstractAsn1Object


{

    @Override
    public void encode( IoSession session, Object message, ProtocolEncoderOutput out ) throws Exception
    {
        AbstractAsn1Object asn1Obj = ( AbstractAsn1Object ) message;
        boolean isTcp = !session.getTransportMetadata().isConnectionless();

        ByteBuffer encodedByteBuf = KerberosEncoder.encode( asn1Obj, isTcp );
        IoBuffer buf = IoBuffer.allocate( encodedByteBuf.remaining() );
        buf.put( encodedByteBuf.array() );
View Full Code Here


*/
public class KerberosEncoder extends ProtocolEncoderAdapter
{
    public void encode( IoSession session, Object message, ProtocolEncoderOutput out ) throws IOException
    {
        AbstractAsn1Object asn1Obj = ( AbstractAsn1Object ) message;
        boolean isTcp = !session.getTransportMetadata().isConnectionless();
        IoBuffer response = null;
        IoBuffer kerberosMessage = null;

        int responseLength = asn1Obj.computeLength();
        kerberosMessage = IoBuffer.allocate( responseLength );

        if ( isTcp )
        {
            response = IoBuffer.allocate( responseLength + 4 );
        }
        else
        {
            response = kerberosMessage;
        }

        try
        {
            asn1Obj.encode( kerberosMessage.buf() );

            if ( isTcp )
            {
                response.putInt( responseLength );
                response.put( kerberosMessage.buf().array() );
View Full Code Here

*/
public class KerberosEncoder extends ProtocolEncoderAdapter
{
    public void encode( IoSession session, Object message, ProtocolEncoderOutput out ) throws IOException
    {
        AbstractAsn1Object asn1Obj = ( AbstractAsn1Object ) message;
        boolean isTcp = !session.getTransportMetadata().isConnectionless();
        IoBuffer response = null;
        IoBuffer kerberosMessage = null;
       
        int responseLength = asn1Obj.computeLength();
        kerberosMessage = IoBuffer.allocate( responseLength );
       
        if ( isTcp )
        {
            response = IoBuffer.allocate( responseLength + 4 );
        }
        else
        {
            response = kerberosMessage;
        }

        try
        {
            asn1Obj.encode( kerberosMessage.buf() );

            if ( isTcp )
            {
                response.putInt( responseLength );
                response.put( kerberosMessage.buf().array() );
View Full Code Here

*/
public class KerberosEncoder extends ProtocolEncoderAdapter
{
    public void encode( IoSession session, Object message, ProtocolEncoderOutput out ) throws IOException
    {
        AbstractAsn1Object asn1Obj = ( AbstractAsn1Object ) message;
        boolean isTcp = !session.getTransportMetadata().isConnectionless();
        IoBuffer response = null;
        IoBuffer kerberosMessage = null;

        int responseLength = asn1Obj.computeLength();
        kerberosMessage = IoBuffer.allocate( responseLength );

        if ( isTcp )
        {
            response = IoBuffer.allocate( responseLength + 4 );
        }
        else
        {
            response = kerberosMessage;
        }

        try
        {
            asn1Obj.encode( kerberosMessage.buf() );

            if ( isTcp )
            {
                response.putInt( responseLength );
                response.put( kerberosMessage.buf().array() );
View Full Code Here

*/
public class KerberosEncoder extends ProtocolEncoderAdapter
{
    public void encode( IoSession session, Object message, ProtocolEncoderOutput out ) throws IOException
    {
        AbstractAsn1Object asn1Obj = ( AbstractAsn1Object ) message;
       
        IoBuffer buf = IoBuffer.allocate( asn1Obj.computeLength() );

        try
        {
            asn1Obj.encode( buf.buf() );

            buf.flip();

            out.write( buf );
        }
View Full Code Here

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

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

        if ( IS_DEBUG )
        {
            LOG.debug( "Dn Attributes : {}", Boolean.valueOf( extensibleMatchFilter.isDnAttributes() ) );
View Full Code Here

                        }
                        catch ( IntegerDecoderException e )
                        {
                            String msg = I18n.err( I18n.ERR_04031, Strings.dumpBytes( value.getData() ) );
                            LOG.error( msg );
                            throw new DecoderException( msg );
                        }
                    }
                } );
    }
View Full Code Here

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

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

                                    break;

                                default:
                                    String msg = I18n.err( I18n.ERR_04044 );
                                    LOG.error( msg );
                                    throw new DecoderException( msg );
                            }

                            // We can have an END transition
                            container.setGrammarEndAllowed( true );
                        }
                        catch ( IntegerDecoderException e )
                        {
                            String msg = I18n.err( I18n.ERR_04044 );
                            LOG.error( msg, e );
                            throw new DecoderException( msg );
                        }
                        catch ( IllegalArgumentException e )
                        {
                            throw new DecoderException( e.getLocalizedMessage() );
                        }
                    }
                } );

        // ============================================================================================
        // Transition from Change Type to Previous Dn
        // ============================================================================================
        // EntryChangeNotification ::= SEQUENCE {
        //     ...
        //     previousDN LDAPDN OPTIONAL,
        //     ...
        //
        // Set the previousDN into the structure. We first check that it's a
        // valid Dn
        super.transitions[EntryChangeStates.CHANGE_TYPE_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] =
            new GrammarTransition<EntryChangeContainer>( EntryChangeStates.CHANGE_TYPE_STATE,
                EntryChangeStates.PREVIOUS_DN_STATE,
                UniversalTag.OCTET_STRING.getValue(),
                new GrammarAction<EntryChangeContainer>( "Set EntryChangeControl previousDN" )
                {
                    public void action( EntryChangeContainer container ) throws DecoderException
                    {
                        ChangeType changeType = container.getEntryChangeDecorator().getChangeType();

                        if ( changeType != ChangeType.MODDN )
                        {
                            LOG.error( I18n.err( I18n.ERR_04045 ) );
                            throw new DecoderException( I18n.err( I18n.ERR_04046 ) );
                        }
                        else
                        {
                            Value value = container.getCurrentTLV().getValue();
                            Dn previousDn;

                            try
                            {
                                previousDn = new Dn( Strings.utf8ToString( value.getData() ) );
                            }
                            catch ( LdapInvalidDnException ine )
                            {
                                LOG.error( I18n.err( I18n.ERR_04047, Strings.dumpBytes( value.getData() ) ) );
                                throw new DecoderException( I18n.err( I18n.ERR_04048 ) );
                            }

                            if ( IS_DEBUG )
                            {
                                LOG.debug( "previousDN = " + previousDn );
                            }

                            container.getEntryChangeDecorator().setPreviousDn( previousDn );

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

        // Change Number action
        GrammarAction<EntryChangeContainer> setChangeNumberAction = new GrammarAction<EntryChangeContainer>(
            "Set EntryChangeControl changeNumber" )
        {
            public void action( EntryChangeContainer container ) throws DecoderException
            {
                Value value = container.getCurrentTLV().getValue();

                try
                {
                    long changeNumber = LongDecoder.parse( value );

                    if ( IS_DEBUG )
                    {
                        LOG.debug( "changeNumber = " + changeNumber );
                    }

                    container.getEntryChangeDecorator().setChangeNumber( changeNumber );

                    // We can have an END transition
                    container.setGrammarEndAllowed( true );
                }
                catch ( LongDecoderException e )
                {
                    String msg = I18n.err( I18n.ERR_04049 );
                    LOG.error( msg, e );
                    throw new DecoderException( msg );
                }
            }
        };

        // ============================================================================================
View Full Code Here

                        }
                        catch ( IntegerDecoderException e )
                        {
                            String msg = I18n.err( I18n.ERR_04051 );
                            LOG.error( msg, e );
                            throw new DecoderException( msg );
                        }
                    }
                } );

        /**
         * Transition from Change types to Changes only
         * PSearch ::= SEQUENCE OF {
         *     ...
         *     changeOnly   BOOLEAN,
         *     ...
         *    
         * Stores the change only flag
         */
        super.transitions[PersistentSearchStates.CHANGE_TYPES_STATE.ordinal()][UniversalTag.BOOLEAN.getValue()] =
            new GrammarTransition<PersistentSearchContainer>( PersistentSearchStates.CHANGE_TYPES_STATE,
                PersistentSearchStates.CHANGES_ONLY_STATE, UniversalTag.BOOLEAN.getValue(),
                new GrammarAction<PersistentSearchContainer>( "Set PSearchControl changesOnly" )
                {
                    public void action( PersistentSearchContainer container ) throws DecoderException
                    {
                        Value value = container.getCurrentTLV().getValue();

                        try
                        {
                            boolean changesOnly = BooleanDecoder.parse( value );

                            if ( IS_DEBUG )
                            {
                                LOG.debug( "changesOnly = " + changesOnly );
                            }

                            container.getPersistentSearchDecorator().setChangesOnly( changesOnly );
                        }
                        catch ( BooleanDecoderException e )
                        {
                            String msg = I18n.err( I18n.ERR_04052 );
                            LOG.error( msg, e );
                            throw new DecoderException( msg );
                        }
                    }
                } );

        /**
         * Transition from Change types to Changes only
         * PSearch ::= SEQUENCE OF {
         *     ...
         *     returnECs    BOOLEAN
         * }
         *    
         * Stores the return ECs flag
         */
        super.transitions[PersistentSearchStates.CHANGES_ONLY_STATE.ordinal()][UniversalTag.BOOLEAN.getValue()] =
            new GrammarTransition<PersistentSearchContainer>( PersistentSearchStates.CHANGES_ONLY_STATE,
                PersistentSearchStates.RETURN_ECS_STATE, UniversalTag.BOOLEAN.getValue(),
                new GrammarAction<PersistentSearchContainer>( "Set PSearchControl returnECs" )
                {
                    public void action( PersistentSearchContainer container ) throws DecoderException
                    {
                        Value value = container.getCurrentTLV().getValue();

                        try
                        {
                            boolean returnECs = BooleanDecoder.parse( value );

                            if ( IS_DEBUG )
                            {
                                LOG.debug( "returnECs = " + returnECs );
                            }

                            container.getPersistentSearchDecorator().setReturnECs( returnECs );

                            // We can have an END transition
                            container.setGrammarEndAllowed( true );
                        }
                        catch ( BooleanDecoderException e )
                        {
                            String msg = I18n.err( I18n.ERR_04053 );
                            LOG.error( msg, e );
                            throw new DecoderException( msg );
                        }
                    }
                } );
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.asn1.AbstractAsn1Object

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.