001/*
002 * Copyright 2014-2022 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright 2014-2022 Ping Identity Corporation
007 *
008 * Licensed under the Apache License, Version 2.0 (the "License");
009 * you may not use this file except in compliance with the License.
010 * You may obtain a copy of the License at
011 *
012 *    http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing, software
015 * distributed under the License is distributed on an "AS IS" BASIS,
016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017 * See the License for the specific language governing permissions and
018 * limitations under the License.
019 */
020/*
021 * Copyright (C) 2014-2022 Ping Identity Corporation
022 *
023 * This program is free software; you can redistribute it and/or modify
024 * it under the terms of the GNU General Public License (GPLv2 only)
025 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
026 * as published by the Free Software Foundation.
027 *
028 * This program is distributed in the hope that it will be useful,
029 * but WITHOUT ANY WARRANTY; without even the implied warranty of
030 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
031 * GNU General Public License for more details.
032 *
033 * You should have received a copy of the GNU General Public License
034 * along with this program; if not, see <http://www.gnu.org/licenses>.
035 */
036package com.unboundid.ldap.listener.interceptor;
037
038
039
040import com.unboundid.ldap.sdk.LDAPException;
041
042import com.unboundid.util.Extensible;
043import com.unboundid.util.NotNull;
044import com.unboundid.util.ThreadSafety;
045import com.unboundid.util.ThreadSafetyLevel;
046
047
048
049/**
050 * This class defines an API that may be used to intercept and potentially alter
051 * communication between an LDAP client and the in-memory directory server.  An
052 * operation interceptor may be enabled for use with the in-memory directory
053 * server by registering it with the
054 * {@link com.unboundid.ldap.listener.InMemoryDirectoryServerConfig}.  The
055 * default implementation of all methods defined in this class is to return the
056 * provided request or result without altering it in any way.
057 * <BR><BR>
058 * Note that any operation interceptors configured for use will be invoked only
059 * for requests received via LDAP.  Operations processed via method calls made
060 * directly to the {@link com.unboundid.ldap.listener.InMemoryDirectoryServer}
061 * class via the {@link com.unboundid.ldap.sdk.LDAPInterface} interface will not
062 * cause any operation interceptors to be invoked.
063 */
064@Extensible()
065@ThreadSafety(level=ThreadSafetyLevel.INTERFACE_THREADSAFE)
066public abstract class InMemoryOperationInterceptor
067{
068  /**
069   * Invokes any processing that should be performed for the provided add
070   * request before it is passed to the in-memory directory server.
071   *
072   * @param  request  Information about the request that was received from the
073   *                  client.
074   *
075   * @throws  LDAPException  If the provided operation should not be passed onto
076   *                         the in-memory directory server, but the result
077   *                         represented by this exception should be used
078   *                         instead.
079   */
080  public void processAddRequest(
081                   @NotNull final InMemoryInterceptedAddRequest request)
082         throws LDAPException
083  {
084    // No processing will be performed by default.
085  }
086
087
088
089  /**
090   * Invokes any processing that should be performed for the provided add result
091   * before it is returned to the client.
092   *
093   * @param  result  Information about the add result that is to be returned to
094   *                 the client.
095   */
096  public void processAddResult(
097                   @NotNull final InMemoryInterceptedAddResult result)
098  {
099    // No processing will be performed by default.
100  }
101
102
103
104  /**
105   * Invokes any processing that should be performed for the provided simple
106   * bind request before it is passed to the in-memory directory server.
107   *
108   * @param  request  Information about the request that was received from the
109   *                  client.
110   *
111   * @throws  LDAPException  If the provided operation should not be passed onto
112   *                         the in-memory directory server, but the result
113   *                         represented by this exception should be used
114   *                         instead.
115   */
116  public void processSimpleBindRequest(
117                   @NotNull final InMemoryInterceptedSimpleBindRequest request)
118         throws LDAPException
119  {
120    // No processing will be performed by default.
121  }
122
123
124
125  /**
126   * Invokes any processing that should be performed for the provided simple
127   * bind result before it is returned to the client.
128   *
129   * @param  result  Information about the bind result that is to be returned to
130   *                 the client.
131   */
132  public void processSimpleBindResult(
133                   @NotNull final InMemoryInterceptedSimpleBindResult result)
134  {
135    // No processing will be performed by default.
136  }
137
138
139
140  /**
141   * Invokes any processing that should be performed for the provided SASL bind
142   * request before it is passed to the in-memory directory server.
143   *
144   * @param  request  Information about the request that was received from the
145   *                  client.
146   *
147   * @throws  LDAPException  If the provided operation should not be passed onto
148   *                         the in-memory directory server, but the result
149   *                         represented by this exception should be used
150   *                         instead.
151   */
152  public void processSASLBindRequest(
153                   @NotNull final InMemoryInterceptedSASLBindRequest request)
154         throws LDAPException
155  {
156    // No processing will be performed by default.
157  }
158
159
160
161  /**
162   * Invokes any processing that should be performed for the provided SASL bind
163   * result before it is returned to the client.
164   *
165   * @param  result  Information about the bind result that is to be returned to
166   *                 the client.
167   */
168  public void processSASLBindResult(
169                   @NotNull final InMemoryInterceptedSASLBindResult result)
170  {
171    // No processing will be performed by default.
172  }
173
174
175
176  /**
177   * Invokes any processing that should be performed for the provided compare
178   * request before it is passed to the in-memory directory server.
179   *
180   * @param  request  Information about the request that was received from the
181   *                  client.
182   *
183   * @throws  LDAPException  If the provided operation should not be passed onto
184   *                         the in-memory directory server, but the result
185   *                         represented by this exception should be used
186   *                         instead.
187   */
188  public void processCompareRequest(
189                   @NotNull final InMemoryInterceptedCompareRequest request)
190         throws LDAPException
191  {
192    // No processing will be performed by default.
193  }
194
195
196
197  /**
198   * Invokes any processing that should be performed for the provided compare
199   * result before it is returned to the client.
200   *
201   * @param  result  Information about the compare result that is to be returned
202   *                 to the client.
203   */
204  public void processCompareResult(
205                   @NotNull final InMemoryInterceptedCompareResult result)
206  {
207    // No processing will be performed by default.
208  }
209
210
211
212  /**
213   * Invokes any processing that should be performed for the provided delete
214   * request before it is passed to the in-memory directory server.
215   *
216   * @param  request  Information about the request that was received from the
217   *                  client.
218   *
219   * @throws  LDAPException  If the provided operation should not be passed onto
220   *                         the in-memory directory server, but the result
221   *                         represented by this exception should be used
222   *                         instead.
223   */
224  public void processDeleteRequest(
225                   @NotNull final InMemoryInterceptedDeleteRequest request)
226         throws LDAPException
227  {
228    // No processing will be performed by default.
229  }
230
231
232
233  /**
234   * Invokes any processing that should be performed for the provided delete
235   * result before it is returned to the client.
236   *
237   * @param  result  Information about the delete result that is to be returned
238   *                 to the client.
239   */
240  public void processDeleteResult(
241                   @NotNull final InMemoryInterceptedDeleteResult result)
242  {
243    // No processing will be performed by default.
244  }
245
246
247
248  /**
249   * Invokes any processing that should be performed for the provided extended
250   * request before it is passed to the in-memory directory server.
251   *
252   * @param  request  Information about the request that was received from the
253   *                  client.
254   *
255   * @throws  LDAPException  If the provided operation should not be passed onto
256   *                         the in-memory directory server, but the result
257   *                         represented by this exception should be used
258   *                         instead.
259   */
260  public void processExtendedRequest(
261                   @NotNull final InMemoryInterceptedExtendedRequest request)
262         throws LDAPException
263  {
264    // No processing will be performed by default.
265  }
266
267
268
269  /**
270   * Invokes any processing that should be performed for the provided extended
271   * result before it is returned to the client.
272   *
273   * @param  result  Information about the extended result that is to be
274   *                 returned to the client.
275   */
276  public void processExtendedResult(
277                   @NotNull final InMemoryInterceptedExtendedResult result)
278  {
279    // No processing will be performed by default.
280  }
281
282
283
284  /**
285   * Invokes any processing that should be performed for the provided modify
286   * request before it is passed to the in-memory directory server.
287   *
288   * @param  request  Information about the request that was received from the
289   *                  client.
290   *
291   * @throws  LDAPException  If the provided operation should not be passed onto
292   *                         the in-memory directory server, but the result
293   *                         represented by this exception should be used
294   *                         instead.
295   */
296  public void processModifyRequest(
297                   @NotNull final InMemoryInterceptedModifyRequest request)
298         throws LDAPException
299  {
300    // No processing will be performed by default.
301  }
302
303
304
305  /**
306   * Invokes any processing that should be performed for the provided modify
307   * result before it is returned to the client.
308   *
309   * @param  result  Information about the modify result that is to be returned
310   *                 to the client.
311   */
312  public void processModifyResult(
313                   @NotNull final InMemoryInterceptedModifyResult result)
314  {
315    // No processing will be performed by default.
316  }
317
318
319
320  /**
321   * Invokes any processing that should be performed for the provided modify DN
322   * request before it is passed to the in-memory directory server.
323   *
324   * @param  request  Information about the request that was received from the
325   *                  client.
326   *
327   * @throws  LDAPException  If the provided operation should not be passed onto
328   *                         the in-memory directory server, but the result
329   *                         represented by this exception should be used
330   *                         instead.
331   */
332  public void processModifyDNRequest(
333                   @NotNull final InMemoryInterceptedModifyDNRequest request)
334         throws LDAPException
335  {
336    // No processing will be performed by default.
337  }
338
339
340
341  /**
342   * Invokes any processing that should be performed for the provided modify DN
343   * result before it is returned to the client.
344   *
345   * @param  result  Information about the modify DN result that is to be
346   *                 returned to the client.
347   */
348  public void processModifyDNResult(
349                   @NotNull final InMemoryInterceptedModifyDNResult result)
350  {
351    // No processing will be performed by default.
352  }
353
354
355
356  /**
357   * Invokes any processing that should be performed for the provided search
358   * request before it is passed to the in-memory directory server.
359   *
360   * @param  request  Information about the request that was received from the
361   *                  client.
362   *
363   * @throws  LDAPException  If the provided operation should not be passed onto
364   *                         the in-memory directory server, but the result
365   *                         represented by this exception should be used
366   *                         instead.
367   */
368  public void processSearchRequest(
369                   @NotNull final InMemoryInterceptedSearchRequest request)
370         throws LDAPException
371  {
372    // No processing will be performed by default.
373  }
374
375
376
377  /**
378   * Invokes any processing that should be performed for the provided search
379   * result entry before it is returned to the client.
380   *
381   * @param  entry  Information about the search result entry to be returned.
382   */
383  public void processSearchEntry(
384                   @NotNull final InMemoryInterceptedSearchEntry entry)
385  {
386    // No processing will be performed by default.
387  }
388
389
390
391  /**
392   * Invokes any processing that should be performed for the provided search
393   * result reference before it is returned to the client.
394   *
395   * @param  reference  Information about the search result reference to be
396   *                    returned.
397   */
398  public void processSearchReference(
399                   @NotNull final InMemoryInterceptedSearchReference reference)
400  {
401    // No processing will be performed by default.
402  }
403
404
405
406  /**
407   * Invokes any processing that should be performed for the provided search
408   * result before it is returned to the client.
409   *
410   * @param  result  Information about the search result that is to be returned
411   *                 to the client.
412   */
413  public void processSearchResult(
414                   @NotNull final InMemoryInterceptedSearchResult result)
415  {
416    // No processing will be performed by default.
417  }
418
419
420
421  /**
422   * Invokes any processing that should be performed for the provided
423   * intermediate response before it is returned to the client.
424   *
425   * @param  response  Information about the intermediate response to be
426   *                   returned to the client.
427   */
428  public void processIntermediateResponse(
429       @NotNull final InMemoryInterceptedIntermediateResponse response)
430  {
431    // No processing will be performed by default.
432  }
433}