001/* 002 * Copyright 2018-2019 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright (C) 2018-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.controls; 022 023 024 025import com.unboundid.ldap.sdk.Control; 026import com.unboundid.ldap.sdk.LDAPException; 027import com.unboundid.ldap.sdk.ResultCode; 028import com.unboundid.util.NotMutable; 029import com.unboundid.util.ThreadSafety; 030import com.unboundid.util.ThreadSafetyLevel; 031 032import static com.unboundid.ldap.sdk.unboundidds.controls.ControlMessages.*; 033 034 035 036/** 037 * This class provides an implementation of a request control that may be 038 * included in a search request to indicate that the server should reject the 039 * request if the server cannot use its defined indexes to identify matching 040 * entries efficiently. This can prevent a requester with the unindexed search 041 * privilege from inadvertently submitting an expensive search request that 042 * could require a long time to complete and potentially consume significant 043 * server resources. This request control has an OID of 044 * "1.3.6.1.4.1.30221.2.5.54", may have a criticality of either true or false, 045 * and does not take a value. 046 * <BR> 047 * <BLOCKQUOTE> 048 * <B>NOTE:</B> This class, and other classes within the 049 * {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only 050 * supported for use against Ping Identity, UnboundID, and 051 * Nokia/Alcatel-Lucent 8661 server products. These classes provide support 052 * for proprietary functionality or for external specifications that are not 053 * considered stable or mature enough to be guaranteed to work in an 054 * interoperable way with other types of LDAP servers. 055 * </BLOCKQUOTE> 056 * 057 * @see PermitUnindexedSearchRequestControl 058 */ 059@NotMutable() 060@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 061public final class RejectUnindexedSearchRequestControl 062 extends Control 063{ 064 /** 065 * The OID (1.3.6.1.4.1.30221.2.5.54) for the reject unindexed search request 066 * control. 067 */ 068 public static final String REJECT_UNINDEXED_SEARCH_REQUEST_OID = 069 "1.3.6.1.4.1.30221.2.5.54"; 070 071 072 073 /** 074 * The serial version UID for this serializable class. 075 */ 076 private static final long serialVersionUID = 6331056590003014623L; 077 078 079 080 /** 081 * Creates a new reject unindexed search request control with a criticality of 082 * {@code true}. 083 */ 084 public RejectUnindexedSearchRequestControl() 085 { 086 this(true); 087 } 088 089 090 091 /** 092 * Creates a new reject unindexed search request control with the specified 093 * criticality. 094 * 095 * @param isCritical Indicates whether the control should be considered 096 * critical. 097 */ 098 public RejectUnindexedSearchRequestControl(final boolean isCritical) 099 { 100 super(REJECT_UNINDEXED_SEARCH_REQUEST_OID, isCritical); 101 } 102 103 104 105 /** 106 * Creates a new reject unindexed search request control that is decoded from 107 * the provided generic control. 108 * 109 * @param control The generic control to be decoded as a reject unindexed 110 * search request control. 111 * 112 * @throws LDAPException If the provided control cannot be decoded as a 113 * reject unindexed search request control. 114 */ 115 public RejectUnindexedSearchRequestControl(final Control control) 116 throws LDAPException 117 { 118 super(control); 119 120 if (control.hasValue()) 121 { 122 throw new LDAPException(ResultCode.DECODING_ERROR, 123 ERR_REJECT_UNINDEXED_SEARCH_REQUEST_HAS_VALUE.get()); 124 } 125 } 126 127 128 129 /** 130 * {@inheritDoc} 131 */ 132 @Override() 133 public String getControlName() 134 { 135 return INFO_CONTROL_NAME_REJECT_UNINDEXED_SEARCH_REQUEST.get(); 136 } 137 138 139 140 /** 141 * {@inheritDoc} 142 */ 143 @Override() 144 public void toString(final StringBuilder buffer) 145 { 146 buffer.append("RejectUnindexedSearchRequestControl(isCritical="); 147 buffer.append(isCritical()); 148 buffer.append(')'); 149 } 150}