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