001/*
002 * Copyright 2011-2024 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright 2011-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) 2011-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.sdk.unboundidds.extensions;
037
038
039
040import com.unboundid.ldap.sdk.Control;
041import com.unboundid.ldap.sdk.ExtendedRequest;
042import com.unboundid.ldap.sdk.LDAPException;
043import com.unboundid.ldap.sdk.ResultCode;
044import com.unboundid.util.NotMutable;
045import com.unboundid.util.NotNull;
046import com.unboundid.util.Nullable;
047import com.unboundid.util.ThreadSafety;
048import com.unboundid.util.ThreadSafetyLevel;
049
050import static com.unboundid.ldap.sdk.unboundidds.extensions.ExtOpMessages.*;
051
052
053
054/**
055 * This class provides an implementation of the end administrative session
056 * extended request, which indicates that an administrative session created via
057 * with the {@link StartAdministrativeSessionExtendedRequest} should be ended.
058 * <BR>
059 * <BLOCKQUOTE>
060 *   <B>NOTE:</B>  This class, and other classes within the
061 *   {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only
062 *   supported for use against Ping Identity, UnboundID, and
063 *   Nokia/Alcatel-Lucent 8661 server products.  These classes provide support
064 *   for proprietary functionality or for external specifications that are not
065 *   considered stable or mature enough to be guaranteed to work in an
066 *   interoperable way with other types of LDAP servers.
067 * </BLOCKQUOTE>
068 * <BR>
069 * This extended request has an OID of 1.3.6.1.4.1.30221.2.6.14, and it does not
070 * take a value.
071 * <BR><BR>
072 * See the documentation for the
073 * {@link StartAdministrativeSessionExtendedRequest} for more information about
074 * creating and using administrative sessions.
075 */
076@NotMutable()
077@ThreadSafety(level=ThreadSafetyLevel.NOT_THREADSAFE)
078public final class EndAdministrativeSessionExtendedRequest
079       extends ExtendedRequest
080{
081  /**
082   * The OID (1.3.6.1.4.1.30221.2.6.14) for the end administrative session
083   * extended request.
084   */
085  @NotNull public static final String END_ADMIN_SESSION_REQUEST_OID =
086       "1.3.6.1.4.1.30221.2.6.14";
087
088
089
090  /**
091   * The serial version UID for this serializable class.
092   */
093  private static final long serialVersionUID = 1860335278876749499L;
094
095
096
097  /**
098   * Creates a new end administrative session extended request with the provided
099   * information.
100   *
101   * @param  controls  The set of controls to include in the request.
102   */
103  public EndAdministrativeSessionExtendedRequest(
104              @Nullable final Control... controls)
105  {
106    super(END_ADMIN_SESSION_REQUEST_OID, controls);
107  }
108
109
110
111  /**
112   * Creates a new end administrative session extended request from the provided
113   * generic extended request.
114   *
115   * @param  extendedRequest  The generic extended request to use to create this
116   *                          end administrative session extended request.
117   *
118   * @throws  LDAPException  If a problem occurs while decoding the request.
119   */
120  public EndAdministrativeSessionExtendedRequest(
121              @NotNull final ExtendedRequest extendedRequest)
122         throws LDAPException
123  {
124    super(extendedRequest);
125
126    if (extendedRequest.getValue() != null)
127    {
128      throw new LDAPException(ResultCode.DECODING_ERROR,
129           ERR_END_ADMIN_SESSION_REQUEST_HAS_VALUE.get());
130    }
131  }
132
133
134
135  /**
136   * {@inheritDoc}
137   */
138  @Override()
139  @NotNull()
140  public EndAdministrativeSessionExtendedRequest duplicate()
141  {
142    return duplicate(getControls());
143  }
144
145
146
147  /**
148   * {@inheritDoc}
149   */
150  @Override()
151  @NotNull()
152  public EndAdministrativeSessionExtendedRequest duplicate(
153              @Nullable final Control[] controls)
154  {
155    final EndAdministrativeSessionExtendedRequest r =
156         new EndAdministrativeSessionExtendedRequest(controls);
157    r.setResponseTimeoutMillis(getResponseTimeoutMillis(null));
158    r.setIntermediateResponseListener(getIntermediateResponseListener());
159    r.setReferralDepth(getReferralDepth());
160    r.setReferralConnector(getReferralConnectorInternal());
161    return r;
162  }
163
164
165
166  /**
167   * {@inheritDoc}
168   */
169  @Override()
170  @NotNull()
171  public String getExtendedRequestName()
172  {
173    return INFO_EXTENDED_REQUEST_NAME_END_ADMIN_SESSION.get();
174  }
175
176
177
178  /**
179   * {@inheritDoc}
180   */
181  @Override()
182  public void toString(@NotNull final StringBuilder buffer)
183  {
184    buffer.append("EndAdministrativeSessionExtendedRequest(");
185
186    final Control[] controls = getControls();
187    if (controls.length > 0)
188    {
189      buffer.append("controls={");
190      for (int i=0; i < controls.length; i++)
191      {
192        if (i > 0)
193        {
194          buffer.append(", ");
195        }
196
197        buffer.append(controls[i]);
198      }
199      buffer.append('}');
200    }
201
202    buffer.append(')');
203  }
204}