Package org.forgerock.opendj.io
Class Ldap
java.lang.Object
org.forgerock.opendj.io.Ldap
This class contains various static utility methods encoding and decoding LDAP
protocol elements.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The OID for the Kerberos V GSSAPI mechanism.static final String
The OID for the LDAP notice of disconnection extended operation.static final byte
The protocol op type for abandon requests.static final byte
The protocol op type for add requests.static final byte
The protocol op type for add responses.static final byte
The protocol op type for bind requests.static final byte
The protocol op type for bind responses.static final byte
The protocol op type for compare requests.static final byte
The protocol op type for compare responses.static final byte
The protocol op type for delete requests.static final byte
The protocol op type for delete responses.static final byte
The protocol op type for extended requests.static final byte
The protocol op type for extended responses.static final byte
The protocol op type for intermediate responses.static final byte
The protocol op type for modify DN requests.static final byte
The protocol op type for modify DN responses.static final byte
The protocol op type for modify requests.static final byte
The protocol op type for modify responses.static final byte
The protocol op type for search requests.static final byte
The protocol op type for search result done elements.static final byte
The protocol op type for search result entries.static final byte
The protocol op type for search result references.static final byte
The protocol op type for unbind requests.static final byte
The BER type to use for the AuthenticationChoice element in a bind request when SASL authentication is to be used.static final byte
The BER type to use for the AuthenticationChoice element in a bind request when simple authentication is to be used.static final byte
The BER type to use for encoding the sequence of controls in an LDAP message.static final byte
The BER type to use for the OID of an extended request.static final byte
The BER type to use for the value of an extended request.static final byte
The BER type to use for the OID of an extended response.static final byte
The BER type to use for the value of an extended response.static final byte
The BER type to use for AND filter components.static final byte
The BER type to use for approximate filter components.static final byte
The BER type to use for equality filter components.static final byte
The BER type to use for extensible matching filter components.static final byte
The BER type to use for greater than or equal to filter components.static final byte
The BER type to use for less than or equal to filter components.static final byte
The BER type to use for NOT filter components.static final byte
The BER type to use for OR filter components.static final byte
The BER type to use for presence filter components.static final byte
The BER type to use for substring filter components.static final byte
The BER type to use for the OID of an intermediate response message.static final byte
The BER type to use for the value of an intermediate response message.static final byte
The BER type to use for the DN attributes flag in a matching rule assertion.static final byte
The BER type to use for the matching rule OID in a matching rule assertion.static final byte
The BER type to use for the attribute type in a matching rule assertion.static final byte
The BER type to use for the assertion value in a matching rule assertion.static final byte
The BER type to use for the newSuperior component of a modify DN request.static final byte
The BER type to use for encoding the sequence of referral URLs in an LDAPResult element.static final byte
The BER type to use for the server SASL credentials in a bind response.static final byte
The BER type to use for the subAny component(s) of a substring filter.static final byte
The BER type to use for the subFinal components of a substring filter.static final byte
The BER type to use for the subInitial component of a substring filter. -
Method Summary
Modifier and TypeMethodDescriptionstatic LdapReader
getReader
(Asn1Reader asn1Reader, DecodeOptions options) Creates a new LDAP reader which will read LDAP messages from an ASN.1 reader using the provided decoding options.static LdapWriter
getWriter
(Asn1Writer asn1Writer, int ldapVersion) Creates a new LDAP writer which will write LDAP messages to the provided ASN.1 writer.static Attribute
readAttribute
(Asn1Reader reader, DecodeOptions options, Schema schema) Reads the next ASN.1 element from the providedASN1Reader
as anAttribute
.static Control
readControl
(Asn1Reader reader) Reads the next ASN.1 element from the providedASN1Reader
as aControl
.static Entry
readEntry
(Asn1Reader reader, DecodeOptions options) Reads the next ASN.1 element from the providedASN1Reader
as anEntry
.static Filter
readFilter
(Asn1Reader reader) Reads the next ASN.1 element from the providedASN1Reader
as aFilter
using a maximum filter depth of 100.static Filter
readFilter
(Asn1Reader reader, int maxFilterDepth) Reads the next ASN.1 element from the providedASN1Reader
as aFilter
using the provided maximum filter depth.static Modification
readModification
(Asn1Reader reader, DecodeOptions options, Schema schema) Reads the next ASN.1 element from the providedASN1Reader
as aModification
.static byte
requestToResponseProtocolOpType
(byte requestProtocolOpType) Returns the response protocol operation type associated to the given request protocol op.static void
writeAttribute
(Asn1Writer writer, Attribute attribute) Writes anAttribute
to the providedAsn1Writer
.static void
writeEntry
(Asn1Writer writer, Entry entry) Writes anEntry
to the providedAsn1Writer
.static void
writeFilter
(Asn1Writer writer, Filter filter) Writes aFilter
to the providedAsn1Writer
.static void
writeModification
(Asn1Writer writer, Modification modification) Writes anModification
to the providedAsn1Writer
.
-
Field Details
-
OID_GSSAPI_KERBEROS_V
The OID for the Kerberos V GSSAPI mechanism.- See Also:
-
OID_NOTICE_OF_DISCONNECTION
The OID for the LDAP notice of disconnection extended operation.- See Also:
-
OP_TYPE_ABANDON_REQUEST
public static final byte OP_TYPE_ABANDON_REQUESTThe protocol op type for abandon requests.- See Also:
-
OP_TYPE_ADD_REQUEST
public static final byte OP_TYPE_ADD_REQUESTThe protocol op type for add requests.- See Also:
-
OP_TYPE_ADD_RESPONSE
public static final byte OP_TYPE_ADD_RESPONSEThe protocol op type for add responses.- See Also:
-
OP_TYPE_BIND_REQUEST
public static final byte OP_TYPE_BIND_REQUESTThe protocol op type for bind requests.- See Also:
-
OP_TYPE_BIND_RESPONSE
public static final byte OP_TYPE_BIND_RESPONSEThe protocol op type for bind responses.- See Also:
-
OP_TYPE_COMPARE_REQUEST
public static final byte OP_TYPE_COMPARE_REQUESTThe protocol op type for compare requests.- See Also:
-
OP_TYPE_COMPARE_RESPONSE
public static final byte OP_TYPE_COMPARE_RESPONSEThe protocol op type for compare responses.- See Also:
-
OP_TYPE_DELETE_REQUEST
public static final byte OP_TYPE_DELETE_REQUESTThe protocol op type for delete requests.- See Also:
-
OP_TYPE_DELETE_RESPONSE
public static final byte OP_TYPE_DELETE_RESPONSEThe protocol op type for delete responses.- See Also:
-
OP_TYPE_EXTENDED_REQUEST
public static final byte OP_TYPE_EXTENDED_REQUESTThe protocol op type for extended requests.- See Also:
-
OP_TYPE_EXTENDED_RESPONSE
public static final byte OP_TYPE_EXTENDED_RESPONSEThe protocol op type for extended responses.- See Also:
-
OP_TYPE_INTERMEDIATE_RESPONSE
public static final byte OP_TYPE_INTERMEDIATE_RESPONSEThe protocol op type for intermediate responses.- See Also:
-
OP_TYPE_MODIFY_DN_REQUEST
public static final byte OP_TYPE_MODIFY_DN_REQUESTThe protocol op type for modify DN requests.- See Also:
-
OP_TYPE_MODIFY_DN_RESPONSE
public static final byte OP_TYPE_MODIFY_DN_RESPONSEThe protocol op type for modify DN responses.- See Also:
-
OP_TYPE_MODIFY_REQUEST
public static final byte OP_TYPE_MODIFY_REQUESTThe protocol op type for modify requests.- See Also:
-
OP_TYPE_MODIFY_RESPONSE
public static final byte OP_TYPE_MODIFY_RESPONSEThe protocol op type for modify responses.- See Also:
-
OP_TYPE_SEARCH_REQUEST
public static final byte OP_TYPE_SEARCH_REQUESTThe protocol op type for search requests.- See Also:
-
OP_TYPE_SEARCH_RESULT_DONE
public static final byte OP_TYPE_SEARCH_RESULT_DONEThe protocol op type for search result done elements.- See Also:
-
OP_TYPE_SEARCH_RESULT_ENTRY
public static final byte OP_TYPE_SEARCH_RESULT_ENTRYThe protocol op type for search result entries.- See Also:
-
OP_TYPE_SEARCH_RESULT_REFERENCE
public static final byte OP_TYPE_SEARCH_RESULT_REFERENCEThe protocol op type for search result references.- See Also:
-
OP_TYPE_UNBIND_REQUEST
public static final byte OP_TYPE_UNBIND_REQUESTThe protocol op type for unbind requests.- See Also:
-
TYPE_AUTHENTICATION_SASL
public static final byte TYPE_AUTHENTICATION_SASLThe BER type to use for the AuthenticationChoice element in a bind request when SASL authentication is to be used.- See Also:
-
TYPE_AUTHENTICATION_SIMPLE
public static final byte TYPE_AUTHENTICATION_SIMPLEThe BER type to use for the AuthenticationChoice element in a bind request when simple authentication is to be used.- See Also:
-
TYPE_CONTROL_SEQUENCE
public static final byte TYPE_CONTROL_SEQUENCEThe BER type to use for encoding the sequence of controls in an LDAP message.- See Also:
-
TYPE_EXTENDED_REQUEST_OID
public static final byte TYPE_EXTENDED_REQUEST_OIDThe BER type to use for the OID of an extended request.- See Also:
-
TYPE_EXTENDED_REQUEST_VALUE
public static final byte TYPE_EXTENDED_REQUEST_VALUEThe BER type to use for the value of an extended request.- See Also:
-
TYPE_EXTENDED_RESPONSE_OID
public static final byte TYPE_EXTENDED_RESPONSE_OIDThe BER type to use for the OID of an extended response.- See Also:
-
TYPE_EXTENDED_RESPONSE_VALUE
public static final byte TYPE_EXTENDED_RESPONSE_VALUEThe BER type to use for the value of an extended response.- See Also:
-
TYPE_FILTER_AND
public static final byte TYPE_FILTER_ANDThe BER type to use for AND filter components.- See Also:
-
TYPE_FILTER_APPROXIMATE
public static final byte TYPE_FILTER_APPROXIMATEThe BER type to use for approximate filter components.- See Also:
-
TYPE_FILTER_EQUALITY
public static final byte TYPE_FILTER_EQUALITYThe BER type to use for equality filter components.- See Also:
-
TYPE_FILTER_EXTENSIBLE_MATCH
public static final byte TYPE_FILTER_EXTENSIBLE_MATCHThe BER type to use for extensible matching filter components.- See Also:
-
TYPE_FILTER_GREATER_OR_EQUAL
public static final byte TYPE_FILTER_GREATER_OR_EQUALThe BER type to use for greater than or equal to filter components.- See Also:
-
TYPE_FILTER_LESS_OR_EQUAL
public static final byte TYPE_FILTER_LESS_OR_EQUALThe BER type to use for less than or equal to filter components.- See Also:
-
TYPE_FILTER_NOT
public static final byte TYPE_FILTER_NOTThe BER type to use for NOT filter components.- See Also:
-
TYPE_FILTER_OR
public static final byte TYPE_FILTER_ORThe BER type to use for OR filter components.- See Also:
-
TYPE_FILTER_PRESENCE
public static final byte TYPE_FILTER_PRESENCEThe BER type to use for presence filter components.- See Also:
-
TYPE_FILTER_SUBSTRING
public static final byte TYPE_FILTER_SUBSTRINGThe BER type to use for substring filter components.- See Also:
-
TYPE_INTERMEDIATE_RESPONSE_OID
public static final byte TYPE_INTERMEDIATE_RESPONSE_OIDThe BER type to use for the OID of an intermediate response message.- See Also:
-
TYPE_INTERMEDIATE_RESPONSE_VALUE
public static final byte TYPE_INTERMEDIATE_RESPONSE_VALUEThe BER type to use for the value of an intermediate response message.- See Also:
-
TYPE_MATCHING_RULE_DN_ATTRIBUTES
public static final byte TYPE_MATCHING_RULE_DN_ATTRIBUTESThe BER type to use for the DN attributes flag in a matching rule assertion.- See Also:
-
TYPE_MATCHING_RULE_ID
public static final byte TYPE_MATCHING_RULE_IDThe BER type to use for the matching rule OID in a matching rule assertion.- See Also:
-
TYPE_MATCHING_RULE_TYPE
public static final byte TYPE_MATCHING_RULE_TYPEThe BER type to use for the attribute type in a matching rule assertion.- See Also:
-
TYPE_MATCHING_RULE_VALUE
public static final byte TYPE_MATCHING_RULE_VALUEThe BER type to use for the assertion value in a matching rule assertion.- See Also:
-
TYPE_MODIFY_DN_NEW_SUPERIOR
public static final byte TYPE_MODIFY_DN_NEW_SUPERIORThe BER type to use for the newSuperior component of a modify DN request.- See Also:
-
TYPE_REFERRAL_SEQUENCE
public static final byte TYPE_REFERRAL_SEQUENCEThe BER type to use for encoding the sequence of referral URLs in an LDAPResult element.- See Also:
-
TYPE_SERVER_SASL_CREDENTIALS
public static final byte TYPE_SERVER_SASL_CREDENTIALSThe BER type to use for the server SASL credentials in a bind response.- See Also:
-
TYPE_SUBANY
public static final byte TYPE_SUBANYThe BER type to use for the subAny component(s) of a substring filter.- See Also:
-
TYPE_SUBFINAL
public static final byte TYPE_SUBFINALThe BER type to use for the subFinal components of a substring filter.- See Also:
-
TYPE_SUBINITIAL
public static final byte TYPE_SUBINITIALThe BER type to use for the subInitial component of a substring filter.- See Also:
-
-
Method Details
-
requestToResponseProtocolOpType
public static byte requestToResponseProtocolOpType(byte requestProtocolOpType) Returns the response protocol operation type associated to the given request protocol op.- Parameters:
requestProtocolOpType
- The request's protocol-op type- Returns:
- The protocol-op type of the response associated to the given request.
- Throws:
IllegalArgumentException
- ifrequestProtocolOpType
does not identify a request producing response.
-
getReader
Creates a new LDAP reader which will read LDAP messages from an ASN.1 reader using the provided decoding options.- Parameters:
asn1Reader
- The ASN.1 reader from which LDAP messages will be read.options
- LDAP message decoding options.- Returns:
- A new LDAP reader which will read LDAP messages from an ASN.1 reader using the provided decoding options.
-
getWriter
Creates a new LDAP writer which will write LDAP messages to the provided ASN.1 writer.- Parameters:
asn1Writer
- The ASN.1 writer to which LDAP messages will be written.ldapVersion
- Version of the protocol to use to encode the messages.- Returns:
- A new LDAP writer which will write LDAP messages to the provided ASN.1 writer.
-
readControl
Reads the next ASN.1 element from the providedASN1Reader
as aControl
.- Parameters:
reader
- TheASN1Reader
from which the ASN.1 encodedControl
should be read.- Returns:
- The decoded
Control
. - Throws:
IOException
- If an error occurs while reading fromreader
.
-
readFilter
Reads the next ASN.1 element from the providedASN1Reader
as aFilter
using a maximum filter depth of 100. The maximum filter depth can prevent stack overflow errors from filters that look like(&(&(&(&(&(&(&(&(&....
.- Parameters:
reader
- TheASN1Reader
from which the ASN.1 encodedFilter
should be read.- Returns:
- The decoded
Filter
. - Throws:
IOException
- If an error occurs while reading fromreader
.LocalizedIllegalArgumentException
- If an attribute description contains invalid character, exceeds the maximum filter depth, or if the search filter has an unrecognized type.
-
readFilter
Reads the next ASN.1 element from the providedASN1Reader
as aFilter
using the provided maximum filter depth. The maximum filter depth can prevent stack overflow errors from filters that look like(&(&(&(&(&(&(&(&(&....
.- Parameters:
reader
- TheASN1Reader
from which the ASN.1 encodedFilter
should be read.maxFilterDepth
- The maximum depth to which nested search filters will be processed. This can prevent stack overflow errors from filters that look like(&(&(&(&(&(&(&(&(&....
.- Returns:
- The decoded
Filter
. - Throws:
IOException
- If an error occurs while reading fromreader
.LocalizedIllegalArgumentException
- If an attribute description contains invalid character, exceeds the maximum filter depth, or if the search filter has an unrecognized type.
-
readEntry
Reads the next ASN.1 element from the providedASN1Reader
as anEntry
.- Parameters:
reader
- TheASN1Reader
from which the ASN.1 encodedEntry
should be read.options
- The decode options to use when decoding the entry.- Returns:
- The decoded
Entry
. - Throws:
IOException
- If an error occurs while reading fromreader
.
-
writeFilter
Writes aFilter
to the providedAsn1Writer
.- Parameters:
writer
- TheAsn1Writer
to which the ASN.1 encodedFilter
should be written.filter
- The filter.
-
writeEntry
Writes anEntry
to the providedAsn1Writer
.- Parameters:
writer
- TheAsn1Writer
to which the ASN.1 encodedEntry
should be written.entry
- The entry.
-
readModification
public static Modification readModification(Asn1Reader reader, DecodeOptions options, Schema schema) throws IOException Reads the next ASN.1 element from the providedASN1Reader
as aModification
.- Parameters:
reader
- TheASN1Reader
from which the ASN.1 encodedModification
should be read.options
- The decode options to use when decoding the modification.schema
- The schema- Returns:
- The decoded
Modification
. - Throws:
IOException
- If an error occurs while reading fromreader
.
-
readAttribute
public static Attribute readAttribute(Asn1Reader reader, DecodeOptions options, Schema schema) throws IOException Reads the next ASN.1 element from the providedASN1Reader
as anAttribute
.- Parameters:
reader
- TheASN1Reader
from which the ASN.1 encodedAttribute
should be read.options
- The decode options to use when decoding the attribute.schema
- The schema- Returns:
- The decoded
Attribute
. - Throws:
IOException
- If an error occurs while reading fromreader
.
-
writeModification
Writes anModification
to the providedAsn1Writer
.- Parameters:
writer
- TheAsn1Writer
to which the ASN.1 encodedModification
should be written.modification
- The modification.
-
writeAttribute
Writes anAttribute
to the providedAsn1Writer
.- Parameters:
writer
- TheAsn1Writer
to which the ASN.1 encodedAttribute
should be written.attribute
- The attribute.
-