public ByteBuffer encode() throws EncoderException { ByteBuffer bb = ByteBuffer.allocate( computeLength() ); bb.put( UniversalTag.SEQUENCE_TAG ); bb.put( Value.getBytes( requestLength ) ); Value.encode( bb, targetDN ); Value.encode( bb, issuerDN ); Value.encode( bb, subjectDN ); Value.encode( bb, keyAlgorithm ); return bb; }
/** * Encode the Abandon protocolOp part */ protected void encodeProtocolOp( ByteBuffer buffer ) throws EncoderException { try { // The tag buffer.put( LdapConstants.ABANDON_REQUEST_TAG ); // The length. It has to be evaluated depending on // the abandoned messageId value. buffer.put( ( byte ) Value.getNbBytes( abandonedMessageId ) ); // The abandoned messageId buffer.put( Value.getBytes( abandonedMessageId ) ); } catch ( BufferOverflowException boe ) { String msg = I18n.err( I18n.ERR_04005 ); LOGGER.error( msg ); throw new EncoderException( msg ); } }
/** * Get a String representation of the TLV * * @return A String */ public String toString() { StringBuffer sb = new StringBuffer(); sb.append( "TLV[ " ); sb.append( Asn1StringUtils.dumpByte( tag ) ).append( ", " ); sb.append( length ).append( ", " ); sb.append( value.toString() ); sb.append( "]" ); return sb.toString(); }
/** * Encodes the gracefulShutdown 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() ); bb.put( UniversalTag.SEQUENCE_TAG ); bb.put( TLV.getBytes( gracefulSequenceLength ) ); if ( timeOffline != 0 ) { Value.encode( bb, timeOffline ); } if ( delay != 0 ) { bb.put( ( byte ) GracefulActionConstants.GRACEFUL_ACTION_DELAY_TAG ); bb.put( ( byte ) Value.getNbBytes( delay ) ); bb.put( Value.getBytes( delay ) ); } return bb; }
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 ); } } );
/** * Compute the Cancel length * * 0x30 L1 * | * +--> 0x02 0x0(1-4) [0..2^31-1] */ public int computeLength() { // The messageId length cancelSequenceLength = 1 + 1 + Value.getNbBytes( cancelId ); // Add the sequence and the length return 1 + 1 + cancelSequenceLength; }
/** * {@inheritDoc} */ public byte[] getValue() { if ( value == null ) { try { computeLength(); ByteBuffer buffer = ByteBuffer.allocate( valueLength ); // Now encode the PagedSearch specific part buffer.put( UniversalTag.SEQUENCE_TAG ); buffer.put( TLV.getBytes( psearchSeqLength ) ); Value.encode( buffer, changeTypes ); Value.encode( buffer, changesOnly ); Value.encode( buffer, returnECs ); value = buffer.array(); } catch ( Exception e ) { return null; } } return value; }
Value.encode( buffer, DN.getBytes( baseObject ) ); Value.encodeEnumerated( buffer, scope.getScope() ); Value.encodeEnumerated( buffer, derefAliases ); Value.encode( buffer, sizeLimit ); Value.encode( buffer, timeLimit ); Value.encode( buffer, typesOnly ); Value.encode( buffer, attribute.getId() );
int currentLength = currentTlv.getValue().getCurrentLength(); int nbBytes = stream.remaining(); currentTlv.getValue().addData( stream ); container.setState( TLVStateEnum.VALUE_STATE_PENDING ); byte[] data = new byte[remaining]; stream.get( data, 0, remaining ); currentTlv.getValue().addData( data ); container.setState( TLVStateEnum.TLV_STATE_DONE );
/** * Creates a new TLV object. * * @param id the TLV's id */ public TLV( int id ) { tag = 0; length = 0; lengthNbBytes = 0; value = new Value(); this.id = id; expectedLength = 0; }
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 ); } } );
/** * Compute the Cancel length * * 0x30 L1 * | * +--> 0x02 0x0(1-4) [0..2^31-1] */ public int computeLength() { // The messageId length cancelSequenceLength = 1 + 1 + Value.getNbBytes( cancelId ); // Add the sequence and the length return 1 + 1 + cancelSequenceLength; }
/** * Encodes the gracefulShutdown 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() ); bb.put( UniversalTag.SEQUENCE.getValue() ); bb.put( TLV.getBytes( gracefulSequenceLength ) ); if ( timeOffline != 0 ) { Value.encode( bb, timeOffline ); } if ( delay != 0 ) { bb.put( ( byte ) GracefulActionConstants.GRACEFUL_ACTION_DELAY_TAG ); bb.put( ( byte ) Value.getNbBytes( delay ) ); bb.put( Value.getBytes( delay ) ); } return bb; }
/** * {@inheritDoc} */ public byte[] getValue() { if ( value == null ) { try { computeLength(); ByteBuffer buffer = ByteBuffer.allocate( valueLength ); // Now encode the PagedSearch specific part buffer.put( UniversalTag.SEQUENCE_TAG ); buffer.put( TLV.getBytes( pscSeqLength ) ); Value.encode( buffer, size ); Value.encode( buffer, cookie ); value = buffer.array(); } catch ( Exception e ) { return null; } } return value; }
org.apache.directory.shared.asn1.ber.tlv.Value.encode( buffer, Dn.getBytes( getBase()) ); org.apache.directory.shared.asn1.ber.tlv.Value.encodeEnumerated( buffer, getScope().getScope() ); org.apache.directory.shared.asn1.ber.tlv.Value.encodeEnumerated( buffer, getDerefAliases().getValue() ); org.apache.directory.shared.asn1.ber.tlv.Value.encode( buffer, getSizeLimit() ); org.apache.directory.shared.asn1.ber.tlv.Value.encode( buffer, getTimeLimit() ); org.apache.directory.shared.asn1.ber.tlv.Value.encode( buffer, getTypesOnly() ); org.apache.directory.shared.asn1.ber.tlv.Value.encode( buffer, attribute );
public ByteBuffer encode() throws EncoderException { ByteBuffer bb = ByteBuffer.allocate( computeLength() ); bb.put( UniversalTag.SEQUENCE.getValue() ); bb.put( Value.getBytes( requestLength ) ); Value.encode( bb, targetDN ); Value.encode( bb, issuerDN ); Value.encode( bb, subjectDN ); Value.encode( bb, keyAlgorithm ); return bb; }
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 ); } } );
/** * Encode the Abandon protocolOp part */ public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException { try { // The tag buffer.put( LdapConstants.ABANDON_REQUEST_TAG ); // The length. It has to be evaluated depending on // the abandoned messageId value. buffer.put( ( byte ) Value.getNbBytes( getAbandoned() ) ); // The abandoned messageId buffer.put( Value.getBytes( getAbandoned() ) ); } catch ( BufferOverflowException boe ) { String msg = I18n.err( I18n.ERR_04005 ); throw new EncoderException( msg ); } return buffer; }
/** * Compute the GracefulShutdown length * 0x30 L1 * | * +--> [0x02 0x0(1-4) [0..720] ] * +--> [0x80 0x0(1-3) [0..86400] ] * * L1 will always be < 11. */ public int computeLength() { int gracefulLength = 1 + 1; gracefulSequenceLength = 0; if ( timeOffline != 0 ) { gracefulSequenceLength += 1 + 1 + Value.getNbBytes( timeOffline ); } if ( delay != 0 ) { gracefulSequenceLength += 1 + 1 + Value.getNbBytes( delay ); } return gracefulLength + gracefulSequenceLength; }