001/* 002 * Copyright 2008-2024 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright 2008-2024 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-2024 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.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.controls.ControlMessages.*; 049 050 051 052/** 053 * NOTE: This class has been deprecated because there are two competing 054 * specifications that can affect the visibility of entries with the 055 * ldapSubEntry object class: 056 * <A HREF="https://docs.ldap.com/specs/rfc3672.txt">RFC 3672</A> and 057 * <A HREF="https://docs.ldap.com/specs/draft-ietf-ldup-subentry-08.txt"> 058 * draft-ietf-ldup-subentry</A>. This class implements support for the latter 059 * and remains fully functional, but you should use either the 060 * {@link RFC3672SubentriesRequestControl} class or the 061 * {@link DraftLDUPSubentriesRequestControl} class to avoid ambiguity. 062 * <BR><BR> 063 * This class provides an implementation of the LDAP subentries request control 064 * as defined in draft-ietf-ldup-subentry. It may be included in a search 065 * request to indicate that the entries with the {@code ldapSubentry} object 066 * class should be included in the search results. 067 * <BR><BR> 068 * Entries containing the {@code ldapSubentry} object class are special in that 069 * they are normally excluded from search results, unless the target entry is 070 * requested with a base-level search. They are used to store operational 071 * information that controls how the server should behave rather than user data. 072 * Because they do not hold user data, it is generally desirable to have them 073 * excluded from search results, but for cases in which a client needs to 074 * retrieve such an entry, then this subentries request control may be included 075 * in the search request. 076 * <BR><BR> 077 * There is no corresponding response control. 078 * <BR><BR> 079 * <H2>Example</H2> 080 * The following example illustrates the use of the subentries request control 081 * to retrieve subentries that may not otherwise be returned. 082 * <PRE> 083 * // First, perform a search to retrieve an entry with a cn of "test subentry" 084 * // but without including the subentries request control. This should not 085 * // return any matching entries. 086 * SearchRequest searchRequest = new SearchRequest("dc=example,dc=com", 087 * SearchScope.SUB, Filter.createEqualityFilter("cn", "test subentry")); 088 * SearchResult resultWithoutControl = connection.search(searchRequest); 089 * LDAPTestUtils.assertResultCodeEquals(resultWithoutControl, 090 * ResultCode.SUCCESS); 091 * LDAPTestUtils.assertEntriesReturnedEquals(resultWithoutControl, 0); 092 * 093 * // Update the search request to add a subentries request control so that 094 * // subentries should be included in search results. This should cause the 095 * // subentry to be returned. 096 * searchRequest.addControl(new SubentriesRequestControl()); 097 * SearchResult resultWithControl = connection.search(searchRequest); 098 * LDAPTestUtils.assertResultCodeEquals(resultWithControl, ResultCode.SUCCESS); 099 * LDAPTestUtils.assertEntriesReturnedEquals(resultWithControl, 1); 100 * </PRE> 101 * 102 * @deprecated This class has been deprecated because there are two competing 103 * specifications that can affect the visibility of entries with the 104 * ldapSubEntry object class: RFC 3672 and 105 * draft-ietf-lddup-subentry. This class implements support for the 106 * latter and remains fully functional, but you should use either 107 * the {@link RFC3672SubentriesRequestControl} class or the 108 * {@link DraftLDUPSubentriesRequestControl} class to avoid 109 * ambiguity. 110 */ 111@Deprecated() 112@NotMutable() 113@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 114public final class SubentriesRequestControl 115 extends Control 116{ 117 /** 118 * The OID (1.3.6.1.4.1.7628.5.101.1) for the LDAP subentries request control. 119 */ 120 @NotNull public static final String SUBENTRIES_REQUEST_OID = 121 "1.3.6.1.4.1.7628.5.101.1"; 122 123 124 125 /** 126 * The serial version UID for this serializable class. 127 */ 128 private static final long serialVersionUID = 4772130172594841481L; 129 130 131 132 /** 133 * Creates a new subentries request control. it will not be marked critical. 134 */ 135 public SubentriesRequestControl() 136 { 137 this(false); 138 } 139 140 141 142 /** 143 * Creates a new subentries request control with the specified criticality. 144 * 145 * @param isCritical Indicates whether this control should be marked 146 * critical. 147 */ 148 public SubentriesRequestControl(final boolean isCritical) 149 { 150 super(SUBENTRIES_REQUEST_OID, isCritical, null); 151 } 152 153 154 155 /** 156 * Creates a new subentries request control which is decoded from the provided 157 * generic control. 158 * 159 * @param control The generic control to be decoded as a subentries request 160 * control. 161 * 162 * @throws LDAPException If the provided control cannot be decoded as a 163 * subentries request control. 164 */ 165 public SubentriesRequestControl(@NotNull final Control control) 166 throws LDAPException 167 { 168 super(control); 169 170 if (control.hasValue()) 171 { 172 throw new LDAPException(ResultCode.DECODING_ERROR, 173 ERR_SUBENTRIES_HAS_VALUE.get()); 174 } 175 } 176 177 178 179 /** 180 * {@inheritDoc} 181 */ 182 @Override() 183 @NotNull() 184 public String getControlName() 185 { 186 return INFO_CONTROL_NAME_SUBENTRIES_REQUEST.get(); 187 } 188 189 190 191 /** 192 * {@inheritDoc} 193 */ 194 @Override() 195 public void toString(@NotNull final StringBuilder buffer) 196 { 197 buffer.append("SubentriesRequestControl(isCritical="); 198 buffer.append(isCritical()); 199 buffer.append(')'); 200 } 201}