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 ETypeInfoEntry SEQ Tag
            buffer.put( UniversalTag.SEQUENCE.getValue() );
            buffer.put( TLV.getBytes( etypeInfoLength ) );

            // The ETypeInfoEntry list, if it's not empty
            if ( ( etypeInfoEntries != null ) && ( etypeInfoEntries.size() != 0 ) )
            {
                for ( ETypeInfoEntry infoEntry : etypeInfoEntries )
                {
                    infoEntry.encode( buffer );
                }
            }
        }
        catch ( BufferOverflowException boe )
        {
            LOG.error( I18n.err( I18n.ERR_144, 1 + TLV.getNbBytes( etypeInfoLength )
                + etypeInfoLength, buffer.capacity() ) );
            throw new EncoderException( I18n.err( I18n.ERR_138 ) );
        }

        if ( IS_DEBUG )
        {
            LOG.debug( "ETYPE-INFO 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_148 ) );
        }

        try
        {
            // The ETYPE-INFO2-ENTRY SEQ Tag
            buffer.put( UniversalTag.SEQUENCE.getValue() );
            buffer.put( TLV.getBytes( etypeInfo2EntrySeqLength ) );

            // The etype, first the tag, then the value
            buffer.put( ( byte ) KerberosConstants.ETYPE_INFO2_ENTRY_ETYPE_TAG );
            buffer.put( TLV.getBytes( etypeTagLength ) );
            BerValue.encode( buffer, etype.getValue() );

            // The salt, first the tag, then the value, if salt is not null
            if ( salt != null )
            {
                // The tag
                buffer.put( ( byte ) KerberosConstants.ETYPE_INFO2_ENTRY_SALT_TAG );
                buffer.put( TLV.getBytes( saltTagLength ) );

                // The value
                buffer.put( UniversalTag.GENERAL_STRING.getValue() );
                buffer.put( TLV.getBytes( saltBytes.length ) );
                buffer.put( saltBytes );
            }

            // The s2kparams, first the tag, then the value, if s2kparams is not null
            if ( s2kparams != null )
            {
                buffer.put( ( byte ) KerberosConstants.ETYPE_INFO2_ENTRY_S2KPARAMS_TAG );
                buffer.put( TLV.getBytes( saltTagLength ) );
                BerValue.encode( buffer, s2kparams );
            }
        }
        catch ( BufferOverflowException boe )
        {
            LOG.error( I18n.err( I18n.ERR_145, 1 + TLV.getNbBytes( etypeInfo2EntrySeqLength )
                + etypeInfo2EntrySeqLength, buffer.capacity() ) );
            throw new EncoderException( I18n.err( I18n.ERR_138 ) );
        }

        if ( IS_DEBUG )
        {
            LOG.debug( "ETYPE-INFO2-ENTRY 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 ) );
        }

        // The KDC-REQ-BODY SEQ Tag
        buffer.put( UniversalTag.SEQUENCE.getValue() );
        buffer.put( TLV.getBytes( kdcReqBodySeqLength ) );
View Full Code Here

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

        try
        {
            // EncTicketPart application tag and length
            buffer.put( ( byte ) KerberosConstants.ENC_TICKET_PART_TAG );
            buffer.put( TLV.getBytes( encTikcetPartLen ) );

            // EncTicketPart sequence tag and length
            buffer.put( UniversalTag.SEQUENCE.getValue() );
            buffer.put( TLV.getBytes( encTikcetPartSeqLen ) );

            // flags tag and int value
            buffer.put( ( byte ) KerberosConstants.ENC_TICKET_PART_FLAGS_TAG );
            buffer.put( TLV.getBytes( flagsLen ) );
            BerValue.encode( buffer, flags );

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

            // crealm tag and value
            buffer.put( ( byte ) KerberosConstants.ENC_TICKET_PART_CREALM_TAG );
            buffer.put( TLV.getBytes( cRealmLen ) );
            buffer.put( UniversalTag.GENERAL_STRING.getValue() );
            buffer.put( TLV.getBytes( cRealmBytes.length ) );
            buffer.put( cRealmBytes );

            // cname tag and value
            buffer.put( ( byte ) KerberosConstants.ENC_TICKET_PART_CNAME_TAG );
            buffer.put( TLV.getBytes( cNameLen ) );
            cName.encode( buffer );

            // transited tag and value
            buffer.put( ( byte ) KerberosConstants.ENC_TICKET_PART_TRANSITED_TAG );
            buffer.put( TLV.getBytes( transitedLen ) );
            transited.encode( buffer );

            // authtime tag and value
            buffer.put( ( byte ) KerberosConstants.ENC_TICKET_PART_AUTHTIME_TAG );
            buffer.put( TLV.getBytes( authTimeLen ) );
            buffer.put( UniversalTag.GENERALIZED_TIME.getValue() );
            buffer.put( ( byte ) 0x0F );
            buffer.put( authTimeBytes );

            if ( startTime != null )
            {
                // strattime tag and value
                buffer.put( ( byte ) KerberosConstants.ENC_TICKET_PART_STARTTIME_TAG );
                buffer.put( TLV.getBytes( startTimeLen ) );
                buffer.put( UniversalTag.GENERALIZED_TIME.getValue() );
                buffer.put( ( byte ) 0x0F );
                buffer.put( startTimeBytes );
            }

            // endtime tag and value
            buffer.put( ( byte ) KerberosConstants.ENC_TICKET_PART_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.ENC_TICKET_PART_RENEWTILL_TAG );
                buffer.put( TLV.getBytes( renewtillLen ) );
                buffer.put( UniversalTag.GENERALIZED_TIME.getValue() );
                buffer.put( ( byte ) 0x0F );
                buffer.put( renewtillBytes );
            }

            if ( clientAddresses != null )
            {
                // caddr tag and value
                buffer.put( ( byte ) KerberosConstants.ENC_TICKET_PART_CADDR_TAG );
                buffer.put( TLV.getBytes( clientAddressesLen ) );
                clientAddresses.encode( buffer );
            }

            if ( authorizationData != null )
            {
                // authorization-data tag and value
                buffer.put( ( byte ) KerberosConstants.ENC_TICKET_PART_AUTHORIZATION_DATA_TAG );
                buffer.put( TLV.getBytes( authzDataLen ) );
                authorizationData.encode( buffer );
            }
        }
        catch ( BufferOverflowException boe )
        {
            log.error( I18n.err( I18n.ERR_742_CANNOT_ENCODE_ENC_TICKET_PART, 1 + TLV.getNbBytes( encTikcetPartLen )
                + encTikcetPartLen, buffer.capacity() ) );
            throw new EncoderException( I18n.err( I18n.ERR_138 ) );
        }

        if ( IS_DEBUG )
        {
            log.debug( "EncTicketPart 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_148 ) );
        }

        try
        {
            // The ETypeInfo2Entry SEQ Tag
            buffer.put( UniversalTag.SEQUENCE.getValue() );
            buffer.put( TLV.getBytes( etypeInfo2Length ) );

            // The ETypeInfo2Entry list, if it's not empty
            if ( ( etypeInfo2Entries != null ) && ( etypeInfo2Entries.size() != 0 ) )
            {
                for ( ETypeInfo2Entry info2Entry : etypeInfo2Entries )
                {
                    info2Entry.encode( buffer );
                }
            }
        }
        catch ( BufferOverflowException boe )
        {
            LOG.error( I18n.err( I18n.ERR_144, 1 + TLV.getNbBytes( etypeInfo2Length )
                + etypeInfo2Length, buffer.capacity() ) );
            throw new EncoderException( I18n.err( I18n.ERR_138 ) );
        }

        if ( IS_DEBUG )
        {
            LOG.debug( "ETYPE-INFO 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_148 ) );
        }

        try
        {
            // The HostAddress SEQ Tag
            buffer.put( UniversalTag.SEQUENCE.getValue() );
            buffer.put( TLV.getBytes( hostAddressLength ) );

            // The addr-type, first the tag, then the value
            buffer.put( ( byte ) 0xA0 );
            buffer.put( TLV.getBytes( addrTypeLength ) );
            BerValue.encode( buffer, addrType.getValue() );

            // The address, first the tag, then the value
            buffer.put( ( byte ) 0xA1 );
            buffer.put( TLV.getBytes( addressLength ) );
            BerValue.encode( buffer, address );
        }
        catch ( BufferOverflowException boe )
        {
            LOG.error( I18n.err( I18n.ERR_143, 1 + TLV.getNbBytes( hostAddressLength )
                + hostAddressLength, buffer.capacity() ) );
            throw new EncoderException( I18n.err( I18n.ERR_138 ) );
        }

        if ( IS_DEBUG )
        {
            LOG.debug( "Checksum 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_148 ) );
        }

        try
        {
            // The METHOD-DATA SEQ Tag
            buffer.put( UniversalTag.SEQUENCE.getValue() );
            buffer.put( TLV.getBytes( methodDataLength ) );

            // The PA-DATA list, if it's not empty
            if ( ( paDatas != null ) && ( paDatas.size() != 0 ) )
            {
                for ( PaData paData : paDatas )
                {
                    paData.encode( buffer );
                }
            }
        }
        catch ( BufferOverflowException boe )
        {
            LOG.error( I18n.err( I18n.ERR_144, 1 + TLV.getNbBytes( methodDataLength )
                + methodDataLength, buffer.capacity() ) );
            throw new EncoderException( I18n.err( I18n.ERR_138 ) );
        }

        if ( IS_DEBUG )
        {
            LOG.debug( "METHOD-DATA 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 AD-KDCIssued SEQ Tag
            buffer.put( UniversalTag.SEQUENCE.getValue() );
            buffer.put( TLV.getBytes( adKdcIssuedSeqLength ) );

            // the ad-checksum
            buffer.put( ( byte ) KerberosConstants.AD_KDC_ISSUED_AD_CHECKSUM_TAG );
            buffer.put( ( byte ) adCheksumTagLength );
            adChecksum.encode( buffer );

            // the i-realm, if any
            if ( irealm != null )
            {
                buffer.put( ( byte ) KerberosConstants.AD_KDC_ISSUED_I_REALM_TAG );
                buffer.put( ( byte ) irealmTagLength );
                buffer.put( UniversalTag.GENERAL_STRING.getValue() );
                buffer.put( ( byte ) irealmBytes.length );
                buffer.put( irealmBytes );
            }

            // the i-sname, if any
            if ( isname != null )
            {
                buffer.put( ( byte ) KerberosConstants.AD_KDC_ISSUED_I_SNAME_TAG );
                buffer.put( ( byte ) isnameTagLength );
                isname.encode( buffer );
            }

            // the elements
            buffer.put( ( byte ) KerberosConstants.AD_KDC_ISSUED_ELEMENTS_TAG );
            buffer.put( ( byte ) elementsTagLength );
            elements.encode( buffer );
        }
        catch ( BufferOverflowException boe )
        {
            LOG.error( I18n.err( I18n.ERR_139, 1 + TLV.getNbBytes( adKdcIssuedSeqLength )
                + adKdcIssuedSeqLength, buffer.capacity() ) );
            throw new EncoderException( I18n.err( I18n.ERR_138 ) );
        }

        if ( IS_DEBUG )
        {
            LOG.debug( "AD-KDCIssued 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_148 ) );
        }

        try
        {
            // The PA-ENC-TS-ENC SEQ Tag
            buffer.put( UniversalTag.SEQUENCE.getValue() );
            buffer.put( TLV.getBytes( paEncTsEncLength ) );

            // The patimestamp, first the tag, then the value
            buffer.put( ( byte ) KerberosConstants.PA_ENC_TS_ENC_PA_TIMESTAMP_TAG );
            buffer.put( ( byte ) 0x11 );

            buffer.put( ( byte ) UniversalTag.GENERALIZED_TIME.getValue() );
            buffer.put( ( byte ) 0x0F );
            buffer.put( patimestamp.getBytes() );

            // The pausec, first the tag, then the value, if any
            if ( pausec != null )
            {
                buffer.put( ( byte ) KerberosConstants.PA_ENC_TS_ENC_PA_USEC_TAG );
                buffer.put( TLV.getBytes( paUsecLength ) );
                BerValue.encode( buffer, pausec );
            }
        }
        catch ( BufferOverflowException boe )
        {
            log.error( I18n.err( I18n.ERR_140, 1 + TLV.getNbBytes( paEncTsEncLength ) + paEncTsEncLength,
                buffer.capacity() ) );
            throw new EncoderException( I18n.err( I18n.ERR_138 ) );
        }

        if ( IS_DEBUG )
        {
            log.debug( "Checksum 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_148 ) );
        }

        try
        {
            // The PreAuthenticationData SEQ Tag
            buffer.put( UniversalTag.SEQUENCE.getValue() );
            buffer.put( TLV.getBytes( preAuthenticationDataSeqLength ) );

            // The PaDataType, first the tag, then the value
            buffer.put( ( byte ) KerberosConstants.PADATA_TYPE_TAG );
            buffer.put( TLV.getBytes( paDataTypeTagLength ) );
            BerValue.encode( buffer, paDataType.getValue() );

            // The PaDataValue, first the tag, then the value
            buffer.put( ( byte ) KerberosConstants.PADATA_VALUE_TAG );
            buffer.put( TLV.getBytes( paDataValueTagLength ) );
            BerValue.encode( buffer, paDataValue );
        }
        catch ( BufferOverflowException boe )
        {
            log.error( I18n.err( I18n.ERR_145, 1 + TLV.getNbBytes( preAuthenticationDataSeqLength )
                + preAuthenticationDataSeqLength, buffer.capacity() ) );
            throw new EncoderException( I18n.err( I18n.ERR_138 ) );
        }

        if ( IS_DEBUG )
        {
            log.debug( "PreAuthenticationData encoding : {}", Strings.dumpBytes( buffer.array() ) );
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.