001/* 002 * Copyright 2007-2024 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright 2007-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) 2007-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.unboundidds.controls; 037 038 039 040import com.unboundid.asn1.ASN1OctetString; 041import com.unboundid.ldap.sdk.Control; 042import com.unboundid.ldap.sdk.LDAPException; 043import com.unboundid.ldap.sdk.ResultCode; 044import com.unboundid.ldap.sdk.controls.AssertionRequestControl; 045import com.unboundid.ldap.sdk.controls.ManageDsaITRequestControl; 046import com.unboundid.ldap.sdk.controls.PostReadRequestControl; 047import com.unboundid.ldap.sdk.controls.PreReadRequestControl; 048import com.unboundid.ldap.sdk.controls.ProxiedAuthorizationV1RequestControl; 049import com.unboundid.ldap.sdk.controls.ProxiedAuthorizationV2RequestControl; 050import com.unboundid.ldap.sdk.controls.SubtreeDeleteRequestControl; 051import com.unboundid.ldap.sdk.unboundidds.extensions. 052 StartBatchedTransactionExtendedRequest; 053import com.unboundid.util.NotMutable; 054import com.unboundid.util.NotNull; 055import com.unboundid.util.ThreadSafety; 056import com.unboundid.util.ThreadSafetyLevel; 057 058import static com.unboundid.ldap.sdk.unboundidds.controls.ControlMessages.*; 059 060 061 062/** 063 * This class provides an implementation of the batched transaction 064 * specification request control, which may be used to indicate that the 065 * associated add, delete, modify, modify DN, or password modify operation is 066 * part of a batched transaction. The transaction should be created with the 067 * start batched transaction extended operation, which will obtain a transaction 068 * ID, and the transaction may be committed or aborted using the end batched 069 * transaction extended operation. 070 * <BR> 071 * <BLOCKQUOTE> 072 * <B>NOTE:</B> This class, and other classes within the 073 * {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only 074 * supported for use against Ping Identity, UnboundID, and 075 * Nokia/Alcatel-Lucent 8661 server products. These classes provide support 076 * for proprietary functionality or for external specifications that are not 077 * considered stable or mature enough to be guaranteed to work in an 078 * interoperable way with other types of LDAP servers. 079 * </BLOCKQUOTE> 080 * <BR> 081 * Note that directory servers may limit the set of controls that are available 082 * for use in requests that are part of a transaction. RFC 5805 section 4 083 * indicates that the following controls may be used in conjunction with the 084 * transaction specification request control: {@link AssertionRequestControl}, 085 * {@link ManageDsaITRequestControl}, {@link PreReadRequestControl}, and 086 * {@link PostReadRequestControl}. The 087 * {@link ProxiedAuthorizationV1RequestControl} and 088 * {@link ProxiedAuthorizationV2RequestControl} controls cannot be included in 089 * requests that are part of a transaction, but you can include them in the 090 * {@link StartBatchedTransactionExtendedRequest} to indicate that all 091 * operations within the transaction should be processed with the specified 092 * authorization identity. 093 * <BR><BR> 094 * The Ping Identity, UnboundID, and Nokia/Alcatel-Lucent 8661 server products 095 * support the following additional UnboundID-specific controls in conjunction 096 * with operations included in a transaction: 097 * {@link AccountUsableRequestControl}, {@link HardDeleteRequestControl}, 098 * {@link IntermediateClientRequestControl}, 099 * {@link PasswordPolicyRequestControl}, 100 * {@link ReplicationRepairRequestControl}, {@link SoftDeleteRequestControl}, 101 * {@link SoftDeletedEntryAccessRequestControl}, 102 * {@link SubtreeDeleteRequestControl}, and {@link UndeleteRequestControl}. 103 * <BR><BR> 104 * See the documentation for the {@link StartBatchedTransactionExtendedRequest} 105 * class for an example of processing a batched transaction. 106 */ 107@NotMutable() 108@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 109public final class BatchedTransactionSpecificationRequestControl 110 extends Control 111{ 112 /** 113 * The OID (1.3.6.1.4.1.30221.2.5.1) for the batched transaction specification 114 * request control. 115 */ 116 @NotNull public static final String 117 BATCHED_TRANSACTION_SPECIFICATION_REQUEST_OID = 118 "1.3.6.1.4.1.30221.2.5.1"; 119 120 121 122 /** 123 * The serial version UID for this serializable class. 124 */ 125 private static final long serialVersionUID = -6817702055586260189L; 126 127 128 129 // The transaction ID for the associated transaction. 130 @NotNull private final ASN1OctetString transactionID; 131 132 133 134 /** 135 * Creates a new batched transaction specification request control with the 136 * provided transaction ID. 137 * 138 * @param transactionID The transaction ID for the associated transaction, 139 * as obtained from the start batched transaction 140 * extended operation. It must not be {@code null}. 141 */ 142 public BatchedTransactionSpecificationRequestControl( 143 @NotNull final ASN1OctetString transactionID) 144 { 145 super(BATCHED_TRANSACTION_SPECIFICATION_REQUEST_OID, true, 146 new ASN1OctetString(transactionID.getValue())); 147 148 this.transactionID = transactionID; 149 } 150 151 152 153 /** 154 * Creates a new batched transaction specification request control which is 155 * decoded from the provided generic control. 156 * 157 * @param control The generic control to be decoded as a batched transaction 158 * specification request control. 159 * 160 * @throws LDAPException If the provided control cannot be decoded as a 161 * batched transaction specification request control. 162 */ 163 public BatchedTransactionSpecificationRequestControl( 164 @NotNull final Control control) 165 throws LDAPException 166 { 167 super(control); 168 169 transactionID = control.getValue(); 170 if (transactionID == null) 171 { 172 throw new LDAPException(ResultCode.DECODING_ERROR, 173 ERR_TXN_REQUEST_CONTROL_NO_VALUE.get()); 174 } 175 } 176 177 178 179 /** 180 * Retrieves the transaction ID for the associated transaction. 181 * 182 * @return The transaction ID for the associated transaction. 183 */ 184 @NotNull() 185 public ASN1OctetString getTransactionID() 186 { 187 return transactionID; 188 } 189 190 191 192 /** 193 * {@inheritDoc} 194 */ 195 @Override() 196 @NotNull() 197 public String getControlName() 198 { 199 return INFO_CONTROL_NAME_BATCHED_TXN_REQUEST.get(); 200 } 201 202 203 204 /** 205 * {@inheritDoc} 206 */ 207 @Override() 208 public void toString(@NotNull final StringBuilder buffer) 209 { 210 buffer.append("BatchedTransactionSpecificationRequestControl(" + 211 "transactionID='"); 212 buffer.append(transactionID.stringValue()); 213 buffer.append("')"); 214 } 215}