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