| | |
| | | |
| | | |
| | | |
| | | import static org.opends.sdk.ldap.LDAPConstants.*; |
| | | import static com.sun.opends.sdk.ldap.LDAPConstants.*; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.logging.Level; |
| | |
| | | /** |
| | | * Static methods for encoding LDAP messages. |
| | | */ |
| | | final class LDAPEncoder |
| | | public final class LDAPEncoder |
| | | { |
| | | static void encodeAttribute(ASN1Writer writer, Attribute attribute) |
| | | throws IOException |
| | | { |
| | | writer.writeStartSequence(); |
| | | writer |
| | | .writeOctetString(attribute.getAttributeDescriptionAsString()); |
| | | |
| | | writer.writeStartSet(); |
| | | for (ByteString value : attribute) |
| | | { |
| | | writer.writeOctetString(value); |
| | | } |
| | | writer.writeEndSequence(); |
| | | |
| | | writer.writeEndSequence(); |
| | | } |
| | | |
| | | |
| | | |
| | | static void encodeControl(ASN1Writer writer, Control control) |
| | | public static void encodeControl(ASN1Writer writer, Control control) |
| | | throws IOException |
| | | { |
| | | writer.writeStartSequence(); |
| | |
| | | |
| | | |
| | | |
| | | static void encodeEntry(ASN1Writer writer, |
| | | public static void encodeEntry(ASN1Writer writer, |
| | | SearchResultEntry searchResultEntry) throws IOException |
| | | { |
| | | writer.writeStartSequence(OP_TYPE_SEARCH_RESULT_ENTRY); |
| | |
| | | |
| | | |
| | | |
| | | static void encodeAbandonRequest(ASN1Writer writer, int messageID, |
| | | public static void encodeAbandonRequest(ASN1Writer writer, int messageID, |
| | | AbandonRequest request) throws IOException |
| | | { |
| | | if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) |
| | |
| | | |
| | | |
| | | |
| | | static void encodeAddRequest(ASN1Writer writer, int messageID, |
| | | public static void encodeAddRequest(ASN1Writer writer, int messageID, |
| | | AddRequest request) throws IOException |
| | | { |
| | | if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) |
| | |
| | | |
| | | |
| | | |
| | | static void encodeCompareRequest(ASN1Writer writer, int messageID, |
| | | public static void encodeCompareRequest(ASN1Writer writer, int messageID, |
| | | CompareRequest request) throws IOException |
| | | { |
| | | if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) |
| | |
| | | |
| | | |
| | | |
| | | static void encodeDeleteRequest(ASN1Writer writer, int messageID, |
| | | public static void encodeDeleteRequest(ASN1Writer writer, int messageID, |
| | | DeleteRequest request) throws IOException |
| | | { |
| | | if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) |
| | |
| | | |
| | | |
| | | |
| | | static void encodeExtendedRequest(ASN1Writer writer, int messageID, |
| | | public static void encodeExtendedRequest(ASN1Writer writer, int messageID, |
| | | ExtendedRequest<?> request) throws IOException |
| | | { |
| | | if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) |
| | |
| | | |
| | | |
| | | |
| | | static void encodeBindRequest(ASN1Writer writer, int messageID, |
| | | public static void encodeBindRequest(ASN1Writer writer, int messageID, |
| | | int version, GenericBindRequest request) throws IOException |
| | | { |
| | | if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) |
| | |
| | | |
| | | |
| | | |
| | | static void encodeBindRequest(ASN1Writer writer, int messageID, |
| | | public static void encodeBindRequest(ASN1Writer writer, int messageID, |
| | | int version, SASLBindRequest<?> request, |
| | | ByteString saslCredentials) throws IOException |
| | | { |
| | |
| | | |
| | | |
| | | |
| | | static void encodeBindRequest(ASN1Writer writer, int messageID, |
| | | public static void encodeBindRequest(ASN1Writer writer, int messageID, |
| | | int version, SimpleBindRequest request) throws IOException |
| | | { |
| | | if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) |
| | |
| | | |
| | | |
| | | |
| | | static void encodeModifyDNRequest(ASN1Writer writer, int messageID, |
| | | public static void encodeModifyDNRequest(ASN1Writer writer, int messageID, |
| | | ModifyDNRequest request) throws IOException |
| | | { |
| | | if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) |
| | |
| | | |
| | | |
| | | |
| | | static void encodeModifyRequest(ASN1Writer writer, int messageID, |
| | | public static void encodeModifyRequest(ASN1Writer writer, int messageID, |
| | | ModifyRequest request) throws IOException |
| | | { |
| | | if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) |
| | |
| | | |
| | | |
| | | |
| | | static void encodeSearchRequest(ASN1Writer writer, int messageID, |
| | | public static void encodeSearchRequest(ASN1Writer writer, int messageID, |
| | | SearchRequest request) throws IOException |
| | | { |
| | | if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) |
| | |
| | | |
| | | |
| | | |
| | | static void encodeUnbindRequest(ASN1Writer writer, int messageID, |
| | | public static void encodeUnbindRequest(ASN1Writer writer, int messageID, |
| | | UnbindRequest request) throws IOException |
| | | { |
| | | if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) |
| | |
| | | |
| | | |
| | | |
| | | static void encodeAddResult(ASN1Writer writer, int messageID, |
| | | public static void encodeAddResult(ASN1Writer writer, int messageID, |
| | | Result result) throws IOException |
| | | { |
| | | if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) |
| | |
| | | |
| | | |
| | | |
| | | static void encodeBindResult(ASN1Writer writer, int messageID, |
| | | public static void encodeBindResult(ASN1Writer writer, int messageID, |
| | | BindResult result) throws IOException |
| | | { |
| | | if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) |
| | |
| | | |
| | | |
| | | |
| | | static void encodeCompareResult(ASN1Writer writer, int messageID, |
| | | public static void encodeCompareResult(ASN1Writer writer, int messageID, |
| | | CompareResult result) throws IOException |
| | | { |
| | | if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) |
| | |
| | | |
| | | |
| | | |
| | | static void encodeDeleteResult(ASN1Writer writer, int messageID, |
| | | public static void encodeDeleteResult(ASN1Writer writer, int messageID, |
| | | Result result) throws IOException |
| | | { |
| | | if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) |
| | |
| | | |
| | | |
| | | |
| | | static void encodeExtendedResult(ASN1Writer writer, int messageID, |
| | | public static void encodeExtendedResult(ASN1Writer writer, int messageID, |
| | | ExtendedResult result) throws IOException |
| | | { |
| | | if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) |
| | |
| | | |
| | | |
| | | |
| | | static void encodeIntermediateResponse(ASN1Writer writer, |
| | | public static void encodeIntermediateResponse(ASN1Writer writer, |
| | | int messageID, IntermediateResponse response) throws IOException |
| | | { |
| | | if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) |
| | |
| | | |
| | | |
| | | |
| | | static void encodeModifyDNResult(ASN1Writer writer, int messageID, |
| | | public static void encodeModifyDNResult(ASN1Writer writer, int messageID, |
| | | Result result) throws IOException |
| | | { |
| | | if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) |
| | |
| | | |
| | | |
| | | |
| | | static void encodeModifyResult(ASN1Writer writer, int messageID, |
| | | public static void encodeModifyResult(ASN1Writer writer, int messageID, |
| | | Result result) throws IOException |
| | | { |
| | | if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) |
| | |
| | | |
| | | |
| | | |
| | | static void encodeSearchResult(ASN1Writer writer, int messageID, |
| | | public static void encodeSearchResult(ASN1Writer writer, int messageID, |
| | | Result result) throws IOException |
| | | { |
| | | if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) |
| | |
| | | |
| | | |
| | | |
| | | static void encodeSearchResultEntry(ASN1Writer writer, int messageID, |
| | | public static void encodeSearchResultEntry(ASN1Writer writer, int messageID, |
| | | SearchResultEntry entry) throws IOException |
| | | { |
| | | if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) |
| | |
| | | |
| | | |
| | | |
| | | static void encodeSearchResultReference(ASN1Writer writer, |
| | | public static void encodeSearchResultReference(ASN1Writer writer, |
| | | int messageID, SearchResultReference reference) |
| | | throws IOException |
| | | { |
| | |
| | | |
| | | |
| | | |
| | | private static void encodeAttribute(ASN1Writer writer, Attribute attribute) |
| | | throws IOException |
| | | { |
| | | writer.writeStartSequence(); |
| | | writer |
| | | .writeOctetString(attribute.getAttributeDescriptionAsString()); |
| | | |
| | | writer.writeStartSet(); |
| | | for (ByteString value : attribute) |
| | | { |
| | | writer.writeOctetString(value); |
| | | } |
| | | writer.writeEndSequence(); |
| | | |
| | | writer.writeEndSequence(); |
| | | } |
| | | |
| | | |
| | | |
| | | private static void encodeChange(ASN1Writer writer, Change change) |
| | | throws IOException |
| | | { |