001/* 002 * Copyright 2011-2024 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright 2011-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) 2011-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 * This class provides an implementation of the LDAP don't use copy control as 054 * defined in <A HREF="http://www.rfc-editor.org/rfc/rfc6171.txt">RFC 6171</A>. 055 * This control may be used to request that only an authoritative directory 056 * server be used to process the associated search or compare request, and that 057 * the request should not be processed on a directory that may contain data 058 * that is cached or potentially stale. If the client includes this control in 059 * a request sent to a non-authoritative server, then that server may send a 060 * referral to the authoritative server, or it may simply reject the request. 061 */ 062@NotMutable() 063@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 064public final class DontUseCopyRequestControl 065 extends Control 066{ 067 /** 068 * The OID (1.3.6.1.1.22) for the don't use copy request control. 069 */ 070 @NotNull public static final String DONT_USE_COPY_REQUEST_OID = 071 "1.3.6.1.1.22"; 072 073 074 075 /** 076 * The serial version UID for this serializable class. 077 */ 078 private static final long serialVersionUID = -5352797941017941217L; 079 080 081 082 /** 083 * Creates a new don't use copy request control. The control will be marked 084 * critical. 085 */ 086 public DontUseCopyRequestControl() 087 { 088 super(DONT_USE_COPY_REQUEST_OID, true, null); 089 } 090 091 092 093 /** 094 * Creates a new don't use copy request control which is decoded from the 095 * provided generic control. 096 * 097 * @param control The generic control to be decoded as a don't use copy 098 * request control. 099 * 100 * @throws LDAPException If the provided control cannot be decoded as a 101 * don't use copy request control. 102 */ 103 public DontUseCopyRequestControl(@NotNull final Control control) 104 throws LDAPException 105 { 106 super(control); 107 108 if (control.hasValue()) 109 { 110 throw new LDAPException(ResultCode.DECODING_ERROR, 111 ERR_DONT_USE_COPY_HAS_VALUE.get()); 112 } 113 } 114 115 116 117 /** 118 * {@inheritDoc} 119 */ 120 @Override() 121 @NotNull() 122 public String getControlName() 123 { 124 return INFO_CONTROL_NAME_DONT_USE_COPY.get(); 125 } 126 127 128 129 /** 130 * {@inheritDoc} 131 */ 132 @Override() 133 public void toString(@NotNull final StringBuilder buffer) 134 { 135 buffer.append("DontUseCopyRequestControl(isCritical="); 136 buffer.append(isCritical()); 137 buffer.append(')'); 138 } 139}