001/* 002 * Copyright 2008-2022 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright 2008-2022 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) 2008-2022 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.controls; 037 038 039 040import com.unboundid.ldap.sdk.Control; 041import com.unboundid.ldap.sdk.LDAPException; 042import com.unboundid.ldap.sdk.ResultCode; 043import com.unboundid.util.NotMutable; 044import com.unboundid.util.NotNull; 045import com.unboundid.util.ThreadSafety; 046import com.unboundid.util.ThreadSafetyLevel; 047 048import static com.unboundid.ldap.sdk.unboundidds.controls.ControlMessages.*; 049 050 051 052/** 053 * This class provides an implementation of a control which can be used to 054 * request that the Directory Server include extended information when returning 055 * a subschema subentry. In the Ping Identity, UnboundID, and 056 * Nokia/Alcatel-Lucent 8661 Directory Server, this will cause the server to 057 * include the X-SCHEMA-FILE extension (which contains the path to the file in 058 * which that schema element is defined) and the X-READ-ONLY extension (which 059 * indicates whether that schema element is read-only and cannot be altered by 060 * external clients). 061 * <BR> 062 * <BLOCKQUOTE> 063 * <B>NOTE:</B> This class, and other classes within the 064 * {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only 065 * supported for use against Ping Identity, UnboundID, and 066 * Nokia/Alcatel-Lucent 8661 server products. These classes provide support 067 * for proprietary functionality or for external specifications that are not 068 * considered stable or mature enough to be guaranteed to work in an 069 * interoperable way with other types of LDAP servers. 070 * </BLOCKQUOTE> 071 * <BR> 072 * This control is not based on any public specification, and has been defined 073 * by Ping Identity Corporation It does not have a value, and may or may not be 074 * critical. It should only be included in search requests. 075 * <BR><BR> 076 * <H2>Example</H2> 077 * The following example demonstrates the procedure to use for requesting the 078 * Directory Server schema with extended information. Note that the 079 * {@code LDAPInterface.getSchema} and {@code Schema.getSchema} convenience 080 * methods cannot be used because they do not allow you to include controls in 081 * the request. 082 * <PRE> 083 * String schemaDN = Schema.getSubschemaSubentryDN(connection, ""); 084 * SearchRequest searchRequest = new SearchRequest(schemaDN, SearchScope.BASE, 085 * Filter.createPresenceFilter("objectClass"), "*", "+"); 086 * searchRequest.addControl(new ExtendedSchemaInfoRequestControl()); 087 * SearchResult searchResult = connection.search(searchRequest); 088 * 089 * Schema schema = null; 090 * if (searchResult.getEntryCount() == 1) 091 * { 092 * schema = new Schema(searchResult.getSearchEntries().get(0)); 093 * } 094 * </PRE> 095 */ 096@NotMutable() 097@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 098public final class ExtendedSchemaInfoRequestControl 099 extends Control 100{ 101 /** 102 * The OID (1.3.6.1.4.1.30221.2.5.12) for the extended schema info request 103 * control. 104 */ 105 @NotNull public static final String EXTENDED_SCHEMA_INFO_REQUEST_OID = 106 "1.3.6.1.4.1.30221.2.5.12"; 107 108 109 /** 110 * The serial version UID for this serializable class. 111 */ 112 private static final long serialVersionUID = -5668945270252160026L; 113 114 115 116 /** 117 * Creates a new extended schema info request control. It will not be 118 * marked critical. 119 */ 120 public ExtendedSchemaInfoRequestControl() 121 { 122 this(false); 123 } 124 125 126 127 /** 128 * Creates a new extended schema info request control with the specified 129 * criticality. 130 * 131 * @param isCritical Indicates whether this control should be marked 132 * critical. 133 */ 134 public ExtendedSchemaInfoRequestControl(final boolean isCritical) 135 { 136 super(EXTENDED_SCHEMA_INFO_REQUEST_OID, isCritical, null); 137 } 138 139 140 141 /** 142 * Creates a new extended schema info request control which is decoded from 143 * the provided generic control. 144 * 145 * @param control The generic control to be decoded as an extended schema 146 * info request control. 147 * 148 * @throws LDAPException If the provided control cannot be decoded as an 149 * extended schema info request control. 150 */ 151 public ExtendedSchemaInfoRequestControl(@NotNull final Control control) 152 throws LDAPException 153 { 154 super(control); 155 156 if (control.hasValue()) 157 { 158 throw new LDAPException(ResultCode.DECODING_ERROR, 159 ERR_EXTENDED_SCHEMA_INFO_REQUEST_HAS_VALUE.get()); 160 } 161 } 162 163 164 165 /** 166 * {@inheritDoc} 167 */ 168 @Override() 169 @NotNull() 170 public String getControlName() 171 { 172 return INFO_CONTROL_NAME_EXTENDED_SCHEMA_INFO.get(); 173 } 174 175 176 177 /** 178 * {@inheritDoc} 179 */ 180 @Override() 181 public void toString(@NotNull final StringBuilder buffer) 182 { 183 buffer.append("ExtendedSchemaInfoRequestControl(isCritical="); 184 buffer.append(isCritical()); 185 buffer.append(')'); 186 } 187}