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_148 ) );
        }

        try
        {
            // The lastRequest SEQ OF Tag
            buffer.put( UniversalTag.SEQUENCE.getValue() );
            buffer.put( TLV.getBytes( lastReqSeqSeqLen ) );

            int i = 0;

            for ( LastReqEntry lre : lastReqs )
            {
                buffer.put( UniversalTag.SEQUENCE.getValue() );
                buffer.put( TLV.getBytes( lastReqSeqLen[i] ) );

                // the lrType
                buffer.put( ( byte ) KerberosConstants.LAST_REQ_LR_TYPE_TAG );
                buffer.put( TLV.getBytes( lrTypeTagLen[i] ) );
                BerValue.encode( buffer, lre.getLrType().getValue() );

                // the lrValue tag
                buffer.put( ( byte ) KerberosConstants.LAST_REQ_LR_VALUE_TAG );
                buffer.put( TLV.getBytes( lrValueTagLen[i] ) );

                // the lrValue value
                buffer.put( ( byte ) UniversalTag.GENERALIZED_TIME.getValue() );
                buffer.put( ( byte ) 0x0F );
                buffer.put( lre.getLrValue().getBytes() );
            }
        }
        catch ( BufferOverflowException boe )
        {
            LOG.error( I18n.err( I18n.ERR_139, 1 + TLV.getNbBytes( lastReqSeqSeqLen )
                + lastReqSeqSeqLen, buffer.capacity() ) );
            throw new EncoderException( I18n.err( I18n.ERR_138 ) );
        }

        if ( IS_DEBUG )
        {
            LOG.debug( "LastReq encoding : {}", Strings.dumpBytes( buffer.array() ) );
View Full Code Here


    @Override
    public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
    {
        if ( buffer == null )
        {
            throw new EncoderException( I18n.err( I18n.ERR_148 ) );
        }

        try
        {
            // The AuthorizationData SEQ OF Tag
            buffer.put( UniversalTag.SEQUENCE.getValue() );
            buffer.put( TLV.getBytes( authorizationDataSeqSeqLen ) );

            int i = 0;

            for ( AuthorizationDataEntry ad : authorizationData )
            {
                buffer.put( UniversalTag.SEQUENCE.getValue() );
                buffer.put( TLV.getBytes( authorizationDataSeqLen[i] ) );

                // the adType
                buffer.put( ( byte ) KerberosConstants.AUTHORIZATION_DATA_ADTYPE_TAG );
                buffer.put( TLV.getBytes( adTypeTagLen[i] ) );
                BerValue.encode( buffer, ad.getAdType().getValue() );

                // the adData
                buffer.put( ( byte ) KerberosConstants.AUTHORIZATION_DATA_ADDATA_TAG );
                buffer.put( TLV.getBytes( adDataTagLen[i] ) );
                BerValue.encode( buffer, ad.getAdDataRef() );

                i++;
            }
        }
        catch ( BufferOverflowException boe )
        {
            LOG.error( I18n.err( I18n.ERR_139, 1 + TLV.getNbBytes( authorizationDataSeqSeqLen )
                + authorizationDataSeqSeqLen, buffer.capacity() ) );
            throw new EncoderException( I18n.err( I18n.ERR_138 ) );
        }

        if ( IS_DEBUG )
        {
            LOG.debug( "AuthorizationData encoding : {}", Strings.dumpBytes( buffer.array() ) );
View Full Code Here

    @Override
    public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
    {
        if ( buffer == null )
        {
            throw new EncoderException( I18n.err( I18n.ERR_148 ) );
        }

        try
        {
            buffer.put( UniversalTag.SEQUENCE.getValue() );
            buffer.put( TLV.getBytes( krbKredInfoSeqLen ) );

            //key tag and value
            buffer.put( ( byte ) KerberosConstants.KRB_CRED_INFO_KEY_TAG );
            buffer.put( TLV.getBytes( keyLen ) );
            key.encode( buffer );

            if ( pRealm != null )
            {
                // prealm tag and value
                buffer.put( ( byte ) KerberosConstants.KRB_CRED_INFO_PREALM_TAG );
                buffer.put( TLV.getBytes( pRealmLen ) );

                buffer.put( UniversalTag.GENERAL_STRING.getValue() );
                buffer.put( TLV.getBytes( pRealmBytes.length ) );
                buffer.put( pRealmBytes );
            }

            if ( pName != null )
            {
                // pname tag and value
                buffer.put( ( byte ) KerberosConstants.KRB_CRED_INFO_PNAME_TAG );
                buffer.put( TLV.getBytes( pNameLen ) );
                pName.encode( buffer );
            }

            if ( ticketFlags != null )
            {
                // flags tag and value
                buffer.put( ( byte ) KerberosConstants.KRB_CRED_INFO_FLAGS_TAG );
                buffer.put( TLV.getBytes( ticketFlagsLen ) );
                BerValue.encode( buffer, ticketFlags );
            }

            if ( authTime != null )
            {
                // authtime tag and value
                buffer.put( ( byte ) KerberosConstants.KRB_CRED_INFO_AUTHTIME_TAG );
                buffer.put( TLV.getBytes( authTimeLen ) );

                buffer.put( ( byte ) UniversalTag.GENERALIZED_TIME.getValue() );
                buffer.put( ( byte ) 0x0F );
                buffer.put( authTimeBytes );
            }

            if ( startTime != null )
            {
                // starttime tag and value
                buffer.put( ( byte ) KerberosConstants.KRB_CRED_INFO_STARTTIME_TAG );
                buffer.put( TLV.getBytes( startTimeLen ) );

                buffer.put( UniversalTag.GENERALIZED_TIME.getValue() );
                buffer.put( ( byte ) 0x0F );
                buffer.put( startTimeBytes );
            }

            if ( endTime != null )
            {
                // endtime tag and value
                buffer.put( ( byte ) KerberosConstants.KRB_CRED_INFO_ENDTIME_TAG );
                buffer.put( TLV.getBytes( endTimeLen ) );

                buffer.put( UniversalTag.GENERALIZED_TIME.getValue() );
                buffer.put( ( byte ) 0x0F );
                buffer.put( endTimeBytes );
            }

            if ( renewtill != null )
            {
                // renewtill tag and value
                buffer.put( ( byte ) KerberosConstants.KRB_CRED_INFO_RENEWTILL_TAG );
                buffer.put( TLV.getBytes( renewtillLen ) );

                buffer.put( UniversalTag.GENERALIZED_TIME.getValue() );
                buffer.put( ( byte ) 0x0F );
                buffer.put( renewtillBytes );
            }

            if ( sRealm != null )
            {
                // srealm tag and value
                buffer.put( ( byte ) KerberosConstants.KRB_CRED_INFO_SREALM_TAG );
                buffer.put( TLV.getBytes( sRealmLen ) );

                buffer.put( UniversalTag.GENERAL_STRING.getValue() );
                buffer.put( TLV.getBytes( sRealmBytes.length ) );
                buffer.put( sRealmBytes );
            }

            if ( sName != null )
            {
                // sname tag and value
                buffer.put( ( byte ) KerberosConstants.KRB_CRED_INFO_SNAME_TAG );
                buffer.put( TLV.getBytes( sNameLen ) );
                sName.encode( buffer );
            }

            if ( clientAddresses != null )
            {
                // caddr tag and value
                buffer.put( ( byte ) KerberosConstants.KRB_CRED_INFO_CADDR_TAG );
                buffer.put( TLV.getBytes( clientAddressesLen ) );
                clientAddresses.encode( buffer );
            }
        }
        catch ( BufferOverflowException boe )
        {
            log.error( I18n.err( I18n.ERR_739_CANNOT_ENCODE_KRB_CRED_INFO, 1 + TLV.getNbBytes( krbKredInfoSeqLen )
                + krbKredInfoSeqLen, buffer.capacity() ) );
            throw new EncoderException( I18n.err( I18n.ERR_138 ) );
        }

        if ( IS_DEBUG )
        {
            log.debug( "KrbCredInfo encoding : {}", Strings.dumpBytes( buffer.array() ) );
View Full Code Here

    @Override
    public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
    {
        if ( buffer == null )
        {
            throw new EncoderException( I18n.err( I18n.ERR_148 ) );
        }

        try
        {
            buffer.put( ( byte ) KerberosConstants.ENC_KRB_PRIV_PART_TAG );
            buffer.put( TLV.getBytes( encKrbPrivPartLen ) );

            buffer.put( UniversalTag.SEQUENCE.getValue() );
            buffer.put( TLV.getBytes( encKrbPrivPartSeqLen ) );

            // user-data
            buffer.put( ( byte ) KerberosConstants.KRB_SAFE_BODY_USER_DATA_TAG );
            buffer.put( TLV.getBytes( userDataLen ) );
            BerValue.encode( buffer, userData );

            if ( timestamp != null )
            {
                // timestamp tag
                buffer.put( ( byte ) KerberosConstants.KRB_SAFE_BODY_TIMESTAMP_TAG );
                buffer.put( TLV.getBytes( timestampLen ) );

                // timestamp value
                buffer.put( ( byte ) UniversalTag.GENERALIZED_TIME.getValue() );
                buffer.put( ( byte ) 0x0F );
                buffer.put( timestamp.getBytes() );
            }

            if ( usec != null )
            {
                // usec
                buffer.put( ( byte ) KerberosConstants.KRB_SAFE_BODY_USEC_TAG );
                buffer.put( TLV.getBytes( usecLen ) );
                BerValue.encode( buffer, usec );
            }

            if ( seqNumber != null )
            {
                // seq-number
                buffer.put( ( byte ) KerberosConstants.KRB_SAFE_BODY_SEQ_NUMBER_TAG );
                buffer.put( TLV.getBytes( seqNumberLen ) );
                BerValue.encode( buffer, seqNumber );
            }

            // s-address
            buffer.put( ( byte ) KerberosConstants.KRB_SAFE_BODY_SENDER_ADDRESS_TAG );
            buffer.put( TLV.getBytes( senderAddressLen ) );
            senderAddress.encode( buffer );

            if ( recipientAddress != null )
            {
                // s-address
                buffer.put( ( byte ) KerberosConstants.KRB_SAFE_BODY_RECIPIENT_ADDRESS_TAG );
                buffer.put( TLV.getBytes( recipientAddressLen ) );
                recipientAddress.encode( buffer );
            }
        }
        catch ( BufferOverflowException boe )
        {
            log.error( I18n.err( I18n.ERR_735_CANNOT_ENCODE_KRBSAFEBODY, 1 + TLV.getNbBytes( encKrbPrivPartLen )
                + encKrbPrivPartLen, buffer.capacity() ) );
            throw new EncoderException( I18n.err( I18n.ERR_138 ) );
        }

        if ( IS_DEBUG )
        {
            log.debug( "EncKrbPrivPart encoding : {}", Strings.dumpBytes( buffer.array() ) );
View Full Code Here

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

        if ( valueLength != 0 )
        {
            buffer.put( getValue() );
View Full Code Here

                }
            }
        }
        catch ( BufferOverflowException boe )
        {
            throw new EncoderException( I18n.err( I18n.ERR_04005 ) );
        }

        return buffer;
    }
View Full Code Here

            return buffer;
        }

        if ( buffer == null )
        {
            throw new EncoderException( I18n.err( I18n.ERR_04023 ) );
        }

        if ( ( getResponse().getTimeBeforeExpiration() < 0 ) && ( getResponse().getGraceAuthNsRemaining() < 0 ) && (
            getResponse().getPasswordPolicyError() == null ) )
        {
View Full Code Here

                }
            }
        }
        catch ( BufferOverflowException boe )
        {
            throw new EncoderException( I18n.err( I18n.ERR_04005 ) );
        }

        return buffer;
    }
View Full Code Here

            buffer.put( TLV.getBytes( getExtendedRequestLength() ) );

            // The requestName, if any
            if ( getRequestNameBytes() == null )
            {
                throw new EncoderException( I18n.err( I18n.ERR_04043 ) );
            }

            buffer.put( ( byte ) LdapConstants.EXTENDED_REQUEST_NAME_TAG );
            buffer.put( TLV.getBytes( getRequestNameBytes().length ) );

            if ( getRequestNameBytes().length != 0 )
            {
                buffer.put( getRequestNameBytes() );
            }

            // The requestValue, if any
            if ( getRequestValue() != null )
            {
                buffer.put( ( byte ) LdapConstants.EXTENDED_REQUEST_VALUE_TAG );

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

                if ( getRequestValue().length != 0 )
                {
                    buffer.put( getRequestValue() );
                }
            }
        }
        catch ( BufferOverflowException boe )
        {
            throw new EncoderException( I18n.err( I18n.ERR_04005 ) );
        }

        return buffer;
    }
View Full Code Here

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

        switch ( getType() )
        {
            case NEW_COOKIE:
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.