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