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