use of com.unboundid.ldap.sdk.unboundidds.controls.PurgePasswordRequestControl in project ldapsdk by pingidentity.
the class LDAPPasswordModify method getUpdateControls.
/**
* Retrieves the controls that should be included in the password update
* request.
*
* @return The controls that should be included in the password update
* request, or an empty array if no controls should be included.
*
* @throws LDAPException If a problem occurs while trying to create any of
* the controls.
*/
@NotNull()
private Control[] getUpdateControls() throws LDAPException {
final List<Control> controls = new ArrayList<>();
if (updateControl.isPresent()) {
controls.addAll(updateControl.getValues());
}
if (usePasswordPolicyControlOnUpdate.isPresent()) {
controls.add(new PasswordPolicyRequestControl());
}
if (noOperation.isPresent()) {
controls.add(new NoOpRequestControl());
}
if (getPasswordValidationDetails.isPresent()) {
controls.add(new PasswordValidationDetailsRequestControl());
}
if (retireCurrentPassword.isPresent()) {
controls.add(new RetirePasswordRequestControl(false));
}
if (purgeCurrentPassword.isPresent()) {
controls.add(new PurgePasswordRequestControl(false));
}
if (passwordUpdateBehavior.isPresent()) {
controls.add(LDAPModify.createPasswordUpdateBehaviorRequestControl(passwordUpdateBehavior.getIdentifierString(), passwordUpdateBehavior.getValues()));
}
if (operationPurpose.isPresent()) {
controls.add(new OperationPurposeRequestControl(false, getToolName(), getToolVersion(), LDAPPasswordModify.class.getName() + ".getUpdateControls", operationPurpose.getValue()));
}
if (useAssuredReplication.isPresent()) {
AssuredReplicationLocalLevel localLevel = null;
if (assuredReplicationLocalLevel.isPresent()) {
final String level = assuredReplicationLocalLevel.getValue();
if (level.equalsIgnoreCase(ASSURED_REPLICATION_LOCAL_LEVEL_NONE)) {
localLevel = AssuredReplicationLocalLevel.NONE;
} else if (level.equalsIgnoreCase(ASSURED_REPLICATION_LOCAL_LEVEL_RECEIVED_ANY_SERVER)) {
localLevel = AssuredReplicationLocalLevel.RECEIVED_ANY_SERVER;
} else if (level.equalsIgnoreCase(ASSURED_REPLICATION_LOCAL_LEVEL_PROCESSED_ALL_SERVERS)) {
localLevel = AssuredReplicationLocalLevel.PROCESSED_ALL_SERVERS;
}
}
AssuredReplicationRemoteLevel remoteLevel = null;
if (assuredReplicationRemoteLevel.isPresent()) {
final String level = assuredReplicationRemoteLevel.getValue();
if (level.equalsIgnoreCase(ASSURED_REPLICATION_REMOTE_LEVEL_NONE)) {
remoteLevel = AssuredReplicationRemoteLevel.NONE;
} else if (level.equalsIgnoreCase(ASSURED_REPLICATION_REMOTE_LEVEL_RECEIVED_ANY_REMOTE_LOCATION)) {
remoteLevel = AssuredReplicationRemoteLevel.RECEIVED_ANY_REMOTE_LOCATION;
} else if (level.equalsIgnoreCase(ASSURED_REPLICATION_REMOTE_LEVEL_RECEIVED_ALL_REMOTE_LOCATIONS)) {
remoteLevel = AssuredReplicationRemoteLevel.RECEIVED_ALL_REMOTE_LOCATIONS;
} else if (level.equalsIgnoreCase(ASSURED_REPLICATION_REMOTE_LEVEL_PROCESSED_ALL_REMOTE_SERVERS)) {
remoteLevel = AssuredReplicationRemoteLevel.PROCESSED_ALL_REMOTE_SERVERS;
}
}
Long timeoutMillis = null;
if (assuredReplicationTimeout.isPresent()) {
timeoutMillis = assuredReplicationTimeout.getValue(TimeUnit.MILLISECONDS);
}
controls.add(new AssuredReplicationRequestControl(true, localLevel, localLevel, remoteLevel, remoteLevel, timeoutMillis, false));
}
return controls.toArray(StaticUtils.NO_CONTROLS);
}
use of com.unboundid.ldap.sdk.unboundidds.controls.PurgePasswordRequestControl in project ldapsdk by pingidentity.
the class LDAPModify method doModify.
/**
* Performs the appropriate processing for an LDIF modify change record.
*
* @param changeRecord The LDIF modify change record to process.
* @param controls The set of controls to include in the request.
* @param pool The connection pool to use to communicate with
* the directory server.
* @param multiUpdateRequests The list to which the request should be added
* if it is to be processed as part of a
* multi-update operation. It may be
* {@code null} if the operation should not be
* processed via the multi-update operation.
* @param rejectWriter The LDIF writer to use for recording
* information about rejected changes. It may be
* {@code null} if no reject writer is
* configured.
*
* @return The result code obtained from processing.
*
* @throws LDAPException If the operation did not complete successfully
* and processing should not continue.
*/
@NotNull()
ResultCode doModify(@NotNull final LDIFModifyChangeRecord changeRecord, @NotNull final List<Control> controls, @NotNull final LDAPConnectionPool pool, @Nullable final List<LDAPRequest> multiUpdateRequests, @Nullable final LDIFWriter rejectWriter) throws LDAPException {
// Create the modify request to process.
final ModifyRequest modifyRequest = changeRecord.toModifyRequest(true);
for (final Control c : controls) {
modifyRequest.addControl(c);
}
// that are specific to that.
if (retireCurrentPassword.isPresent() || purgeCurrentPassword.isPresent() || passwordValidationDetails.isPresent()) {
for (final Modification m : modifyRequest.getModifications()) {
final String baseName = m.getAttribute().getBaseName();
if (baseName.equalsIgnoreCase(ATTR_USER_PASSWORD) || baseName.equalsIgnoreCase(ATTR_AUTH_PASSWORD)) {
if (retireCurrentPassword.isPresent()) {
modifyRequest.addControl(new RetirePasswordRequestControl(false));
} else if (purgeCurrentPassword.isPresent()) {
modifyRequest.addControl(new PurgePasswordRequestControl(false));
}
if (passwordValidationDetails.isPresent()) {
modifyRequest.addControl(new PasswordValidationDetailsRequestControl());
}
break;
}
}
}
// just add the request to the list and return without doing anything else.
if (multiUpdateErrorBehavior.isPresent()) {
multiUpdateRequests.add(modifyRequest);
commentToOut(INFO_LDAPMODIFY_MODIFY_ADDED_TO_MULTI_UPDATE.get(modifyRequest.getDN()));
return ResultCode.SUCCESS;
}
// If the --dryRun argument was provided, then we'll stop here.
if (dryRun.isPresent()) {
commentToOut(INFO_LDAPMODIFY_DRY_RUN_MODIFY.get(modifyRequest.getDN(), dryRun.getIdentifierString()));
return ResultCode.SUCCESS;
}
// Process the modify operation and get the result.
commentToOut(INFO_LDAPMODIFY_MODIFYING_ENTRY.get(modifyRequest.getDN()));
if (verbose.isPresent()) {
for (final String ldifLine : modifyRequest.toLDIFChangeRecord().toLDIF(WRAP_COLUMN)) {
out(ldifLine);
}
out();
}
LDAPResult modifyResult;
try {
modifyResult = pool.modify(modifyRequest);
} catch (final LDAPException le) {
Debug.debugException(le);
modifyResult = le.toLDAPResult();
}
// Display information about the result.
displayResult(modifyResult, useTransaction.isPresent());
// should end all processing, then throw an exception.
switch(modifyResult.getResultCode().intValue()) {
case ResultCode.SUCCESS_INT_VALUE:
case ResultCode.NO_OPERATION_INT_VALUE:
break;
case ResultCode.ASSERTION_FAILED_INT_VALUE:
writeRejectedChange(rejectWriter, INFO_LDAPMODIFY_ASSERTION_FAILED.get(modifyRequest.getDN(), String.valueOf(assertionFilter.getValue())), modifyRequest.toLDIFChangeRecord(), modifyResult);
throw new LDAPException(modifyResult);
default:
writeRejectedChange(rejectWriter, null, modifyRequest.toLDIFChangeRecord(), modifyResult);
if (useTransaction.isPresent() || (!continueOnError.isPresent())) {
throw new LDAPException(modifyResult);
}
break;
}
return modifyResult.getResultCode();
}
Aggregations