/** * Encodes the cancel extended operation. * * @return A ByteBuffer that contains the encoded PDU * @throws EncoderException If anything goes wrong. */ public ByteBuffer encode() throws EncoderException { // Allocate the bytes buffer. ByteBuffer bb = ByteBuffer.allocate( computeLength() ); // The sequence bb.put( UniversalTag.SEQUENCE_TAG ); bb.put( TLV.getBytes( cancelSequenceLength ) ); // The messageId Value.encode( bb, cancelId ); return bb; }
TLV localParent = tlv.getParent(); Filter localFilter = terminalFilter; while ( ( localParent != null ) && ( localParent.getExpectedLength() == 0 ) ) if ( localParent.getId() != localFilter.getParent().getTlvId() ) localParent = localParent.getParent(); localParent = localParent.getParent();
public void action( LdapMessageContainer<MessageDecorator<? extends Message>> container ) { TLV tlv = container.getCurrentTLV(); // If the length is null, we store an empty value if ( tlv.getLength() == 0 ) { LOG.debug( "No vals for this attribute" ); } // We can have an END transition container.setGrammarEndAllowed( true ); LOG.debug( "Some vals are to be decoded" ); } } );
/** * Check if the TLV tree is fully decoded * * @param container The container * @return <code>true</code> if the TLV has been decoded */ private boolean isTLVDecoded( IAsn1Container container ) { TLV current = container.getCurrentTLV(); TLV parent = current.getParent(); while ( parent != null ) { if ( parent.getExpectedLength() != 0 ) { return false; } parent = parent.getParent(); } Value value = current.getValue(); if ( ( value != null ) && ( value.getData() != null ) ) { return ( current.getExpectedLength() == value.getData().length ); } else { return current.getExpectedLength() == 0; } }
/** * A debug function used to dump the expected length stack. * * @param tlv The current TLV. * @return A string which represent the expected length stack. */ private String getParentLength( TLV tlv ) { StringBuffer buffer = new StringBuffer(); buffer.append( "TLV expected length stack : " ); while ( true ) { if ( tlv == null ) { buffer.append( " - null" ); break; } else { buffer.append( " - " ).append( tlv.getExpectedLength() ); } tlv = tlv.getParent(); } return buffer.toString(); }
/** * Dump the current TLV tree * * @param container The container */ private void dumpTLVTree( IAsn1Container container ) { StringBuffer sb = new StringBuffer(); TLV current = container.getCurrentTLV(); sb.append( "TLV" ).append( Asn1StringUtils.dumpByte( current.getTag() ) ).append( "(" ) .append( current.getExpectedLength() ).append( ")" ); current = current.getParent(); while ( current != null ) { sb.append( "-TLV" ).append( Asn1StringUtils.dumpByte( current.getTag() ) ).append( "(" ) .append( current.getExpectedLength() ).append( ")" ); current = current.getParent(); } if ( IS_DEBUG ) { LOG.debug( "TLV Tree : {}", sb.toString() ); } }
int length = tlv.getLength(); tlv.setExpectedLength( length ); container.setParentTLV( tlv ); int expectedLength = parentTLV.getExpectedLength(); int currentLength = tlv.getSize(); parentTLV.setExpectedLength( 0 ); if ( tlv.isConstructed() ) if ( parentTLV.getExpectedLength() != 0 ) parentTLV = parentTLV.getParent(); tlv.setParent( parentTLV ); tlv.setExpectedLength( length ); tlv.setExpectedLength( length ); if ( parentTLV.getExpectedLength() != 0 ) parentTLV = parentTLV.getParent(); parentTLV.setExpectedLength( expectedLength - currentLength ); tlv.setExpectedLength( length ); if ( tlv.isConstructed() )
/** * {@inheritDoc} */ public int computeLength( int valueLength ) { // The OID int oidLengh = StringTools.getBytesUtf8( oid ).length; controlLength = 1 + TLV.getNbBytes( oidLengh ) + oidLengh; // The criticality, only if true if ( criticality ) { controlLength += 1 + 1 + 1; // Always 3 for a boolean } this.valueLength = valueLength; if ( valueLength != 0 ) { controlLength += 1 + TLV.getNbBytes( valueLength ) + valueLength; } return 1 + TLV.getNbBytes( controlLength ) + controlLength; }
public void action( Asn1Container container ) throws DecoderException { CertGenerationContainer certGenContainer = ( CertGenerationContainer ) container; Value value = certGenContainer.getCurrentTLV().getValue(); String keyAlgorithm = Strings.utf8ToString(value.getData()); if ( IS_DEBUG ) { LOG.debug( "key algorithm = " + keyAlgorithm ); } if ( keyAlgorithm != null && ( keyAlgorithm.trim().length() > 0 ) ) { certGenContainer.getCertGenerationObject().setKeyAlgorithm( keyAlgorithm ); } certGenContainer.setGrammarEndAllowed( true ); } } );
public void action( IAsn1Container container ) throws DecoderException { PagedResultsControlContainer pagedSearchContainer = ( PagedResultsControlContainer ) container; Value value = pagedSearchContainer.getCurrentTLV().getValue(); if ( pagedSearchContainer.getCurrentTLV().getLength() == 0 ) { pagedSearchContainer.getPagedSearchControl().setCookie( StringTools.EMPTY_BYTES ); } else { pagedSearchContainer.getPagedSearchControl().setCookie( value.getData() ); } // We can have an END transition pagedSearchContainer.grammarEndAllowed( true ); } } );
int length = tlv.getLength(); while ( tlv.getLengthBytesRead() < tlv.getLengthNbBytes() ) tlv.incLengthBytesRead(); length = ( length << 8 ) | ( octet & 0x00FF ); tlv.setLength( length ); if ( tlv.getLengthBytesRead() < tlv.getLengthNbBytes() ) tlv.setLength( length ); container.setState( TLVStateEnum.LENGTH_STATE_END );
/** * @return The TLV Id */ public int getTlvId() { return tlv.getId(); }
/** * Compute the Simple authentication length * * Simple authentication : 0x80 L1 simple * * L1 = Length(simple) * Length(Simple authentication) = Length(0x80) + Length(L1) + Length(simple) */ public int computeLength() { int length = 1; length += TLV.getNbBytes( simple.length ) + simple.length; if ( IS_DEBUG ) { log.debug( "Simple Authentication length : {}", Integer.valueOf( length ) ); } return length; }
public void action( IAsn1Container container ) throws DecoderException { CertGenerationContainer CertGenContainer = ( CertGenerationContainer ) container; Value value = CertGenContainer.getCurrentTLV().getValue(); String keyAlgorithm = StringTools.utf8ToString( value.getData() ); if ( IS_DEBUG ) { LOG.debug( "key algorithm = " + keyAlgorithm ); } if ( keyAlgorithm != null && ( keyAlgorithm.trim().length() > 0 ) ) { CertGenContainer.getCertGenerationObject().setKeyAlgorithm( keyAlgorithm ); } CertGenContainer.grammarEndAllowed( true ); } } );
public void action( LdapMessageContainer<SearchRequestDecorator> container ) throws DecoderException { SearchRequestDecorator searchRequestDecorator = container.getMessage(); TLV tlv = container.getCurrentTLV(); // Store the value. SubstringFilter substringFilter = ( SubstringFilter ) searchRequestDecorator.getTerminalFilter(); if ( tlv.getLength() == 0 ) { String msg = I18n.err( I18n.ERR_04108 ); LOG.error( msg ); throw new DecoderException( msg ); } substringFilter.setInitialSubstrings( Strings.utf8ToString(tlv.getValue().getData()) ); // We now have to get back to the nearest filter which is // not terminal. searchRequestDecorator.unstackFilters( container ); } } );
public void action( LdapMessageContainer<SearchRequestDecorator> container ) { // Now, we can allocate the SearchRequest Object TLV tlv = container.getCurrentTLV(); SearchRequestDecorator searchRequest = new SearchRequestDecorator( container.getLdapCodecService(), new SearchRequestImpl( container.getMessageId() ) ); searchRequest.setTlvId( tlv.getId()); container.setMessage( searchRequest ); LOG.debug( "Search Request" ); } } );
/** * Encodes the cancel extended operation. * * @return A ByteBuffer that contains the encoded PDU * @throws org.apache.directory.shared.asn1.EncoderException If anything goes wrong. */ public ByteBuffer encode() throws EncoderException { // Allocate the bytes buffer. ByteBuffer bb = ByteBuffer.allocate( computeLength() ); // The sequence bb.put( UniversalTag.SEQUENCE.getValue() ); bb.put( TLV.getBytes( cancelSequenceLength ) ); // The messageId Value.encode( bb, cancelId ); return bb; }
/** * Compute the NotFilter length * NotFilter : * 0xA2 L1 super.computeLength() * * Length(NotFilter) = Length(0xA2) + Length(super.computeLength()) + * super.computeLength() */ public int computeLength() { filtersLength = super.computeLength(); return 1 + TLV.getNbBytes( filtersLength ) + filtersLength; }
public void action( SyncStateValueContainer container ) throws DecoderException { Value value = container.getCurrentTLV().getValue(); byte[] cookie = value.getData(); if ( IS_DEBUG ) { LOG.debug( "cookie = {}", cookie ); } container.getSyncStateValueControl().setCookie( cookie ); // terminal state container.setGrammarEndAllowed( true ); } } );