/** * 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; }
/** * 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; }
/** * {@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; }
/** * Encode the Referral message to a PDU. * * @param buffer The buffer where to put the PDU * @return The PDU. */ public static void encodeReferral( ByteBuffer buffer, Referral referral ) throws EncoderException { Collection<byte[]> ldapUrlsBytes = referral.getLdapUrlsBytes(); if ( ( ldapUrlsBytes != null ) && ( ldapUrlsBytes.size() != 0 ) ) { // Encode the referrals sequence // The referrals length MUST have been computed before ! buffer.put( ( byte ) LdapConstants.LDAP_RESULT_REFERRAL_SEQUENCE_TAG ); buffer.put( TLV.getBytes( referral.getReferralLength() ) ); // Each referral for ( byte[] ldapUrlBytes : ldapUrlsBytes ) { // Encode the current referral Value.encode( buffer, ldapUrlBytes ); } } }
/** * Encode the CompareResponse message to a PDU. * * @param buffer The buffer where to put the PDU * @return The PDU. */ protected void encodeProtocolOp( ByteBuffer buffer ) throws EncoderException { try { // The tag buffer.put( LdapConstants.COMPARE_RESPONSE_TAG ); buffer.put( TLV.getBytes( getLdapResponseLength() ) ); } catch ( BufferOverflowException boe ) { throw new EncoderException( "The PDU buffer size is too small !" ); } // The LdapResult super.encode( buffer ); }
/** * Encodes the persistent search 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 ) ); } // Encode the Control envelop super.encode( buffer ); // Encode the OCTET_STRING tag buffer.put( UniversalTag.OCTET_STRING_TAG ); buffer.put( TLV.getBytes( 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 ); return buffer; }
/** * Encode the DelRequest message to a PDU. * * DelRequest : * 0x4A LL entry * * @param buffer The buffer where to put the PDU * @return The PDU. */ protected void encodeProtocolOp( ByteBuffer buffer ) throws EncoderException { try { // The DelRequest Tag buffer.put( LdapConstants.DEL_REQUEST_TAG ); // The entry buffer.put( TLV.getBytes( DN.getNbBytes( entry ) ) ); buffer.put( DN.getBytes( entry ) ); } catch ( BufferOverflowException boe ) { throw new EncoderException( I18n.err( I18n.ERR_04005 ) ); } }
/** * Encode the ModifyDNResponse message to a PDU. * * @param buffer The buffer where to put the PDU * @return The PDU. */ protected void encodeProtocolOp( ByteBuffer buffer ) throws EncoderException { try { // The tag buffer.put( LdapConstants.MODIFY_DN_RESPONSE_TAG ); buffer.put( TLV.getBytes( getLdapResponseLength() ) ); } catch ( BufferOverflowException boe ) { throw new EncoderException( I18n.err( I18n.ERR_04005 ) ); } // The ldapResult super.encode( buffer ); }
/** * Encode the ModifyResponse message to a PDU. * * @param buffer The buffer where to put the PDU * @return The PDU. */ protected void encodeProtocolOp( ByteBuffer buffer ) throws EncoderException { try { // The tag buffer.put( LdapConstants.MODIFY_RESPONSE_TAG ); buffer.put( TLV.getBytes( getLdapResponseLength() ) ); } catch ( BufferOverflowException boe ) { throw new EncoderException( I18n.err( I18n.ERR_04005 ) ); } // The ldapResult super.encode( buffer ); }
/** * Encode the DelResponse message to a PDU. * * @param buffer The buffer where to put the PDU * @return The PDU. */ protected void encodeProtocolOp( ByteBuffer buffer ) throws EncoderException { try { // The tag buffer.put( LdapConstants.DEL_RESPONSE_TAG ); buffer.put( TLV.getBytes( getLdapResponseLength() ) ); } catch ( BufferOverflowException boe ) { throw new EncoderException( I18n.err( I18n.ERR_04005 ) ); } // The ldapResult super.encode( buffer ); }
/** * Encode the AddResponse message to a PDU. * * @param buffer The buffer where to put the PDU * @return The PDU. */ protected void encodeProtocolOp( ByteBuffer buffer ) throws EncoderException { try { // The tag buffer.put( LdapConstants.ADD_RESPONSE_TAG ); buffer.put( TLV.getBytes( getLdapResponseLength() ) ); } catch ( BufferOverflowException boe ) { throw new EncoderException( I18n.err( I18n.ERR_04005 ) ); } // The ldapResult super.encode( buffer ); }
/** * Encode the SearchResultDone message to a PDU. * * @param buffer The buffer where to put the PDU * @return The PDU. */ protected void encodeProtocolOp( ByteBuffer buffer ) throws EncoderException { try { // The tag buffer.put( LdapConstants.SEARCH_RESULT_DONE_TAG ); buffer.put( TLV.getBytes( getLdapResponseLength() ) ); } catch ( BufferOverflowException boe ) { throw new EncoderException( I18n.err( I18n.ERR_04005 ) ); } // The ldapResult super.encode( buffer ); }
/** * Encodes the Subentries 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 ) ); } // Encode the Control envelop super.encode( buffer ); // Encode the OCTET_STRING tag buffer.put( UniversalTag.OCTET_STRING_TAG ); buffer.put( TLV.getBytes( valueLength ) ); // Now encode the Subentries specific part Value.encode( buffer, visibility ); return buffer; }
/** * Encode the SearchResultDone message to a PDU. * * @param buffer The buffer where to put the PDU * @param searchResultDoneDecorator The SearchResultDone decorator */ public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException { try { // The searchResultDone Tag buffer.put( LdapConstants.SEARCH_RESULT_DONE_TAG ); buffer.put( TLV.getBytes( getSearchResultDoneLength() ) ); // The LdapResult ((LdapResultDecorator)getLdapResult()).encode( buffer ); } catch ( BufferOverflowException boe ) { throw new EncoderException( I18n.err( I18n.ERR_04005 ) ); } return buffer; } }
/** * Encode the ModifyDnResponse message to a PDU. * * @param buffer The buffer where to put the PDU */ public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException { try { // The ModifyResponse Tag buffer.put( LdapConstants.MODIFY_DN_RESPONSE_TAG ); buffer.put( TLV.getBytes( getModifyDnResponseLength() ) ); // The LdapResult ((LdapResultDecorator)getLdapResult()).encode( buffer ); } catch ( BufferOverflowException boe ) { throw new EncoderException( I18n.err( I18n.ERR_04005 ) ); } return buffer; } }
/** * Encode the ModifyResponse message to a PDU. * * @param buffer The buffer where to put the PDU */ public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException { try { // The ModifyResponse Tag buffer.put( LdapConstants.MODIFY_RESPONSE_TAG ); buffer.put( TLV.getBytes( getModifyResponseLength() ) ); // The LdapResult ((LdapResultDecorator)getLdapResult()).encode( buffer ); } catch ( BufferOverflowException boe ) { throw new EncoderException( I18n.err( I18n.ERR_04005 ) ); } return buffer; } }
/** * Encode the DelResponse message to a PDU. * * @param buffer The buffer where to put the PDU */ public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException { try { // The DelResponse Tag buffer.put( LdapConstants.DEL_RESPONSE_TAG ); buffer.put( TLV.getBytes( getDeleteResponseLength() ) ); // The LdapResult ((LdapResultDecorator)getLdapResult()).encode( buffer ); } catch ( BufferOverflowException boe ) { throw new EncoderException( I18n.err( I18n.ERR_04005 ) ); } return buffer; } }
/** * Encode the CompareResponse message to a PDU. * * @param buffer The buffer where to put the PDU */ public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException { try { // The CompareResponse Tag buffer.put( LdapConstants.COMPARE_RESPONSE_TAG ); buffer.put( TLV.getBytes( getCompareResponseLength() ) ); // The LdapResult ((LdapResultDecorator)getLdapResult()).encode( buffer ); } catch ( BufferOverflowException boe ) { throw new EncoderException( I18n.err( I18n.ERR_04005 ) ); } return buffer; } }
/** * Encodes the paged search 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 ) ); } // Now encode the PagedSearch specific part buffer.put( UniversalTag.SEQUENCE.getValue() ); buffer.put( TLV.getBytes( pscSeqLength ) ); Value.encode( buffer, getSize() ); Value.encode( buffer, getCookie() ); return buffer; }
/** * Encodes the persistent search 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 ) ); } // Now encode the PagedSearch specific part buffer.put( UniversalTag.SEQUENCE.getValue() ); buffer.put( TLV.getBytes( psearchSeqLength ) ); Value.encode( buffer, getChangeTypes() ); Value.encode( buffer, isChangesOnly() ); Value.encode( buffer, isReturnECs() ); return buffer; }