Package com.unboundid.ldap.protocol
Class LDAPMessage
java.lang.Object
com.unboundid.ldap.protocol.LDAPMessage
- All Implemented Interfaces:
Serializable
@InternalUseOnly
@NotMutable
@ThreadSafety(level=COMPLETELY_THREADSAFE)
public final class LDAPMessage
extends Object
implements Serializable
This class provides a data structure that may be used to represent LDAP
protocol messages. Each LDAP message contains a message ID, a protocol op,
and an optional set of controls.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final byteThe BER type to use for the set of controls.static final byteThe BER type to use for the abandon request protocol op.static final byteThe BER type to use for the add request protocol op.static final byteThe BER type to use for the add response protocol op.static final byteThe BER type to use for the bind request protocol op.static final byteThe BER type to use for the bind response protocol op.static final byteThe BER type to use for the compare request protocol op.static final byteThe BER type to use for the compare response protocol op.static final byteThe BER type to use for the delete request protocol op.static final byteThe BER type to use for the delete response protocol op.static final byteThe BER type to use for the extended request protocol op.static final byteThe BER type to use for the extended response protocol op.static final byteThe BER type to use for the intermediate response protocol op.static final byteThe BER type to use for the modify DN request protocol op.static final byteThe BER type to use for the modify DN response protocol op.static final byteThe BER type to use for the modify request protocol op.static final byteThe BER type to use for the modify response protocol op.static final byteThe BER type to use for the search request protocol op.static final byteThe BER type to use for the search result done protocol op.static final byteThe BER type to use for the search result entry protocol op.static final byteThe BER type to use for the search result reference protocol op.static final byteThe BER type to use for the unbind request protocol op. -
Constructor Summary
ConstructorsConstructorDescriptionLDAPMessage(int messageID, ProtocolOp protocolOp, Control... controls) Creates a new LDAP message with the provided information.LDAPMessage(int messageID, ProtocolOp protocolOp, List<Control> controls) Creates a new LDAP message with the provided information. -
Method Summary
Modifier and TypeMethodDescriptionstatic LDAPMessagedecode(ASN1Element element) Decodes the provided ASN.1 element as an LDAP message.encode()Encodes this LDAP message to an ASN.1 element.Retrieves the abandon request protocol op from this LDAP message.Retrieves the add request protocol op from this LDAP message.Retrieves the add response protocol op from this LDAP message.Retrieves the bind request protocol op from this LDAP message.Retrieves the bind response protocol op from this LDAP message.Retrieves the compare request protocol op from this LDAP message.Retrieves the compare response protocol op from this LDAP message.Retrieves the set of controls for this LDAP message.Retrieves the delete request protocol op from this LDAP message.Retrieves the delete response protocol op from this LDAP message.Retrieves the extended request protocol op from this LDAP message.Retrieves the extended response protocol op from this LDAP message.Retrieves the intermediate response protocol op from this LDAP message.intRetrieves the message ID for this LDAP message.Retrieves the modify DN request protocol op from this LDAP message.Retrieves the modify DN response protocol op from this LDAP message.Retrieves the modify request protocol op from this LDAP message.Retrieves the modify response protocol op from this LDAP message.Retrieves the protocol op for this LDAP message.byteRetrieves the BER type for the protocol op contained in this LDAP message.Retrieves the search request protocol op from this LDAP message.Retrieves the search result done protocol op from this LDAP message.Retrieves the search result entry protocol op from this LDAP message.Retrieves the search result reference protocol op from this LDAP message.Retrieves the unbind request protocol op from this LDAP message.static LDAPMessagereadFrom(ASN1StreamReader reader, boolean ignoreSocketTimeout) Reads an LDAP message from the provided ASN.1 stream reader.static LDAPResponsereadLDAPResponseFrom(ASN1StreamReader reader, boolean ignoreSocketTimeout) ReadsLDAPResponseobject from the provided ASN.1 stream reader.static LDAPResponsereadLDAPResponseFrom(ASN1StreamReader reader, boolean ignoreSocketTimeout, Schema schema) ReadsLDAPResponseobject from the provided ASN.1 stream reader.toString()Retrieves a string representation of this LDAP message.voidtoString(StringBuilder buffer) Appends a string representation of this LDAP message to the provided buffer.voidwriteTo(ASN1Buffer buffer) Writes an encoded representation of this LDAP message to the provided ASN.1 buffer.
-
Field Details
-
PROTOCOL_OP_TYPE_BIND_REQUEST
The BER type to use for the bind request protocol op.- See Also:
-
PROTOCOL_OP_TYPE_BIND_RESPONSE
The BER type to use for the bind response protocol op.- See Also:
-
PROTOCOL_OP_TYPE_UNBIND_REQUEST
The BER type to use for the unbind request protocol op.- See Also:
-
PROTOCOL_OP_TYPE_SEARCH_REQUEST
The BER type to use for the search request protocol op.- See Also:
-
PROTOCOL_OP_TYPE_SEARCH_RESULT_ENTRY
The BER type to use for the search result entry protocol op.- See Also:
-
PROTOCOL_OP_TYPE_SEARCH_RESULT_REFERENCE
The BER type to use for the search result reference protocol op.- See Also:
-
PROTOCOL_OP_TYPE_SEARCH_RESULT_DONE
The BER type to use for the search result done protocol op.- See Also:
-
PROTOCOL_OP_TYPE_MODIFY_REQUEST
The BER type to use for the modify request protocol op.- See Also:
-
PROTOCOL_OP_TYPE_MODIFY_RESPONSE
The BER type to use for the modify response protocol op.- See Also:
-
PROTOCOL_OP_TYPE_ADD_REQUEST
The BER type to use for the add request protocol op.- See Also:
-
PROTOCOL_OP_TYPE_ADD_RESPONSE
The BER type to use for the add response protocol op.- See Also:
-
PROTOCOL_OP_TYPE_DELETE_REQUEST
The BER type to use for the delete request protocol op.- See Also:
-
PROTOCOL_OP_TYPE_DELETE_RESPONSE
The BER type to use for the delete response protocol op.- See Also:
-
PROTOCOL_OP_TYPE_MODIFY_DN_REQUEST
The BER type to use for the modify DN request protocol op.- See Also:
-
PROTOCOL_OP_TYPE_MODIFY_DN_RESPONSE
The BER type to use for the modify DN response protocol op.- See Also:
-
PROTOCOL_OP_TYPE_COMPARE_REQUEST
The BER type to use for the compare request protocol op.- See Also:
-
PROTOCOL_OP_TYPE_COMPARE_RESPONSE
The BER type to use for the compare response protocol op.- See Also:
-
PROTOCOL_OP_TYPE_ABANDON_REQUEST
The BER type to use for the abandon request protocol op.- See Also:
-
PROTOCOL_OP_TYPE_EXTENDED_REQUEST
The BER type to use for the extended request protocol op.- See Also:
-
PROTOCOL_OP_TYPE_EXTENDED_RESPONSE
The BER type to use for the extended response protocol op.- See Also:
-
PROTOCOL_OP_TYPE_INTERMEDIATE_RESPONSE
The BER type to use for the intermediate response protocol op.- See Also:
-
MESSAGE_TYPE_CONTROLS
The BER type to use for the set of controls.- See Also:
-
-
Constructor Details
-
LDAPMessage
Creates a new LDAP message with the provided information.- Parameters:
messageID- The message ID for this LDAP message.protocolOp- The protocol op for this LDAP message. It must not benull.controls- The set of controls for this LDAP message. It may benullor empty if no controls are required.
-
LDAPMessage
Creates a new LDAP message with the provided information.- Parameters:
messageID- The message ID for this LDAP message.protocolOp- The protocol op for this LDAP message. It must not benull.controls- The set of controls for this LDAP message. It may benullor empty if no controls are required.
-
-
Method Details
-
getMessageID
Retrieves the message ID for this LDAP message.- Returns:
- The message ID for this LDAP message.
-
getProtocolOp
Retrieves the protocol op for this LDAP message.- Returns:
- The protocol op for this LDAP message.
-
getProtocolOpType
Retrieves the BER type for the protocol op contained in this LDAP message.- Returns:
- The BER type for the protocol op contained in this LDAP message.
-
getAbandonRequestProtocolOp
Retrieves the abandon request protocol op from this LDAP message. This may only be used if this LDAP message was obtained using thereadFrom(com.unboundid.asn1.ASN1StreamReader, boolean)method.- Returns:
- The abandon request protocol op from this LDAP message.
- Throws:
ClassCastException- If the protocol op for this LDAP message is not an abandon request protocol op.
-
getAddRequestProtocolOp
Retrieves the add request protocol op from this LDAP message. This may only be used if this LDAP message was obtained using thereadFrom(com.unboundid.asn1.ASN1StreamReader, boolean)method.- Returns:
- The add request protocol op from this LDAP message.
- Throws:
ClassCastException- If the protocol op for this LDAP message is not an add request protocol op.
-
getAddResponseProtocolOp
Retrieves the add response protocol op from this LDAP message. This may only be used if this LDAP message was obtained using thereadFrom(com.unboundid.asn1.ASN1StreamReader, boolean)method.- Returns:
- The add response protocol op from this LDAP message.
- Throws:
ClassCastException- If the protocol op for this LDAP message is not an add response protocol op.
-
getBindRequestProtocolOp
Retrieves the bind request protocol op from this LDAP message. This may only be used if this LDAP message was obtained using thereadFrom(com.unboundid.asn1.ASN1StreamReader, boolean)method.- Returns:
- The bind request protocol op from this LDAP message.
- Throws:
ClassCastException- If the protocol op for this LDAP message is not a bind request protocol op.
-
getBindResponseProtocolOp
Retrieves the bind response protocol op from this LDAP message. This may only be used if this LDAP message was obtained using thereadFrom(com.unboundid.asn1.ASN1StreamReader, boolean)method.- Returns:
- The bind response protocol op from this LDAP message.
- Throws:
ClassCastException- If the protocol op for this LDAP message is not a bind response protocol op.
-
getCompareRequestProtocolOp
Retrieves the compare request protocol op from this LDAP message. This may only be used if this LDAP message was obtained using thereadFrom(com.unboundid.asn1.ASN1StreamReader, boolean)method.- Returns:
- The compare request protocol op from this LDAP message.
- Throws:
ClassCastException- If the protocol op for this LDAP message is not a compare request protocol op.
-
getCompareResponseProtocolOp
Retrieves the compare response protocol op from this LDAP message. This may only be used if this LDAP message was obtained using thereadFrom(com.unboundid.asn1.ASN1StreamReader, boolean)method.- Returns:
- The compare response protocol op from this LDAP message.
- Throws:
ClassCastException- If the protocol op for this LDAP message is not a compare response protocol op.
-
getDeleteRequestProtocolOp
Retrieves the delete request protocol op from this LDAP message. This may only be used if this LDAP message was obtained using thereadFrom(com.unboundid.asn1.ASN1StreamReader, boolean)method.- Returns:
- The delete request protocol op from this LDAP message.
- Throws:
ClassCastException- If the protocol op for this LDAP message is not a delete request protocol op.
-
getDeleteResponseProtocolOp
Retrieves the delete response protocol op from this LDAP message. This may only be used if this LDAP message was obtained using thereadFrom(com.unboundid.asn1.ASN1StreamReader, boolean)method.- Returns:
- The delete response protocol op from this LDAP message.
- Throws:
ClassCastException- If the protocol op for this LDAP message is not a delete response protocol op.
-
getExtendedRequestProtocolOp
Retrieves the extended request protocol op from this LDAP message. This may only be used if this LDAP message was obtained using thereadFrom(com.unboundid.asn1.ASN1StreamReader, boolean)method.- Returns:
- The extended request protocol op from this LDAP message.
- Throws:
ClassCastException- If the protocol op for this LDAP message is not an extended request protocol op.
-
getExtendedResponseProtocolOp
@NotNull public ExtendedResponseProtocolOp getExtendedResponseProtocolOp() throws ClassCastExceptionRetrieves the extended response protocol op from this LDAP message. This may only be used if this LDAP message was obtained using thereadFrom(com.unboundid.asn1.ASN1StreamReader, boolean)method.- Returns:
- The extended response protocol op from this LDAP message.
- Throws:
ClassCastException- If the protocol op for this LDAP message is not an extended response protocol op.
-
getModifyRequestProtocolOp
Retrieves the modify request protocol op from this LDAP message. This may only be used if this LDAP message was obtained using thereadFrom(com.unboundid.asn1.ASN1StreamReader, boolean)method.- Returns:
- The modify request protocol op from this LDAP message.
- Throws:
ClassCastException- If the protocol op for this LDAP message is not a modify request protocol op.
-
getModifyResponseProtocolOp
Retrieves the modify response protocol op from this LDAP message. This may only be used if this LDAP message was obtained using thereadFrom(com.unboundid.asn1.ASN1StreamReader, boolean)method.- Returns:
- The modify response protocol op from this LDAP message.
- Throws:
ClassCastException- If the protocol op for this LDAP message is not a modify response protocol op.
-
getModifyDNRequestProtocolOp
Retrieves the modify DN request protocol op from this LDAP message. This may only be used if this LDAP message was obtained using thereadFrom(com.unboundid.asn1.ASN1StreamReader, boolean)method.- Returns:
- The modify DN request protocol op from this LDAP message.
- Throws:
ClassCastException- If the protocol op for this LDAP message is not a modify DN request protocol op.
-
getModifyDNResponseProtocolOp
@NotNull public ModifyDNResponseProtocolOp getModifyDNResponseProtocolOp() throws ClassCastExceptionRetrieves the modify DN response protocol op from this LDAP message. This may only be used if this LDAP message was obtained using thereadFrom(com.unboundid.asn1.ASN1StreamReader, boolean)method.- Returns:
- The modify DN response protocol op from this LDAP message.
- Throws:
ClassCastException- If the protocol op for this LDAP message is not a modify DN response protocol op.
-
getSearchRequestProtocolOp
Retrieves the search request protocol op from this LDAP message. This may only be used if this LDAP message was obtained using thereadFrom(com.unboundid.asn1.ASN1StreamReader, boolean)method.- Returns:
- The search request protocol op from this LDAP message.
- Throws:
ClassCastException- If the protocol op for this LDAP message is not a search request protocol op.
-
getSearchResultEntryProtocolOp
@NotNull public SearchResultEntryProtocolOp getSearchResultEntryProtocolOp() throws ClassCastExceptionRetrieves the search result entry protocol op from this LDAP message. This may only be used if this LDAP message was obtained using thereadFrom(com.unboundid.asn1.ASN1StreamReader, boolean)method.- Returns:
- The search result entry protocol op from this LDAP message.
- Throws:
ClassCastException- If the protocol op for this LDAP message is not a search result entry protocol op.
-
getSearchResultReferenceProtocolOp
@NotNull public SearchResultReferenceProtocolOp getSearchResultReferenceProtocolOp() throws ClassCastExceptionRetrieves the search result reference protocol op from this LDAP message. This may only be used if this LDAP message was obtained using thereadFrom(com.unboundid.asn1.ASN1StreamReader, boolean)method.- Returns:
- The search result reference protocol op from this LDAP message.
- Throws:
ClassCastException- If the protocol op for this LDAP message is not a search result reference protocol op.
-
getSearchResultDoneProtocolOp
@NotNull public SearchResultDoneProtocolOp getSearchResultDoneProtocolOp() throws ClassCastExceptionRetrieves the search result done protocol op from this LDAP message. This may only be used if this LDAP message was obtained using thereadFrom(com.unboundid.asn1.ASN1StreamReader, boolean)method.- Returns:
- The search result done protocol op from this LDAP message.
- Throws:
ClassCastException- If the protocol op for this LDAP message is not a search result done protocol op.
-
getUnbindRequestProtocolOp
Retrieves the unbind request protocol op from this LDAP message. This may only be used if this LDAP message was obtained using thereadFrom(com.unboundid.asn1.ASN1StreamReader, boolean)method.- Returns:
- The unbind request protocol op from this LDAP message.
- Throws:
ClassCastException- If the protocol op for this LDAP message is not an unbind request protocol op.
-
getIntermediateResponseProtocolOp
@NotNull public IntermediateResponseProtocolOp getIntermediateResponseProtocolOp() throws ClassCastExceptionRetrieves the intermediate response protocol op from this LDAP message. This may only be used if this LDAP message was obtained using thereadFrom(com.unboundid.asn1.ASN1StreamReader, boolean)method.- Returns:
- The intermediate response protocol op from this LDAP message.
- Throws:
ClassCastException- If the protocol op for this LDAP message is not an intermediate response protocol op.
-
getControls
Retrieves the set of controls for this LDAP message.- Returns:
- The set of controls for this LDAP message.
-
encode
Encodes this LDAP message to an ASN.1 element.- Returns:
- The ASN.1 element containing the encoded representation of this LDAP message.
-
decode
Decodes the provided ASN.1 element as an LDAP message.- Parameters:
element- The ASN.1 element to be decoded.- Returns:
- The LDAP message decoded from the provided ASN.1 element.
- Throws:
LDAPException- If the provided ASN.1 element cannot be decoded as a valid LDAP message.
-
writeTo
Writes an encoded representation of this LDAP message to the provided ASN.1 buffer.- Parameters:
buffer- The ASN.1 buffer to which the encoded representation should be written.
-
readFrom
@Nullable public static LDAPMessage readFrom(@NotNull ASN1StreamReader reader, boolean ignoreSocketTimeout) throws LDAPException Reads an LDAP message from the provided ASN.1 stream reader.- Parameters:
reader- The ASN.1 stream reader from which the LDAP message should be read.ignoreSocketTimeout- Indicates whether to ignore socket timeout exceptions caught during processing. This should betruewhen the associated connection is operating in asynchronous mode, andfalsewhen operating in synchronous mode. In either case, exceptions will not be ignored for the first read, since that will be handled by the connection reader.- Returns:
- The decoded LDAP message, or
nullif the end of the input stream has been reached. - Throws:
LDAPException- If an error occurs while attempting to read or decode the LDAP message.
-
readLDAPResponseFrom
@Nullable public static LDAPResponse readLDAPResponseFrom(@NotNull ASN1StreamReader reader, boolean ignoreSocketTimeout) throws LDAPException ReadsLDAPResponseobject from the provided ASN.1 stream reader.- Parameters:
reader- The ASN.1 stream reader from which the LDAP message should be read.ignoreSocketTimeout- Indicates whether to ignore socket timeout exceptions caught during processing. This should betruewhen the associated connection is operating in asynchronous mode, andfalsewhen operating in synchronous mode. In either case, exceptions will not be ignored for the first read, since that will be handled by the connection reader.- Returns:
- The decoded LDAP message, or
nullif the end of the input stream has been reached. - Throws:
LDAPException- If an error occurs while attempting to read or decode the LDAP message.
-
readLDAPResponseFrom
@Nullable public static LDAPResponse readLDAPResponseFrom(@NotNull ASN1StreamReader reader, boolean ignoreSocketTimeout, @Nullable Schema schema) throws LDAPException ReadsLDAPResponseobject from the provided ASN.1 stream reader.- Parameters:
reader- The ASN.1 stream reader from which the LDAP message should be read.ignoreSocketTimeout- Indicates whether to ignore socket timeout exceptions caught during processing. This should betruewhen the associated connection is operating in asynchronous mode, andfalsewhen operating in synchronous mode. In either case, exceptions will not be ignored for the first read, since that will be handled by the connection reader.schema- The schema to use to select the appropriate matching rule for attributes included in the response.- Returns:
- The decoded LDAP message, or
nullif the end of the input stream has been reached. - Throws:
LDAPException- If an error occurs while attempting to read or decode the LDAP message.
-
toString
Retrieves a string representation of this LDAP message. -
toString
Appends a string representation of this LDAP message to the provided buffer.- Parameters:
buffer- The buffer to which the string representation should be appended.
-