/** * 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 ); } }
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; }
/** * 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 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; }
/** * 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; }
buffer.put( Value.getBytes( syncStateType.getValue() ) );
buffer.put( Value.getBytes( changeType.getValue() ) );
buffer.put( Value.getBytes( mode.getValue() ) );
/** * 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; }
bb.put( Value.getBytes( delay ) );
/** * Encode an integer value * * @param buffer The PDU in which the value will be put * @param value The integer to be encoded * @throws EncoderException if the PDU in which the value should be encoded is * two small */ public static void encode( ByteBuffer buffer, int value ) throws EncoderException { if ( buffer == null ) { throw new EncoderException( I18n.err( I18n.ERR_00003 ) ); } try { buffer.put( UniversalTag.INTEGER_TAG ); buffer.put( ( byte ) getNbBytes( value ) ); buffer.put( getBytes( value ) ); } catch ( BufferOverflowException boe ) { throw new EncoderException( I18n.err( I18n.ERR_00004 ) ); } return; }
/** * Encode a long value * * @param buffer The PDU in which the value will be put * @param value The long to be encoded * @throws EncoderException if the PDU in which the value should be encoded is * two small */ public static void encode( ByteBuffer buffer, long value ) throws EncoderException { if ( buffer == null ) { throw new EncoderException( I18n.err( I18n.ERR_00003 ) ); } try { buffer.put( UniversalTag.INTEGER_TAG ); buffer.put( ( byte ) getNbBytes( value ) ); buffer.put( getBytes( value ) ); } catch ( BufferOverflowException boe ) { throw new EncoderException( I18n.err( I18n.ERR_00004 ) ); } return; }
bb.put( Value.getBytes( delay ) );
buffer.put( Value.getBytes( mode.getValue() ) );
/** * Encode an integer value * * @param buffer The PDU in which the value will be put * @param tag The tag if it's not an UNIVERSAL one * @param value The integer to be encoded * @throws EncoderException if the PDU in which the value should be encoded is * two small */ public static void encode( ByteBuffer buffer, byte tag, int value ) throws EncoderException { if ( buffer == null ) { throw new EncoderException( I18n.err( I18n.ERR_00003 ) ); } try { buffer.put( tag ); buffer.put( ( byte ) getNbBytes( value ) ); buffer.put( getBytes( value ) ); } catch ( BufferOverflowException boe ) { throw new EncoderException( I18n.err( I18n.ERR_00004 ) ); } return; }
/** * Encode an enumerated value * * @param buffer The PDU in which the value will be put * @param value The integer to be encoded * @throws EncoderException if the PDU in which the value should be encoded is * two small */ public static void encodeEnumerated( ByteBuffer buffer, int value ) throws EncoderException { if ( buffer == null ) { throw new EncoderException( I18n.err( I18n.ERR_00003 ) ); } try { buffer.put( UniversalTag.ENUMERATED_TAG ); buffer.put( TLV.getBytes( getNbBytes( value ) ) ); buffer.put( getBytes( value ) ); } catch ( BufferOverflowException boe ) { throw new EncoderException( I18n.err( I18n.ERR_00004 ) ); } return; }
buffer.put( Value.getBytes( getSyncStateType().getValue() ) );
buffer.put( Value.getBytes( getMode().getValue() ) );
/** * Encode the SyncStateValue control * * @param buffer The encoded sink * @return A ByteBuffer that contains the encoded PDU * @throws EncoderException If anything goes wrong. */ @Override public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException { if ( buffer == null ) { throw new EncoderException( I18n.err( I18n.ERR_04023 ) ); } // Encode the SEQ buffer.put( UniversalTag.SEQUENCE.getValue() ); buffer.put( TLV.getBytes( syncStateSeqLength ) ); // The mode buffer.put( UniversalTag.ENUMERATED.getValue() ); buffer.put( ( byte ) 0x01 ); buffer.put( Value.getBytes( getSyncStateType().getValue() ) ); // the entryUUID Value.encode( buffer, getEntryUUID() ); // The cookie if ( getCookie() != null ) { Value.encode( buffer, getCookie() ); } return buffer; }
/** * Encodes the entry change control. * * @param buffer The encoded sink * @return A ByteBuffer that contains the encoded PDU * @throws EncoderException If anything goes wrong. */ public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException { if ( buffer == null ) { throw new EncoderException( I18n.err( I18n.ERR_04023 ) ); } buffer.put( UniversalTag.SEQUENCE.getValue() ); buffer.put( TLV.getBytes( eccSeqLength ) ); buffer.put( UniversalTag.ENUMERATED.getValue() ); buffer.put( ( byte ) 1 ); buffer.put( Value.getBytes( getChangeType().getValue() ) ); if ( getPreviousDn() != null ) { Value.encode( buffer, previousDnBytes ); } if ( getChangeNumber() != UNDEFINED_CHANGE_NUMBER ) { Value.encode( buffer, getChangeNumber() ); } return buffer; }