001/*
002 * Copyright 2015-2022 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright 2015-2022 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) 2015-2022 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.unboundidds.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.unboundidds.controls.ControlMessages.*;
049
050
051
052/**
053 * This class provides an implementation of the name with entryUUID request
054 * control.  It may be included in an add request to indicate that the server
055 * should replace the provided RDN with the server-generated entryUUID value.
056 * It will also cause the server to include a
057 * {@link com.unboundid.ldap.sdk.controls.PostReadResponseControl} in
058 * the add result to make the generated DN available to the client.  If the
059 * request already includes a
060 * {@link com.unboundid.ldap.sdk.controls.PostReadRequestControl}, then the
061 * attributes included in the post-read response control will be generated from
062 * that request control.  Otherwise, the server will behave as if the request
063 * had included a post-read request control requesting only the entryUUID
064 * attribute.
065 * <BR>
066 * <BLOCKQUOTE>
067 *   <B>NOTE:</B>  This class, and other classes within the
068 *   {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only
069 *   supported for use against Ping Identity, UnboundID, and
070 *   Nokia/Alcatel-Lucent 8661 server products.  These classes provide support
071 *   for proprietary functionality or for external specifications that are not
072 *   considered stable or mature enough to be guaranteed to work in an
073 *   interoperable way with other types of LDAP servers.
074 * </BLOCKQUOTE>
075 * <BR>
076 * This control has an OID of "1.3.6.1.4.1.30221.2.5.44".  It is recommended
077 * that it be used with a criticality of {@code true}.  It does not take a
078 * value.
079 */
080@NotMutable()
081@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
082public final class NameWithEntryUUIDRequestControl
083       extends Control
084{
085  /**
086   * The OID (1.3.6.1.4.1.30221.2.5.44) for the name with entryUUID request
087   * control.
088   */
089  @NotNull public static final String NAME_WITH_ENTRY_UUID_REQUEST_OID =
090       "1.3.6.1.4.1.30221.2.5.44";
091
092
093
094  /**
095   * The serial version UID for this serializable class.
096   */
097  private static final long serialVersionUID = -1083494935823253033L;
098
099
100
101  /**
102   * Creates a new name with entryUUID request control.  It will be marked
103   * critical.
104   */
105  public NameWithEntryUUIDRequestControl()
106  {
107    this(true);
108  }
109
110
111
112  /**
113   * Creates a new name with entryUUID request control with the specified
114   * criticality.
115   *
116   * @param  isCritical  Indicates whether this control should be marked
117   *                     critical.
118   */
119  public NameWithEntryUUIDRequestControl(final boolean isCritical)
120  {
121    super(NAME_WITH_ENTRY_UUID_REQUEST_OID, isCritical, null);
122  }
123
124
125
126  /**
127   * Creates a new name with entryUUID request control which is decoded from the
128   * provided generic control.
129   *
130   * @param  control  The generic control to be decoded as a name with entryUUID
131   *                  request control.
132   *
133   * @throws LDAPException  If the provided control cannot be decoded as a name
134   *                         with entryUUID request control.
135   */
136  public NameWithEntryUUIDRequestControl(@NotNull final Control control)
137       throws LDAPException
138  {
139    super(control);
140
141    if (control.hasValue())
142    {
143      throw new LDAPException(ResultCode.DECODING_ERROR,
144           ERR_NAME_WITH_ENTRY_UUID_REQUEST_HAS_VALUE.get());
145    }
146  }
147
148
149
150  /**
151   * {@inheritDoc}
152   */
153  @Override()
154  @NotNull()
155  public String getControlName()
156  {
157    return INFO_CONTROL_NAME_WITH_ENTRY_UUID_REQUEST.get();
158  }
159
160
161
162  /**
163   * {@inheritDoc}
164   */
165  @Override()
166  public void toString(@NotNull final StringBuilder buffer)
167  {
168    buffer.append("NameWithEntryUUIDRequestControl(isCritical=");
169    buffer.append(isCritical());
170    buffer.append(')');
171  }
172}