001 /* 002 * Copyright 2013-2015 UnboundID Corp. 003 * All Rights Reserved. 004 */ 005 /* 006 * Copyright (C) 2015 UnboundID Corp. 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 */ 021 package com.unboundid.ldap.sdk.unboundidds.controls; 022 023 024 025 import com.unboundid.ldap.sdk.Control; 026 import com.unboundid.ldap.sdk.LDAPException; 027 import com.unboundid.ldap.sdk.ResultCode; 028 import com.unboundid.util.NotMutable; 029 import com.unboundid.util.ThreadSafety; 030 import com.unboundid.util.ThreadSafetyLevel; 031 032 import static com.unboundid.ldap.sdk.unboundidds.controls.ControlMessages.*; 033 034 035 036 /** 037 * <BLOCKQUOTE> 038 * <B>NOTE:</B> This class is part of the Commercial Edition of the UnboundID 039 * LDAP SDK for Java. It is not available for use in applications that 040 * include only the Standard Edition of the LDAP SDK, and is not supported for 041 * use in conjunction with non-UnboundID products. 042 * </BLOCKQUOTE> 043 * This class provides a request control that can be included in a modify 044 * request or a password modify extended request in order to indicate that if 045 * the operation results in changing the password for a user, the user's former 046 * password should be purged from the entry rather than retired, and any 047 * existing retired password should also be purged. 048 * <BR><BR> 049 * This control has an OID of "1.3.6.1.4.1.30221.2.5.32" and does not have a 050 * value. The criticality may be either true (in which case the operation will 051 * succeed only if the user's password policy allows passwords to be retired by 052 * a request control) or false (in which case if the password policy does not 053 * allow the use of this control, the operation will be processed as if the 054 * control had not been included in the request). 055 * <BR><BR> 056 * <H2>Example</H2> 057 * The following example demonstrates the use of the purge password request 058 * control to request that a user's current password be purged in the course of 059 * a password change. 060 * <PRE> 061 * Control[] requestControls = 062 * { 063 * new PurgePasswordRequestControl(true) 064 * }; 065 * 066 * PasswordModifyExtendedRequest passwordModifyRequest = 067 * new PasswordModifyExtendedRequest( 068 * "uid=test.user,ou=People,dc=example,dc=com", // The user to update 069 * null, // The current password -- we don't know it. 070 * "newPassword", // The new password to assign to the user. 071 * requestControls); // The controls to include in the request. 072 * PasswordModifyExtendedResult passwordModifyResult = 073 * (PasswordModifyExtendedResult) 074 * connection.processExtendedOperation(passwordModifyRequest); 075 * </PRE> 076 * 077 * @see RetirePasswordRequestControl 078 */ 079 @NotMutable() 080 @ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 081 public final class PurgePasswordRequestControl 082 extends Control 083 { 084 /** 085 * The OID (1.3.6.1.4.1.4203.1.10.2) for the purge password request control. 086 */ 087 public static final String PURGE_PASSWORD_REQUEST_OID = 088 "1.3.6.1.4.1.30221.2.5.32"; 089 090 091 092 /** 093 * The serial version UID for this serializable class. 094 */ 095 private static final long serialVersionUID = -3756801088881565921L; 096 097 098 099 /** 100 * Creates a new retire password request control with the specified 101 * criticality. 102 * 103 * @param isCritical Indicates whether the control should be considered 104 * critical. 105 */ 106 public PurgePasswordRequestControl(final boolean isCritical) 107 { 108 super(PURGE_PASSWORD_REQUEST_OID, isCritical, null); 109 } 110 111 112 113 /** 114 * Creates a new retire password request control which is decoded from the 115 * provided generic control. 116 * 117 * @param control The generic control to be decoded as a retire password 118 * request control. 119 * 120 * @throws LDAPException If the provided control cannot be decoded as a 121 * retire password request control. 122 */ 123 public PurgePasswordRequestControl(final Control control) 124 throws LDAPException 125 { 126 super(control); 127 128 if (control.hasValue()) 129 { 130 throw new LDAPException(ResultCode.DECODING_ERROR, 131 ERR_PURGE_PASSWORD_REQUEST_CONTROL_HAS_VALUE.get()); 132 } 133 } 134 135 136 137 /** 138 * {@inheritDoc} 139 */ 140 @Override() 141 public String getControlName() 142 { 143 return INFO_CONTROL_NAME_PURGE_PASSWORD_REQUEST.get(); 144 } 145 146 147 148 /** 149 * {@inheritDoc} 150 */ 151 @Override() 152 public void toString(final StringBuilder buffer) 153 { 154 buffer.append("PurgePasswordRequestControl(isCritical="); 155 buffer.append(isCritical()); 156 buffer.append(')'); 157 } 158 }