001/* 002 * Copyright 2008-2018 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright (C) 2015-2018 Ping Identity Corporation 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 */ 021package com.unboundid.ldap.sdk.unboundidds.controls; 022 023 024 025import com.unboundid.ldap.sdk.Control; 026import com.unboundid.ldap.sdk.LDAPException; 027import com.unboundid.ldap.sdk.ResultCode; 028import com.unboundid.util.NotMutable; 029import com.unboundid.util.ThreadSafety; 030import com.unboundid.util.ThreadSafetyLevel; 031 032import static com.unboundid.ldap.sdk.unboundidds.controls.ControlMessages.*; 033 034 035 036/** 037 * This class provides an implementation of an LDAP control that can be used to 038 * request that the Directory Server ignore the NO-USER-MODIFICATION flag for 039 * attribute types. It may be included in an add request to allow the client to 040 * include attributes which are not normally allowed to be externally specified 041 * (e.g., entryUUID, creatorsName, modifiersName, etc.). This control does not 042 * have a value, and there is no corresponding response control. 043 * <BR> 044 * <BLOCKQUOTE> 045 * <B>NOTE:</B> This class, and other classes within the 046 * {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only 047 * supported for use against Ping Identity, UnboundID, and Alcatel-Lucent 8661 048 * server products. These classes provide support for proprietary 049 * functionality or for external specifications that are not considered stable 050 * or mature enough to be guaranteed to work in an interoperable way with 051 * other types of LDAP servers. 052 * </BLOCKQUOTE> 053 * <BR> 054 * <H2>Example</H2> 055 * The following example demonstrates the process for attempting to perform an 056 * add operation including the ignore NO-USER-MODIFICATION control so that an 057 * entry can be added which already includes the creatorsName and 058 * createTimestamp attributes: 059 * <PRE> 060 * AddRequest addRequest = new AddRequest("dc=example,dc=com", 061 * new Attribute("objectClass", "top", "domain"), 062 * new Attribute("dc", "example"), 063 * new Attribute("creatorsName", "cn=Admin User DN"), 064 * new Attribute("createTimestamp", "20080101000000Z")); 065 * addRequest.addControl(new IgnoreNoUserModificationRequestControl()); 066 * 067 * try 068 * { 069 * LDAPResult result = connection.add(addRequest); 070 * // The entry was added successfully. 071 * } 072 * catch (LDAPException le) 073 * { 074 * // The attempt to add the entry failed. 075 * } 076 * </PRE> 077 */ 078@NotMutable() 079@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 080public final class IgnoreNoUserModificationRequestControl 081 extends Control 082{ 083 /** 084 * The OID (1.3.6.1.4.1.30221.2.5.5) for the ignore NO-USER-MODIFICATION 085 * request control. 086 */ 087 public static final String IGNORE_NO_USER_MODIFICATION_REQUEST_OID = 088 "1.3.6.1.4.1.30221.2.5.5"; 089 090 091 092 /** 093 * The serial version UID for this serializable class. 094 */ 095 private static final long serialVersionUID = 2622432059171073555L; 096 097 098 099 /** 100 * Creates a new ignore NO-USER-MODIFICATION request control. It will be 101 * marked critical. 102 */ 103 public IgnoreNoUserModificationRequestControl() 104 { 105 super(IGNORE_NO_USER_MODIFICATION_REQUEST_OID, true, null); 106 } 107 108 109 110 /** 111 * Creates a new ignore NO-USER-MODIFICATION request control which is decoded 112 * from the provided generic control. 113 * 114 * @param control The generic control to be decoded as an ignore 115 * NO-USER-MODIFICATION request control. 116 * 117 * @throws LDAPException If the provided control cannot be decoded as an 118 * ignore NO-USER-MODIFICATION request control. 119 */ 120 public IgnoreNoUserModificationRequestControl(final Control control) 121 throws LDAPException 122 { 123 super(control); 124 125 if (control.hasValue()) 126 { 127 throw new LDAPException(ResultCode.DECODING_ERROR, 128 ERR_IGNORENUM_REQUEST_HAS_VALUE.get()); 129 } 130 } 131 132 133 134 /** 135 * {@inheritDoc} 136 */ 137 @Override() 138 public String getControlName() 139 { 140 return INFO_CONTROL_NAME_IGNORE_NO_USER_MODIFICATION_REQUEST.get(); 141 } 142 143 144 145 /** 146 * {@inheritDoc} 147 */ 148 @Override() 149 public void toString(final StringBuilder buffer) 150 { 151 buffer.append("IgnoreNoUserModificationRequestControl(isCritical="); 152 buffer.append(isCritical()); 153 buffer.append(')'); 154 } 155}