Class LDAPMessage

  • All Implemented Interfaces:
    ProtocolElement

    public class LDAPMessage
    extends Object
    implements ProtocolElement
    This class defines the data structures and methods to use when interacting with an LDAP message, which is the basic envelope used to hold LDAP requests and responses.
    • Constructor Detail

      • LDAPMessage

        public LDAPMessage​(int messageID,
                           ProtocolOp protocolOp)
        Creates a new LDAP message with the provided message ID and protocol op but no controls.
        Parameters:
        messageID - The message ID for this LDAP message.
        protocolOp - The protocol op for this LDAP message.
      • LDAPMessage

        public LDAPMessage​(int messageID,
                           ProtocolOp protocolOp,
                           List<Control> controls)
        Creates a new LDAP message with the provided message ID, protocol op, and set of controls.
        Parameters:
        messageID - The message ID for this LDAP message.
        protocolOp - The protocol op for this LDAP message.
        controls - The set of controls for this LDAP message.
    • Method Detail

      • getMessageID

        public int getMessageID()
        Retrieves the message ID for this LDAP message.
        Returns:
        The message ID for this LDAP message.
      • getProtocolOp

        public ProtocolOp getProtocolOp()
        Retrieves the protocol op for this LDAP message.
        Returns:
        The protocol op for this LDAP message.
      • getProtocolOpType

        public byte getProtocolOpType()
        Retrieves the protocol op type for this LDAP message.
        Returns:
        The protocol op type for this LDAP message.
      • getProtocolOpName

        public String getProtocolOpName()
        Retrieves the protocol op name for this LDAP message.
        Returns:
        The protocol op name for this LDAP message.
      • getAbandonRequestProtocolOp

        public AbandonRequestProtocolOp getAbandonRequestProtocolOp()
                                                             throws ClassCastException
        Retrieves the protocol op for this LDAP message as an abandon request protocol op.
        Returns:
        The protocol op for this LDAP message as an abandon request protocol op.
        Throws:
        ClassCastException - If the protocol op is not an abandon request protocol op.
      • getAddRequestProtocolOp

        public AddRequestProtocolOp getAddRequestProtocolOp()
                                                     throws ClassCastException
        Retrieves the protocol op for this LDAP message as an add request protocol op.
        Returns:
        The protocol op for this LDAP message as an add request protocol op.
        Throws:
        ClassCastException - If the protocol op is not an add request protocol op.
      • getAddResponseProtocolOp

        public AddResponseProtocolOp getAddResponseProtocolOp()
                                                       throws ClassCastException
        Retrieves the protocol op for this LDAP message as an add response protocol op.
        Returns:
        The protocol op for this LDAP message as an add response protocol op.
        Throws:
        ClassCastException - If the protocol op is not an add response protocol op.
      • getBindRequestProtocolOp

        public BindRequestProtocolOp getBindRequestProtocolOp()
                                                       throws ClassCastException
        Retrieves the protocol op for this LDAP message as a bind request protocol op.
        Returns:
        The protocol op for this LDAP message as a bind request protocol op.
        Throws:
        ClassCastException - If the protocol op is not a bind request protocol op.
      • getBindResponseProtocolOp

        public BindResponseProtocolOp getBindResponseProtocolOp()
                                                         throws ClassCastException
        Retrieves the protocol op for this LDAP message as a bind response protocol op.
        Returns:
        The protocol op for this LDAP message as a bind response protocol op.
        Throws:
        ClassCastException - If the protocol op is not a bind response protocol op.
      • getCompareRequestProtocolOp

        public CompareRequestProtocolOp getCompareRequestProtocolOp()
                                                             throws ClassCastException
        Retrieves the protocol op for this LDAP message as a compare request protocol op.
        Returns:
        The protocol op for this LDAP message as a compare request protocol op.
        Throws:
        ClassCastException - If the protocol op is not a compare request protocol op.
      • getCompareResponseProtocolOp

        public CompareResponseProtocolOp getCompareResponseProtocolOp()
                                                               throws ClassCastException
        Retrieves the protocol op for this LDAP message as a compare response protocol op.
        Returns:
        The protocol op for this LDAP message as a compare response protocol op.
        Throws:
        ClassCastException - If the protocol op is not a compare response protocol op.
      • getDeleteRequestProtocolOp

        public DeleteRequestProtocolOp getDeleteRequestProtocolOp()
                                                           throws ClassCastException
        Retrieves the protocol op for this LDAP message as a delete request protocol op.
        Returns:
        The protocol op for this LDAP message as a delete request protocol op.
        Throws:
        ClassCastException - If the protocol op is not a delete request protocol op.
      • getDeleteResponseProtocolOp

        public DeleteResponseProtocolOp getDeleteResponseProtocolOp()
                                                             throws ClassCastException
        Retrieves the protocol op for this LDAP message as a delete response protocol op.
        Returns:
        The protocol op for this LDAP message as a delete response protocol op.
        Throws:
        ClassCastException - If the protocol op is not a delete response protocol op.
      • getExtendedRequestProtocolOp

        public ExtendedRequestProtocolOp getExtendedRequestProtocolOp()
                                                               throws ClassCastException
        Retrieves the protocol op for this LDAP message as an extended request protocol op.
        Returns:
        The protocol op for this LDAP message as an extended request protocol op.
        Throws:
        ClassCastException - If the protocol op is not an extended request protocol op.
      • getExtendedResponseProtocolOp

        public ExtendedResponseProtocolOp getExtendedResponseProtocolOp()
                                                                 throws ClassCastException
        Retrieves the protocol op for this LDAP message as an extended response protocol op.
        Returns:
        The protocol op for this LDAP message as an extended response protocol op.
        Throws:
        ClassCastException - If the protocol op is not an extended response protocol op.
      • getModifyRequestProtocolOp

        public ModifyRequestProtocolOp getModifyRequestProtocolOp()
                                                           throws ClassCastException
        Retrieves the protocol op for this LDAP message as a modify request protocol op.
        Returns:
        The protocol op for this LDAP message as a modify request protocol op.
        Throws:
        ClassCastException - If the protocol op is not a modify request protocol op.
      • getModifyResponseProtocolOp

        public ModifyResponseProtocolOp getModifyResponseProtocolOp()
                                                             throws ClassCastException
        Retrieves the protocol op for this LDAP message as a modify response protocol op.
        Returns:
        The protocol op for this LDAP message as a modify response protocol op.
        Throws:
        ClassCastException - If the protocol op is not a modify response protocol op.
      • getModifyDNRequestProtocolOp

        public ModifyDNRequestProtocolOp getModifyDNRequestProtocolOp()
                                                               throws ClassCastException
        Retrieves the protocol op for this LDAP message as a modify DN request protocol op.
        Returns:
        The protocol op for this LDAP message as a modify DN request protocol op.
        Throws:
        ClassCastException - If the protocol op is not a modify DN request protocol op.
      • getModifyDNResponseProtocolOp

        public ModifyDNResponseProtocolOp getModifyDNResponseProtocolOp()
                                                                 throws ClassCastException
        Retrieves the protocol op for this LDAP message as a modify DN response protocol op.
        Returns:
        The protocol op for this LDAP message as a modify DN response protocol op.
        Throws:
        ClassCastException - If the protocol op is not a modify DN response protocol op.
      • getSearchRequestProtocolOp

        public SearchRequestProtocolOp getSearchRequestProtocolOp()
                                                           throws ClassCastException
        Retrieves the protocol op for this LDAP message as a search request protocol op.
        Returns:
        The protocol op for this LDAP message as a search request protocol op.
        Throws:
        ClassCastException - If the protocol op is not a search request protocol op.
      • getSearchResultDoneProtocolOp

        public SearchResultDoneProtocolOp getSearchResultDoneProtocolOp()
                                                                 throws ClassCastException
        Retrieves the protocol op for this LDAP message as a search result done protocol op.
        Returns:
        The protocol op for this LDAP message as a search result done protocol op.
        Throws:
        ClassCastException - If the protocol op is not a search result done protocol op.
      • getSearchResultEntryProtocolOp

        public SearchResultEntryProtocolOp getSearchResultEntryProtocolOp()
                                                                   throws ClassCastException
        Retrieves the protocol op for this LDAP message as a search result entry protocol op.
        Returns:
        The protocol op for this LDAP message as a search result entry protocol op.
        Throws:
        ClassCastException - If the protocol op is not a search result entry protocol op.
      • getSearchResultReferenceProtocolOp

        public SearchResultReferenceProtocolOp getSearchResultReferenceProtocolOp()
                                                                           throws ClassCastException
        Retrieves the protocol op for this LDAP message as a search result reference protocol op.
        Returns:
        The protocol op for this LDAP message as a search result reference protocol op.
        Throws:
        ClassCastException - If the protocol op is not a search result reference protocol op.
      • getUnbindRequestProtocolOp

        public UnbindRequestProtocolOp getUnbindRequestProtocolOp()
                                                           throws ClassCastException
        Retrieves the protocol op for this LDAP message as an unbind request protocol op.
        Returns:
        The protocol op for this LDAP message as an unbind request protocol op.
        Throws:
        ClassCastException - If the protocol op is not an unbind request protocol op.
      • getControls

        public List<Control> getControls()
        Retrieves the set of controls for this LDAP message. It may be modified by the caller.
        Returns:
        The set of controls for this LDAP message.
      • write

        public void write​(ASN1Writer stream)
                   throws IOException
        Writes this protocol op to an ASN.1 output stream.
        Parameters:
        stream - The ASN.1 output stream to write to.
        Throws:
        IOException - If a problem occurs while writing to the stream.
      • getProtocolElementName

        public String getProtocolElementName()
        Retrieves the name of the protocol associated with this protocol element.
        Specified by:
        getProtocolElementName in interface ProtocolElement
        Returns:
        The name of the protocol associated with this protocol element.
      • toString

        public String toString()
        Retrieves a string representation of this LDAP message.
        Overrides:
        toString in class Object
        Returns:
        A string representation of this LDAP message.
      • toString

        public void toString​(StringBuilder buffer)
        Appends a string representation of this protocol element to the provided buffer.
        Specified by:
        toString in interface ProtocolElement
        Parameters:
        buffer - The buffer into which the string representation should be written.
      • toString

        public void toString​(StringBuilder buffer,
                             int indent)
        Appends a string representation of this protocol element to the provided buffer.
        Specified by:
        toString in interface ProtocolElement
        Parameters:
        buffer - The buffer into which the string representation should be written.
        indent - The number of spaces that should be used to indent the resulting string representation.