001/*
002 * Copyright 2024 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright 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) 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.experimental;
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.experimental.ExperimentalMessages.*;
049
050
051
052/**
053 * This class provides an implementation of the LDAP relax rules request control
054 * as defined in draft-zeilenga-ldap-relax-03.  This control may be included in
055 * LDAP update (including add, delete, modify, and modify DN) requests to
056 * indicate that the server should relax its enforcement of certain constraints
057 * for that update operation.  Such constraints that may be relaxed include:
058 * <UL>
059 *   <LI>
060 *     The restriction that prevents changing an entry's structural object
061 *     class.
062 *   </LI>
063 *   <LI>
064 *     The restriction that prevents clients from altering the values of
065 *     attributes defined with the NO-USER-MODIFICATION constraint.
066 *   </LI>
067 *   <LI>
068 *     The restriction that prevents using attributes defined with the
069 *     OBSOLETE constraint.
070 *   </LI>
071 *   <LI>
072 *     The restriction that prevents including an auxiliary object class in an
073 *     entry when that class is prohibited by a DIT content rule.
074 *   </LI>
075 *   <LI>
076 *     The restriction that prevents including an attribute in an entry when
077 *     that attribute is prohibited by a DIT content rule.
078 *   </LI>
079 *   <LI>
080 *     The restriction that prevents adding a subordinate entry whose structural
081 *     class does not satisfy the DIT structure rule that governs the parent
082 *     entry.
083 *   </LI>
084 *   <LI>
085 *     The restriction that prevents adding an entry with RDN attributes that do
086 *     not satisfy the governing name form.
087 *   </LI>
088 *   <LI>
089 *     The restriction that prevents altering entries that currently do not
090 *     conform to the server schema in some way in a manner that does not fix
091 *     the relevant schema conformance issues.
092 *   </LI>
093 * </UL>
094 * <BR><BR>
095 * Note that at the time this control was written, the latest version of the
096 * specification may be found in draft-zeilenga-ldap-relax-03.  This version of
097 * the document does not explicitly specify the OID that should be used for the
098 * control.  Until such time as this OID is officially defined, this
099 * implementation uses the OID temporarily assigned for its use by the OpenLDAP
100 * Foundation, which is used by at least the OpenLDAP and ForgeRock servers.
101 */
102@NotMutable()
103@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
104public final class DraftZeilengaLDAPRelaxRules03RequestControl
105       extends Control
106{
107  /**
108   * The OID (1.3.6.1.4.1.4203.666.5.12) for the LDAP relax rules request
109   * control.
110   */
111  @NotNull
112  public static final String RELAX_RULES_REQUEST_OID =
113       "1.3.6.1.4.1.4203.666.5.12";
114
115
116
117  /**
118   * The serial version UID for this serializable class.
119   */
120  private static final long serialVersionUID = -945892512562705359L;
121
122
123
124  /**
125   * Creates a new relax rules request control.  It will be marked critical, as
126   * required by the control specification.
127   */
128  public DraftZeilengaLDAPRelaxRules03RequestControl()
129  {
130    super(RELAX_RULES_REQUEST_OID, true, null);
131  }
132
133
134
135  /**
136   * Creates a new relax rules request control which is decoded from the
137   * provided generic control.
138   *
139   * @param  control  The generic control to be decoded as a relax rules request
140   *                  control.
141   *
142   * @throws  LDAPException  If the provided control cannot be decoded as a
143   *                         relax rules request control.
144   */
145  public DraftZeilengaLDAPRelaxRules03RequestControl(
146              @NotNull final Control control)
147         throws LDAPException
148  {
149    super(control);
150
151    if (control.hasValue())
152    {
153      throw new LDAPException(ResultCode.DECODING_ERROR,
154                              ERR_RELAX_RULES_REQUEST_HAS_VALUE.get());
155    }
156  }
157
158
159
160  /**
161   * {@inheritDoc}
162   */
163  @Override()
164  @NotNull()
165  public String getControlName()
166  {
167    return INFO_CONTROL_NAME_RELAX_RULES_REQUEST.get();
168  }
169
170
171
172  /**
173   * {@inheritDoc}
174   */
175  @Override()
176  public void toString(@NotNull final StringBuilder buffer)
177  {
178    buffer.append("RelaxRulesRequestControl(isCritical=");
179    buffer.append(isCritical());
180    buffer.append(')');
181  }
182}