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