001/* 002 * Copyright 2014-2024 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright 2014-2024 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-2024 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.Entry; 041import com.unboundid.ldap.sdk.IntermediateResponse; 042import com.unboundid.ldap.sdk.LDAPException; 043import com.unboundid.ldap.sdk.LDAPResult; 044import com.unboundid.ldap.sdk.ReadOnlySearchRequest; 045import com.unboundid.ldap.sdk.SearchResultReference; 046import com.unboundid.util.NotExtensible; 047import com.unboundid.util.NotNull; 048import com.unboundid.util.Nullable; 049import com.unboundid.util.ThreadSafety; 050import com.unboundid.util.ThreadSafetyLevel; 051 052 053 054/** 055 * This class provides an API that can be used in the course of processing a 056 * search request via the {@link InMemoryOperationInterceptor} API. 057 */ 058@NotExtensible() 059@ThreadSafety(level=ThreadSafetyLevel.INTERFACE_NOT_THREADSAFE) 060public interface InMemoryInterceptedSearchResult 061 extends InMemoryInterceptedResult 062{ 063 /** 064 * Retrieves the search request that was processed. If the request was 065 * altered between the time it was received from the client and the time it 066 * was actually processed by the in-memory directory server, then this will be 067 * the most recently altered version. 068 * 069 * @return The search request that was processed. 070 */ 071 @NotNull() 072 ReadOnlySearchRequest getRequest(); 073 074 075 076 /** 077 * Retrieves the search result to be returned to the client. 078 * 079 * @return The search result to be returned to the client. 080 */ 081 @Nullable() 082 LDAPResult getResult(); 083 084 085 086 /** 087 * Replaces the search result to be returned to the client. 088 * 089 * @param searchResult The search result that should be returned to the 090 * client instead of the result originally generated by 091 * the in-memory directory server. It must not be 092 * {@code null}. 093 */ 094 void setResult(@NotNull LDAPResult searchResult); 095 096 097 098 /** 099 * Sends the provided search result entry to the client. It will be processed 100 * by the {@link InMemoryOperationInterceptor#processSearchEntry} method of 101 * all registered operation interceptors. 102 * 103 * @param entry The search result entry to be returned to the client. It 104 * must not be {@code null}. If the provided entry is a 105 * {@code SearchResultEntry}, then it may optionally include 106 * one or more controls to provide to the client. If it is any 107 * other type of {@code Entry}, then it will not include any 108 * controls. 109 * 110 * @throws LDAPException If a problem is encountered while trying to send 111 * the search result entry. 112 */ 113 void sendSearchEntry(@NotNull Entry entry) 114 throws LDAPException; 115 116 117 118 /** 119 * Sends the provided search result reference to the client. It will be 120 * processed by the 121 * {@link InMemoryOperationInterceptor#processSearchReference} method of all 122 * registered operation interceptors. 123 * 124 * @param reference The search result reference to be returned to the 125 * client. It must not be {@code null}. 126 * 127 * @throws LDAPException If a problem is encountered while trying to send 128 * the search result reference. 129 */ 130 void sendSearchReference(@NotNull SearchResultReference reference) 131 throws LDAPException; 132 133 134 135 /** 136 * Sends the provided intermediate response message to the client. It will 137 * be processed by the 138 * {@link InMemoryOperationInterceptor#processIntermediateResponse} method of 139 * all registered operation interceptors. 140 * 141 * @param intermediateResponse The intermediate response to send to the 142 * client. It must not be {@code null}. 143 * 144 * @throws LDAPException If a problem is encountered while trying to send 145 * the intermediate response. 146 */ 147 void sendIntermediateResponse( 148 @NotNull IntermediateResponse intermediateResponse) 149 throws LDAPException; 150}