Search in sources :

Example 1 with PurgePasswordRequestControl

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);
}
Also used : PurgePasswordRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.PurgePasswordRequestControl) AssuredReplicationRemoteLevel(com.unboundid.ldap.sdk.unboundidds.controls.AssuredReplicationRemoteLevel) NoOpRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.NoOpRequestControl) AssuredReplicationRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.AssuredReplicationRequestControl) ArrayList(java.util.ArrayList) OperationPurposeRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.OperationPurposeRequestControl) AuthorizationIdentityRequestControl(com.unboundid.ldap.sdk.controls.AuthorizationIdentityRequestControl) Control(com.unboundid.ldap.sdk.Control) GetUserResourceLimitsRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.GetUserResourceLimitsRequestControl) GetAuthorizationEntryRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.GetAuthorizationEntryRequestControl) PurgePasswordRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.PurgePasswordRequestControl) AssuredReplicationRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.AssuredReplicationRequestControl) RetirePasswordRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.RetirePasswordRequestControl) NoOpRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.NoOpRequestControl) OperationPurposeRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.OperationPurposeRequestControl) PasswordPolicyRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.PasswordPolicyRequestControl) PasswordValidationDetailsRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.PasswordValidationDetailsRequestControl) RetirePasswordRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.RetirePasswordRequestControl) PasswordPolicyRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.PasswordPolicyRequestControl) PasswordValidationDetailsRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.PasswordValidationDetailsRequestControl) AssuredReplicationLocalLevel(com.unboundid.ldap.sdk.unboundidds.controls.AssuredReplicationLocalLevel) NotNull(com.unboundid.util.NotNull)

Example 2 with PurgePasswordRequestControl

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();
}
Also used : Modification(com.unboundid.ldap.sdk.Modification) RouteToServerRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.RouteToServerRequestControl) SubtreeDeleteRequestControl(com.unboundid.ldap.sdk.controls.SubtreeDeleteRequestControl) SimplePagedResultsControl(com.unboundid.ldap.sdk.controls.SimplePagedResultsControl) TransactionSpecificationRequestControl(com.unboundid.ldap.sdk.controls.TransactionSpecificationRequestControl) AssuredReplicationRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.AssuredReplicationRequestControl) PostReadRequestControl(com.unboundid.ldap.sdk.controls.PostReadRequestControl) SuppressOperationalAttributeUpdateRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.SuppressOperationalAttributeUpdateRequestControl) NameWithEntryUUIDRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.NameWithEntryUUIDRequestControl) ReplicationRepairRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.ReplicationRepairRequestControl) ProxiedAuthorizationV1RequestControl(com.unboundid.ldap.sdk.controls.ProxiedAuthorizationV1RequestControl) OperationPurposeRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.OperationPurposeRequestControl) PasswordUpdateBehaviorRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.PasswordUpdateBehaviorRequestControl) UndeleteRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.UndeleteRequestControl) GetRecentLoginHistoryRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.GetRecentLoginHistoryRequestControl) PermissiveModifyRequestControl(com.unboundid.ldap.sdk.controls.PermissiveModifyRequestControl) AuthorizationIdentityRequestControl(com.unboundid.ldap.sdk.controls.AuthorizationIdentityRequestControl) Control(com.unboundid.ldap.sdk.Control) GetUserResourceLimitsRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.GetUserResourceLimitsRequestControl) HardDeleteRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.HardDeleteRequestControl) IgnoreNoUserModificationRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.IgnoreNoUserModificationRequestControl) GetBackendSetIDRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.GetBackendSetIDRequestControl) GetAuthorizationEntryRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.GetAuthorizationEntryRequestControl) PurgePasswordRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.PurgePasswordRequestControl) ProxiedAuthorizationV2RequestControl(com.unboundid.ldap.sdk.controls.ProxiedAuthorizationV2RequestControl) SoftDeleteRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.SoftDeleteRequestControl) RetirePasswordRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.RetirePasswordRequestControl) GetServerIDRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.GetServerIDRequestControl) NoOpRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.NoOpRequestControl) PasswordPolicyRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.PasswordPolicyRequestControl) SuppressReferentialIntegrityUpdatesRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.SuppressReferentialIntegrityUpdatesRequestControl) AssertionRequestControl(com.unboundid.ldap.sdk.controls.AssertionRequestControl) RouteToBackendSetRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.RouteToBackendSetRequestControl) ManageDsaITRequestControl(com.unboundid.ldap.sdk.controls.ManageDsaITRequestControl) PasswordValidationDetailsRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.PasswordValidationDetailsRequestControl) UniquenessRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.UniquenessRequestControl) GeneratePasswordRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.GeneratePasswordRequestControl) PreReadRequestControl(com.unboundid.ldap.sdk.controls.PreReadRequestControl) RetirePasswordRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.RetirePasswordRequestControl) PurgePasswordRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.PurgePasswordRequestControl) LDAPException(com.unboundid.ldap.sdk.LDAPException) LDAPResult(com.unboundid.ldap.sdk.LDAPResult) ModifyRequest(com.unboundid.ldap.sdk.ModifyRequest) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) PasswordValidationDetailsRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.PasswordValidationDetailsRequestControl) NotNull(com.unboundid.util.NotNull)

Aggregations

Control (com.unboundid.ldap.sdk.Control)2 AuthorizationIdentityRequestControl (com.unboundid.ldap.sdk.controls.AuthorizationIdentityRequestControl)2 AssuredReplicationRequestControl (com.unboundid.ldap.sdk.unboundidds.controls.AssuredReplicationRequestControl)2 GetAuthorizationEntryRequestControl (com.unboundid.ldap.sdk.unboundidds.controls.GetAuthorizationEntryRequestControl)2 GetUserResourceLimitsRequestControl (com.unboundid.ldap.sdk.unboundidds.controls.GetUserResourceLimitsRequestControl)2 NoOpRequestControl (com.unboundid.ldap.sdk.unboundidds.controls.NoOpRequestControl)2 OperationPurposeRequestControl (com.unboundid.ldap.sdk.unboundidds.controls.OperationPurposeRequestControl)2 PasswordPolicyRequestControl (com.unboundid.ldap.sdk.unboundidds.controls.PasswordPolicyRequestControl)2 PasswordValidationDetailsRequestControl (com.unboundid.ldap.sdk.unboundidds.controls.PasswordValidationDetailsRequestControl)2 PurgePasswordRequestControl (com.unboundid.ldap.sdk.unboundidds.controls.PurgePasswordRequestControl)2 RetirePasswordRequestControl (com.unboundid.ldap.sdk.unboundidds.controls.RetirePasswordRequestControl)2 ASN1OctetString (com.unboundid.asn1.ASN1OctetString)1 LDAPException (com.unboundid.ldap.sdk.LDAPException)1 LDAPResult (com.unboundid.ldap.sdk.LDAPResult)1 Modification (com.unboundid.ldap.sdk.Modification)1 ModifyRequest (com.unboundid.ldap.sdk.ModifyRequest)1 AssertionRequestControl (com.unboundid.ldap.sdk.controls.AssertionRequestControl)1 ManageDsaITRequestControl (com.unboundid.ldap.sdk.controls.ManageDsaITRequestControl)1 PermissiveModifyRequestControl (com.unboundid.ldap.sdk.controls.PermissiveModifyRequestControl)1 PostReadRequestControl (com.unboundid.ldap.sdk.controls.PostReadRequestControl)1