001    /*
002     * Copyright 2011-2015 UnboundID Corp.
003     * All Rights Reserved.
004     */
005    /*
006     * Copyright (C) 2015 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.sdk.unboundidds.extensions;
022    
023    
024    
025    import com.unboundid.ldap.sdk.Control;
026    import com.unboundid.ldap.sdk.ExtendedRequest;
027    import com.unboundid.ldap.sdk.LDAPException;
028    import com.unboundid.ldap.sdk.ResultCode;
029    import com.unboundid.util.NotMutable;
030    import com.unboundid.util.ThreadSafety;
031    import com.unboundid.util.ThreadSafetyLevel;
032    
033    import static com.unboundid.ldap.sdk.unboundidds.extensions.ExtOpMessages.*;
034    
035    
036    
037    /**
038     * <BLOCKQUOTE>
039     *   <B>NOTE:</B>  This class is part of the Commercial Edition of the UnboundID
040     *   LDAP SDK for Java.  It is not available for use in applications that
041     *   include only the Standard Edition of the LDAP SDK, and is not supported for
042     *   use in conjunction with non-UnboundID products.
043     * </BLOCKQUOTE>
044     * This class provides an implementation of the end administrative session
045     * extended request, which indicates that an administrative session created via
046     * with the {@link StartAdministrativeSessionExtendedRequest} should be ended.
047     * <BR><BR>
048     * This extended request has an OID of 1.3.6.1.4.1.30221.2.6.14, and it does not
049     * take a value.
050     * <BR><BR>
051     * See the documentation for the
052     * {@link StartAdministrativeSessionExtendedRequest} for more information about
053     * creating and using administrative sessions.
054     */
055    @NotMutable()
056    @ThreadSafety(level=ThreadSafetyLevel.NOT_THREADSAFE)
057    public final class EndAdministrativeSessionExtendedRequest
058           extends ExtendedRequest
059    {
060      /**
061       * The OID (1.3.6.1.4.1.30221.2.6.14) for the end administrative session
062       * extended request.
063       */
064      public static final String END_ADMIN_SESSION_REQUEST_OID =
065           "1.3.6.1.4.1.30221.2.6.14";
066    
067    
068    
069      /**
070       * The serial version UID for this serializable class.
071       */
072      private static final long serialVersionUID = 1860335278876749499L;
073    
074    
075    
076      /**
077       * Creates a new end administrative session extended request with the provided
078       * information.
079       *
080       * @param  controls  The set of controls to include in the request.
081       */
082      public EndAdministrativeSessionExtendedRequest(final Control... controls)
083      {
084        super(END_ADMIN_SESSION_REQUEST_OID, controls);
085      }
086    
087    
088    
089      /**
090       * Creates a new end administrative session extended request from the provided
091       * generic extended request.
092       *
093       * @param  extendedRequest  The generic extended request to use to create this
094       *                          end administrative session extended request.
095       *
096       * @throws  LDAPException  If a problem occurs while decoding the request.
097       */
098      public EndAdministrativeSessionExtendedRequest(
099                  final ExtendedRequest extendedRequest)
100             throws LDAPException
101      {
102        super(extendedRequest);
103    
104        if (extendedRequest.getValue() != null)
105        {
106          throw new LDAPException(ResultCode.DECODING_ERROR,
107               ERR_END_ADMIN_SESSION_REQUEST_HAS_VALUE.get());
108        }
109      }
110    
111    
112    
113      /**
114       * {@inheritDoc}
115       */
116      @Override()
117      public EndAdministrativeSessionExtendedRequest duplicate()
118      {
119        return duplicate(getControls());
120      }
121    
122    
123    
124      /**
125       * {@inheritDoc}
126       */
127      @Override()
128      public EndAdministrativeSessionExtendedRequest duplicate(
129                  final Control[] controls)
130      {
131        return new EndAdministrativeSessionExtendedRequest(controls);
132      }
133    
134    
135    
136      /**
137       * {@inheritDoc}
138       */
139      @Override()
140      public String getExtendedRequestName()
141      {
142        return INFO_EXTENDED_REQUEST_NAME_END_ADMIN_SESSION.get();
143      }
144    
145    
146    
147      /**
148       * {@inheritDoc}
149       */
150      @Override()
151      public void toString(final StringBuilder buffer)
152      {
153        buffer.append("EndAdministrativeSessionExtendedRequest(");
154    
155        final Control[] controls = getControls();
156        if (controls.length > 0)
157        {
158          buffer.append("controls={");
159          for (int i=0; i < controls.length; i++)
160          {
161            if (i > 0)
162            {
163              buffer.append(", ");
164            }
165    
166            buffer.append(controls[i]);
167          }
168          buffer.append('}');
169        }
170    
171        buffer.append(')');
172      }
173    }