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