001    /*
002     * Copyright 2014-2016 UnboundID Corp.
003     * All Rights Reserved.
004     */
005    /*
006     * Copyright (C) 2014-2016 UnboundID Corp.
007     *
008     * This program is free software; you can redistribute it and/or modify
009     * it under the terms of the GNU General Public License (GPLv2 only)
010     * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
011     * as published by the Free Software Foundation.
012     *
013     * This program is distributed in the hope that it will be useful,
014     * but WITHOUT ANY WARRANTY; without even the implied warranty of
015     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016     * GNU General Public License for more details.
017     *
018     * You should have received a copy of the GNU General Public License
019     * along with this program; if not, see <http://www.gnu.org/licenses>.
020     */
021    package com.unboundid.ldap.listener.interceptor;
022    
023    
024    
025    import com.unboundid.ldap.sdk.ExtendedResult;
026    import com.unboundid.ldap.sdk.IntermediateResponse;
027    import com.unboundid.ldap.sdk.LDAPException;
028    import com.unboundid.util.NotExtensible;
029    import com.unboundid.util.ThreadSafety;
030    import com.unboundid.util.ThreadSafetyLevel;
031    
032    
033    
034    /**
035     * This class provides an API that can be used in the course of processing a
036     * request via the {@link InMemoryOperationInterceptor} API.
037     */
038    @NotExtensible()
039    @ThreadSafety(level=ThreadSafetyLevel.INTERFACE_NOT_THREADSAFE)
040    public interface InMemoryInterceptedRequest
041    {
042      /**
043       * Retrieves the connection ID for the associated client connection.
044       *
045       * @return  The connection ID for the associated client connection.
046       */
047      long getConnectionID();
048    
049    
050    
051      /**
052       * Retrieves the server address to which the client is connected, if
053       * available.
054       *
055       * @return  The server address to which the client is connected, or
056       *          {@code null} if this is not available for some reason.
057       */
058      String getConnectedAddress();
059    
060    
061    
062      /**
063       * Retrieves the server port to which the client is connected, if available.
064       *
065       * @return  The server port to which the client is connected, or -1 if this is
066       *          not available for some reason.
067       */
068      int getConnectedPort();
069    
070    
071    
072      /**
073       * Retrieves the LDAP message ID for this operation.
074       *
075       * @return  The LDAP message ID for this operation.
076       */
077      int getMessageID();
078    
079    
080    
081      /**
082       * Sends the provided intermediate response message to the client.  It will
083       * be processed by the
084       * {@link InMemoryOperationInterceptor#processIntermediateResponse} method of
085       * all registered operation interceptors.
086       *
087       * @param  intermediateResponse  The intermediate response to send to the
088       *                               client.  It must not be {@code null}.
089       *
090       * @throws  LDAPException  If a problem is encountered while trying to send
091       *                         the intermediate response.
092       */
093      void sendIntermediateResponse(final IntermediateResponse intermediateResponse)
094           throws LDAPException;
095    
096    
097    
098      /**
099       * Sends an unsolicited notification message to the client.
100       *
101       * @param  unsolicitedNotification  The unsolicited notification to send to
102       *                                  the client.  It must not be {@code null}.
103       *
104       * @throws  LDAPException  If a problem is encountered while trying to send
105       *                         the unsolicited notification.
106       */
107      void sendUnsolicitedNotification(final ExtendedResult unsolicitedNotification)
108           throws LDAPException;
109    
110    
111    
112      /**
113       * Retrieves the value for a property that has previously been set for this
114       * operation.  This can be used to help maintain state information across the
115       * request and response for an operation.
116       *
117       * @param  name  The name of the property for which to retrieve the
118       *               corresponding value.  It must not be {@code null}.
119       *
120       * @return  The value for the requested property, or {@code null} if there is
121       *          no value for the specified property.
122       */
123      Object getProperty(final String name);
124    
125    
126    
127      /**
128       * Sets the value for a property that may be used to help maintain state
129       * information across the request and response for an operation.
130       *
131       * @param  name   The name of the property to set.  It must not be
132       *                {@code null}.
133       * @param  value  The value to use for the property.  If it is {@code null},
134       *                then any value previously set will be removed.
135       *
136       * @return  The value held for the property before this method was invoked, or
137       *          {@code null} if it did not previously have a value.
138       */
139      Object setProperty(final String name, final Object value);
140    }