001    /*
002     * CDDL HEADER START
003     *
004     * The contents of this file are subject to the terms of the
005     * Common Development and Distribution License, Version 1.0 only
006     * (the "License").  You may not use this file except in compliance
007     * with the License.
008     *
009     * You can obtain a copy of the license at
010     * trunk/opends/resource/legal-notices/OpenDS.LICENSE
011     * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
012     * See the License for the specific language governing permissions
013     * and limitations under the License.
014     *
015     * When distributing Covered Code, include this CDDL HEADER in each
016     * file and include the License file at
017     * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
018     * add the following below this CDDL HEADER, with the fields enclosed
019     * by brackets "[]" replaced with your own identifying information:
020     *      Portions Copyright [yyyy] [name of copyright owner]
021     *
022     * CDDL HEADER END
023     *
024     *
025     *      Copyright 2006-2008 Sun Microsystems, Inc.
026     */
027    package org.opends.server.types;
028    import org.opends.messages.Message;
029    
030    
031    
032    import static org.opends.messages.CoreMessages.*;
033    
034    
035    
036    /**
037     * This enumeration defines the set of possible reasons for the
038     * closure of a connection between a client and the Directory Server.
039     */
040    @org.opends.server.types.PublicAPI(
041         stability=org.opends.server.types.StabilityLevel.VOLATILE,
042         mayInstantiate=false,
043         mayExtend=false,
044         mayInvoke=true)
045    public enum DisconnectReason
046    {
047      /**
048       * The disconnect reason that indicates that the client connection
049       * was closed because the client unbind from the server.
050       */
051      UNBIND(
052              INFO_DISCONNECT_DUE_TO_UNBIND.get()),
053    
054    
055    
056      /**
057       * The disconnect reason that indicates that the client connection
058       * was closed because the client disconnected without unbinding.
059       */
060      CLIENT_DISCONNECT(
061              INFO_DISCONNECT_DUE_TO_CLIENT_CLOSURE.get()),
062    
063    
064    
065      /**
066       * The disconnect reason that indicates that the client connection
067       * was closed because the client connection was rejected.
068       */
069      CONNECTION_REJECTED(
070              INFO_DISCONNECT_DUE_TO_REJECTED_CLIENT.get()),
071    
072    
073    
074      /**
075       * The disconnect reason that indicates that the client connection
076       * was closed because of an I/O error.
077       */
078      IO_ERROR(
079              INFO_DISCONNECT_DUE_TO_IO_ERROR.get()),
080    
081    
082    
083      /**
084       * The disconnect reason that indicates that the client connection
085       * was closed because of a protocol error.
086       */
087      PROTOCOL_ERROR(
088              INFO_DISCONNECT_DUE_TO_PROTOCOL_ERROR.get()),
089    
090    
091    
092      /**
093       * The disconnect reason that indicates that the client connection
094       * was closed because the Directory Server shut down.
095       */
096      SERVER_SHUTDOWN(
097              INFO_DISCONNECT_DUE_TO_SERVER_SHUTDOWN.get()),
098    
099    
100    
101      /**
102       * The disconnect reason that indicates that the client connection
103       * was closed because an administrator terminated the connection.
104       */
105      ADMIN_DISCONNECT(
106              INFO_DISCONNECT_BY_ADMINISTRATOR.get()),
107    
108    
109    
110      /**
111       * The disconnect reason that indicates that the client connection
112       * was closed because of a security problem.
113       */
114      SECURITY_PROBLEM(
115              INFO_DISCONNECT_DUE_TO_SECURITY_PROBLEM.get()),
116    
117    
118    
119      /**
120       * The disconnect reason that indicates that the client connection
121       * was closed because the maximum allowed request size was exceeded.
122       */
123      MAX_REQUEST_SIZE_EXCEEDED(
124              INFO_DISCONNECT_DUE_TO_MAX_REQUEST_SIZE.get()),
125    
126    
127    
128      /**
129       * The disconnect reason that indicates that the client connection
130       * was closed because an administrative limit was exceeded.
131       */
132      ADMIN_LIMIT_EXCEEDED(
133              INFO_DISCONNECT_DUE_TO_ADMIN_LIMIT.get()),
134    
135    
136    
137      /**
138       * The disconnect reason that indicates that the client connection
139       * was closed because the idle time limit was exceeded.
140       */
141      IDLE_TIME_LIMIT_EXCEEDED(
142              INFO_DISCONNECT_DUE_TO_IDLE_TIME_LIMIT.get()),
143    
144    
145    
146      /**
147       * The disconnect reason that indicates that the client connection
148       * was closed because of an I/O timeout.
149       */
150      IO_TIMEOUT(
151              INFO_DISCONNECT_DUE_TO_IO_TIMEOUT.get()),
152    
153    
154    
155      /**
156       * The disconnect reason that indicates that the client connection
157       * was closed because of an internal error within the server.
158       */
159      SERVER_ERROR(
160              INFO_DISCONNECT_DUE_TO_SERVER_ERROR.get()),
161    
162    
163    
164      /**
165       * The disconnect reason that indicates that the client connection
166       * was closed by a plugin.
167       */
168      CLOSED_BY_PLUGIN(
169              INFO_DISCONNECT_BY_PLUGIN.get()),
170    
171    
172    
173      /**
174       * The disconnect reason that indicates that the client connection
175       * was closed for some other reason.
176       */
177      OTHER(
178              INFO_DISCONNECT_OTHER.get());
179    
180    
181    
182      // The disconnect reason.
183      private Message message;
184    
185    
186      /**
187       * Creates a new disconnect reason element with the provided closure
188       * message.
189       *
190       * @param  message  The message for this disconnect reason.
191       */
192      private DisconnectReason(Message message)
193      {
194        this.message = message;
195      }
196    
197    
198    
199      /**
200       * Retrieves the human-readable disconnect reason.
201       *
202       * @return  The human-readable disconnect reason.
203       */
204      public Message getClosureMessage()
205      {
206        return message;
207      }
208    
209    
210    
211      /**
212       * Retrieves a string representation of this disconnect reason.
213       *
214       * @return  A string representation of this disconnect reason.
215       */
216      public String toString()
217      {
218        return message.toString();
219      }
220    }
221