Search in sources :

Example 1 with PasswordPolicyRequestControl

use of com.unboundid.ldap.sdk.unboundidds.controls.PasswordPolicyRequestControl in project ldapsdk by pingidentity.

the class LDAPModify method getBindControls.

/**
 * {@inheritDoc}
 */
@Override()
@NotNull()
protected List<Control> getBindControls() {
    final ArrayList<Control> bindControls = new ArrayList<>(10);
    if (bindControl.isPresent()) {
        bindControls.addAll(bindControl.getValues());
    }
    if (authorizationIdentity.isPresent()) {
        bindControls.add(new AuthorizationIdentityRequestControl(false));
    }
    if (getAuthorizationEntryAttribute.isPresent()) {
        bindControls.add(new GetAuthorizationEntryRequestControl(true, true, getAuthorizationEntryAttribute.getValues()));
    }
    if (getRecentLoginHistory.isPresent()) {
        bindControls.add(new GetRecentLoginHistoryRequestControl());
    }
    if (getUserResourceLimits.isPresent()) {
        bindControls.add(new GetUserResourceLimitsRequestControl());
    }
    if (usePasswordPolicyControl.isPresent()) {
        bindControls.add(new PasswordPolicyRequestControl());
    }
    if (suppressOperationalAttributeUpdates.isPresent()) {
        final EnumSet<SuppressType> suppressTypes = EnumSet.noneOf(SuppressType.class);
        for (final String s : suppressOperationalAttributeUpdates.getValues()) {
            if (s.equalsIgnoreCase("last-access-time")) {
                suppressTypes.add(SuppressType.LAST_ACCESS_TIME);
            } else if (s.equalsIgnoreCase("last-login-time")) {
                suppressTypes.add(SuppressType.LAST_LOGIN_TIME);
            } else if (s.equalsIgnoreCase("last-login-ip")) {
                suppressTypes.add(SuppressType.LAST_LOGIN_IP);
            }
        }
        bindControls.add(new SuppressOperationalAttributeUpdateRequestControl(suppressTypes));
    }
    return bindControls;
}
Also used : 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) PasswordPolicyRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.PasswordPolicyRequestControl) ArrayList(java.util.ArrayList) AuthorizationIdentityRequestControl(com.unboundid.ldap.sdk.controls.AuthorizationIdentityRequestControl) SuppressType(com.unboundid.ldap.sdk.unboundidds.controls.SuppressType) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) GetRecentLoginHistoryRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.GetRecentLoginHistoryRequestControl) SuppressOperationalAttributeUpdateRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.SuppressOperationalAttributeUpdateRequestControl) GetAuthorizationEntryRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.GetAuthorizationEntryRequestControl) GetUserResourceLimitsRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.GetUserResourceLimitsRequestControl) NotNull(com.unboundid.util.NotNull)

Example 2 with PasswordPolicyRequestControl

use of com.unboundid.ldap.sdk.unboundidds.controls.PasswordPolicyRequestControl 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 3 with PasswordPolicyRequestControl

use of com.unboundid.ldap.sdk.unboundidds.controls.PasswordPolicyRequestControl in project ssam by pingidentity.

the class SSAMController method updatePassword.

/**
 * Handles password update AJAX requests, changing the currently authenticated
 * user's password to the specified value.
 *
 * @param currentPassword
 *          The user's current password
 * @param password
 *          The new password for the user
 *
 * @return Returns a 200 status code and empty response upon success, or an
 *         error status code and error message if there is an error
 */
@RequestMapping(value = "/updatePassword", method = RequestMethod.POST, consumes = APPLICATION_FORM_URLENCODED_VALUE, produces = TEXT_PLAIN_VALUE)
public ResponseEntity<String> updatePassword(@RequestParam("currentPassword") String currentPassword, @RequestParam("password") String password) {
    Control[] controls = { getIntermediateClientRequestControl(), new PasswordPolicyRequestControl() };
    PasswordModifyExtendedRequest request = new PasswordModifyExtendedRequest(null, currentPassword, password, controls);
    try {
        PasswordModifyExtendedResult extendedResult = (PasswordModifyExtendedResult) pool.processExtendedOperation(request);
        ResultCode resultCode = extendedResult.getResultCode();
        if (resultCode == ResultCode.SUCCESS) {
            return new ResponseEntity<>(HttpStatus.OK);
        } else if (resultCode == ResultCode.INVALID_CREDENTIALS) {
            String additionalInfo = "";
            if (extendedResult.hasResponseControl(PasswordPolicyResponseControl.PASSWORD_POLICY_RESPONSE_OID)) {
                additionalInfo += "Reason: ";
                Control[] responseControls = extendedResult.getResponseControls();
                String separator = "";
                for (final Control control : responseControls) {
                    if (control.getOID().equals(PasswordPolicyResponseControl.PASSWORD_POLICY_RESPONSE_OID)) {
                        final PasswordPolicyResponseControl responseControl = (PasswordPolicyResponseControl) control;
                        additionalInfo += String.format("%s%s", separator, getPasswordPolicyErrorTypeMessage(responseControl.getErrorType()));
                        separator = ", ";
                    }
                }
            } else {
                additionalInfo = (extendedResult.getDiagnosticMessage() == null) ? "Please verify that your old password is correct." : extendedResult.getDiagnosticMessage();
            }
            // This will be returned if the "current password" is incorrect.
            return new ResponseEntity<>("Your password could not be updated. " + additionalInfo, HttpStatus.BAD_REQUEST);
        } else {
            return new ResponseEntity<>(resultCode + " - " + extendedResult.getDiagnosticMessage(), HttpStatus.BAD_REQUEST);
        }
    } catch (LDAPException e) {
        return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
    }
}
Also used : Control(com.unboundid.ldap.sdk.Control) IntermediateClientRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.IntermediateClientRequestControl) PasswordPolicyRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.PasswordPolicyRequestControl) PasswordPolicyResponseControl(com.unboundid.ldap.sdk.unboundidds.controls.PasswordPolicyResponseControl) ResponseEntity(org.springframework.http.ResponseEntity) PasswordPolicyRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.PasswordPolicyRequestControl) LDAPException(com.unboundid.ldap.sdk.LDAPException) PasswordModifyExtendedResult(com.unboundid.ldap.sdk.extensions.PasswordModifyExtendedResult) PasswordPolicyResponseControl(com.unboundid.ldap.sdk.unboundidds.controls.PasswordPolicyResponseControl) PasswordModifyExtendedRequest(com.unboundid.ldap.sdk.extensions.PasswordModifyExtendedRequest) ResultCode(com.unboundid.ldap.sdk.ResultCode) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with PasswordPolicyRequestControl

use of com.unboundid.ldap.sdk.unboundidds.controls.PasswordPolicyRequestControl in project ldapsdk by pingidentity.

the class LDAPSearch method getBindControls.

/**
 * {@inheritDoc}
 */
@Override()
@NotNull()
protected List<Control> getBindControls() {
    final ArrayList<Control> bindControls = new ArrayList<>(10);
    if (bindControl.isPresent()) {
        bindControls.addAll(bindControl.getValues());
    }
    if (authorizationIdentity.isPresent()) {
        bindControls.add(new AuthorizationIdentityRequestControl(false));
    }
    if (getAuthorizationEntryAttribute.isPresent()) {
        bindControls.add(new GetAuthorizationEntryRequestControl(true, true, getAuthorizationEntryAttribute.getValues()));
    }
    if (getRecentLoginHistory.isPresent()) {
        bindControls.add(new GetRecentLoginHistoryRequestControl());
    }
    if (getUserResourceLimits.isPresent()) {
        bindControls.add(new GetUserResourceLimitsRequestControl());
    }
    if (usePasswordPolicyControl.isPresent()) {
        bindControls.add(new PasswordPolicyRequestControl());
    }
    if (suppressOperationalAttributeUpdates.isPresent()) {
        final EnumSet<SuppressType> suppressTypes = EnumSet.noneOf(SuppressType.class);
        for (final String s : suppressOperationalAttributeUpdates.getValues()) {
            if (s.equalsIgnoreCase("last-access-time")) {
                suppressTypes.add(SuppressType.LAST_ACCESS_TIME);
            } else if (s.equalsIgnoreCase("last-login-time")) {
                suppressTypes.add(SuppressType.LAST_LOGIN_TIME);
            } else if (s.equalsIgnoreCase("last-login-ip")) {
                suppressTypes.add(SuppressType.LAST_LOGIN_IP);
            }
        }
        bindControls.add(new SuppressOperationalAttributeUpdateRequestControl(suppressTypes));
    }
    return bindControls;
}
Also used : VirtualListViewRequestControl(com.unboundid.ldap.sdk.controls.VirtualListViewRequestControl) RouteToServerRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.RouteToServerRequestControl) RFC3672SubentriesRequestControl(com.unboundid.ldap.sdk.controls.RFC3672SubentriesRequestControl) SimplePagedResultsControl(com.unboundid.ldap.sdk.controls.SimplePagedResultsControl) MatchingEntryCountRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.MatchingEntryCountRequestControl) MatchedValuesRequestControl(com.unboundid.ldap.sdk.controls.MatchedValuesRequestControl) VirtualAttributesOnlyRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.VirtualAttributesOnlyRequestControl) AccountUsableRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.AccountUsableRequestControl) OverrideSearchLimitsRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.OverrideSearchLimitsRequestControl) SuppressOperationalAttributeUpdateRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.SuppressOperationalAttributeUpdateRequestControl) ProxiedAuthorizationV1RequestControl(com.unboundid.ldap.sdk.controls.ProxiedAuthorizationV1RequestControl) OperationPurposeRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.OperationPurposeRequestControl) SoftDeletedEntryAccessRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.SoftDeletedEntryAccessRequestControl) JoinRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.JoinRequestControl) ReturnConflictEntriesRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.ReturnConflictEntriesRequestControl) GetRecentLoginHistoryRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.GetRecentLoginHistoryRequestControl) PermitUnindexedSearchRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.PermitUnindexedSearchRequestControl) RejectUnindexedSearchRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.RejectUnindexedSearchRequestControl) AuthorizationIdentityRequestControl(com.unboundid.ldap.sdk.controls.AuthorizationIdentityRequestControl) Control(com.unboundid.ldap.sdk.Control) GetUserResourceLimitsRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.GetUserResourceLimitsRequestControl) GetBackendSetIDRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.GetBackendSetIDRequestControl) GetAuthorizationEntryRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.GetAuthorizationEntryRequestControl) RealAttributesOnlyRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.RealAttributesOnlyRequestControl) ExcludeBranchRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.ExcludeBranchRequestControl) ProxiedAuthorizationV2RequestControl(com.unboundid.ldap.sdk.controls.ProxiedAuthorizationV2RequestControl) ServerSideSortRequestControl(com.unboundid.ldap.sdk.controls.ServerSideSortRequestControl) GetServerIDRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.GetServerIDRequestControl) PasswordPolicyRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.PasswordPolicyRequestControl) AssertionRequestControl(com.unboundid.ldap.sdk.controls.AssertionRequestControl) RouteToBackendSetRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.RouteToBackendSetRequestControl) ManageDsaITRequestControl(com.unboundid.ldap.sdk.controls.ManageDsaITRequestControl) PersistentSearchRequestControl(com.unboundid.ldap.sdk.controls.PersistentSearchRequestControl) GetEffectiveRightsRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.GetEffectiveRightsRequestControl) DraftLDUPSubentriesRequestControl(com.unboundid.ldap.sdk.controls.DraftLDUPSubentriesRequestControl) PasswordPolicyRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.PasswordPolicyRequestControl) ArrayList(java.util.ArrayList) AuthorizationIdentityRequestControl(com.unboundid.ldap.sdk.controls.AuthorizationIdentityRequestControl) SuppressType(com.unboundid.ldap.sdk.unboundidds.controls.SuppressType) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) GetRecentLoginHistoryRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.GetRecentLoginHistoryRequestControl) SuppressOperationalAttributeUpdateRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.SuppressOperationalAttributeUpdateRequestControl) GetAuthorizationEntryRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.GetAuthorizationEntryRequestControl) GetUserResourceLimitsRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.GetUserResourceLimitsRequestControl) NotNull(com.unboundid.util.NotNull)

Example 5 with PasswordPolicyRequestControl

use of com.unboundid.ldap.sdk.unboundidds.controls.PasswordPolicyRequestControl in project ldapsdk by pingidentity.

the class LDAPModify method createRequestControls.

/**
 * Populates lists of request controls that should be included in requests
 * of various types.
 *
 * @param  addControls       The list of controls to include in add requests.
 * @param  deleteControls    The list of controls to include in delete
 *                           requests.
 * @param  modifyControls    The list of controls to include in modify
 *                           requests.
 * @param  modifyDNControls  The list of controls to include in modify DN
 *                           requests.
 * @param  searchControls    The list of controls to include in search
 *                           requests.
 *
 * @throws  LDAPException  If a problem is encountered while creating any of
 *                         the requested controls.
 */
private void createRequestControls(@NotNull final List<Control> addControls, @NotNull final List<Control> deleteControls, @NotNull final List<Control> modifyControls, @NotNull final List<Control> modifyDNControls, @NotNull final List<Control> searchControls) throws LDAPException {
    if (addControl.isPresent()) {
        addControls.addAll(addControl.getValues());
    }
    if (deleteControl.isPresent()) {
        deleteControls.addAll(deleteControl.getValues());
    }
    if (modifyControl.isPresent()) {
        modifyControls.addAll(modifyControl.getValues());
    }
    if (modifyDNControl.isPresent()) {
        modifyDNControls.addAll(modifyDNControl.getValues());
    }
    if (operationControl.isPresent()) {
        addControls.addAll(operationControl.getValues());
        deleteControls.addAll(operationControl.getValues());
        modifyControls.addAll(operationControl.getValues());
        modifyDNControls.addAll(operationControl.getValues());
    }
    addControls.addAll(routeToBackendSetRequestControls);
    deleteControls.addAll(routeToBackendSetRequestControls);
    modifyControls.addAll(routeToBackendSetRequestControls);
    modifyDNControls.addAll(routeToBackendSetRequestControls);
    if (noOperation.isPresent()) {
        final NoOpRequestControl c = new NoOpRequestControl();
        addControls.add(c);
        deleteControls.add(c);
        modifyControls.add(c);
        modifyDNControls.add(c);
    }
    if (generatePassword.isPresent()) {
        addControls.add(new GeneratePasswordRequestControl());
    }
    if (getBackendSetID.isPresent()) {
        final GetBackendSetIDRequestControl c = new GetBackendSetIDRequestControl(false);
        addControls.add(c);
        deleteControls.add(c);
        modifyControls.add(c);
        modifyDNControls.add(c);
    }
    if (getServerID.isPresent()) {
        final GetServerIDRequestControl c = new GetServerIDRequestControl(false);
        addControls.add(c);
        deleteControls.add(c);
        modifyControls.add(c);
        modifyDNControls.add(c);
    }
    if (ignoreNoUserModification.isPresent()) {
        addControls.add(new IgnoreNoUserModificationRequestControl(false));
        modifyControls.add(new IgnoreNoUserModificationRequestControl(false));
    }
    if (nameWithEntryUUID.isPresent()) {
        addControls.add(new NameWithEntryUUIDRequestControl(true));
    }
    if (permissiveModify.isPresent()) {
        modifyControls.add(new PermissiveModifyRequestControl(false));
    }
    if (routeToServer.isPresent()) {
        final RouteToServerRequestControl c = new RouteToServerRequestControl(false, routeToServer.getValue(), false, false, false);
        addControls.add(c);
        deleteControls.add(c);
        modifyControls.add(c);
        modifyDNControls.add(c);
    }
    if (suppressReferentialIntegrityUpdates.isPresent()) {
        final SuppressReferentialIntegrityUpdatesRequestControl c = new SuppressReferentialIntegrityUpdatesRequestControl(true);
        deleteControls.add(c);
        modifyDNControls.add(c);
    }
    if (suppressOperationalAttributeUpdates.isPresent()) {
        final EnumSet<SuppressType> suppressTypes = EnumSet.noneOf(SuppressType.class);
        for (final String s : suppressOperationalAttributeUpdates.getValues()) {
            if (s.equalsIgnoreCase("last-access-time")) {
                suppressTypes.add(SuppressType.LAST_ACCESS_TIME);
            } else if (s.equalsIgnoreCase("last-login-time")) {
                suppressTypes.add(SuppressType.LAST_LOGIN_TIME);
            } else if (s.equalsIgnoreCase("last-login-ip")) {
                suppressTypes.add(SuppressType.LAST_LOGIN_IP);
            } else if (s.equalsIgnoreCase("lastmod")) {
                suppressTypes.add(SuppressType.LASTMOD);
            }
        }
        final SuppressOperationalAttributeUpdateRequestControl c = new SuppressOperationalAttributeUpdateRequestControl(suppressTypes);
        addControls.add(c);
        deleteControls.add(c);
        modifyControls.add(c);
        modifyDNControls.add(c);
    }
    if (usePasswordPolicyControl.isPresent()) {
        final PasswordPolicyRequestControl c = new PasswordPolicyRequestControl();
        addControls.add(c);
        modifyControls.add(c);
    }
    if (assuredReplication.isPresent()) {
        AssuredReplicationLocalLevel localLevel = null;
        if (assuredReplicationLocalLevel.isPresent()) {
            final String level = assuredReplicationLocalLevel.getValue();
            if (level.equalsIgnoreCase("none")) {
                localLevel = AssuredReplicationLocalLevel.NONE;
            } else if (level.equalsIgnoreCase("received-any-server")) {
                localLevel = AssuredReplicationLocalLevel.RECEIVED_ANY_SERVER;
            } else if (level.equalsIgnoreCase("processed-all-servers")) {
                localLevel = AssuredReplicationLocalLevel.PROCESSED_ALL_SERVERS;
            }
        }
        AssuredReplicationRemoteLevel remoteLevel = null;
        if (assuredReplicationRemoteLevel.isPresent()) {
            final String level = assuredReplicationRemoteLevel.getValue();
            if (level.equalsIgnoreCase("none")) {
                remoteLevel = AssuredReplicationRemoteLevel.NONE;
            } else if (level.equalsIgnoreCase("received-any-remote-location")) {
                remoteLevel = AssuredReplicationRemoteLevel.RECEIVED_ANY_REMOTE_LOCATION;
            } else if (level.equalsIgnoreCase("received-all-remote-locations")) {
                remoteLevel = AssuredReplicationRemoteLevel.RECEIVED_ALL_REMOTE_LOCATIONS;
            } else if (level.equalsIgnoreCase("processed-all-remote-servers")) {
                remoteLevel = AssuredReplicationRemoteLevel.PROCESSED_ALL_REMOTE_SERVERS;
            }
        }
        Long timeoutMillis = null;
        if (assuredReplicationTimeout.isPresent()) {
            timeoutMillis = assuredReplicationTimeout.getValue(TimeUnit.MILLISECONDS);
        }
        final AssuredReplicationRequestControl c = new AssuredReplicationRequestControl(true, localLevel, localLevel, remoteLevel, remoteLevel, timeoutMillis, false);
        addControls.add(c);
        deleteControls.add(c);
        modifyControls.add(c);
        modifyDNControls.add(c);
    }
    if (hardDelete.isPresent() && (!clientSideSubtreeDelete.isPresent())) {
        deleteControls.add(new HardDeleteRequestControl(true));
    }
    if (replicationRepair.isPresent()) {
        final ReplicationRepairRequestControl c = new ReplicationRepairRequestControl();
        addControls.add(c);
        deleteControls.add(c);
        modifyControls.add(c);
        modifyDNControls.add(c);
    }
    if (softDelete.isPresent()) {
        deleteControls.add(new SoftDeleteRequestControl(true, true));
    }
    if (serverSideSubtreeDelete.isPresent()) {
        deleteControls.add(new SubtreeDeleteRequestControl());
    }
    if (assertionFilter.isPresent()) {
        final AssertionRequestControl c = new AssertionRequestControl(assertionFilter.getValue(), true);
        addControls.add(c);
        deleteControls.add(c);
        modifyControls.add(c);
        modifyDNControls.add(c);
    }
    if (operationPurpose.isPresent()) {
        final OperationPurposeRequestControl c = new OperationPurposeRequestControl(false, "ldapmodify", Version.NUMERIC_VERSION_STRING, LDAPModify.class.getName() + ".createRequestControls", operationPurpose.getValue());
        addControls.add(c);
        deleteControls.add(c);
        modifyControls.add(c);
        modifyDNControls.add(c);
    }
    if (manageDsaIT.isPresent()) {
        final ManageDsaITRequestControl c = new ManageDsaITRequestControl(true);
        addControls.add(c);
        if (!clientSideSubtreeDelete.isPresent()) {
            deleteControls.add(c);
        }
        modifyControls.add(c);
        modifyDNControls.add(c);
    }
    if (passwordUpdateBehavior.isPresent()) {
        final PasswordUpdateBehaviorRequestControl c = createPasswordUpdateBehaviorRequestControl(passwordUpdateBehavior.getIdentifierString(), passwordUpdateBehavior.getValues());
        addControls.add(c);
        modifyControls.add(c);
    }
    if (preReadAttribute.isPresent()) {
        final ArrayList<String> attrList = new ArrayList<>(10);
        for (final String value : preReadAttribute.getValues()) {
            final StringTokenizer tokenizer = new StringTokenizer(value, ", ");
            while (tokenizer.hasMoreTokens()) {
                attrList.add(tokenizer.nextToken());
            }
        }
        final String[] attrArray = attrList.toArray(StaticUtils.NO_STRINGS);
        final PreReadRequestControl c = new PreReadRequestControl(attrArray);
        deleteControls.add(c);
        modifyControls.add(c);
        modifyDNControls.add(c);
    }
    if (postReadAttribute.isPresent()) {
        final ArrayList<String> attrList = new ArrayList<>(10);
        for (final String value : postReadAttribute.getValues()) {
            final StringTokenizer tokenizer = new StringTokenizer(value, ", ");
            while (tokenizer.hasMoreTokens()) {
                attrList.add(tokenizer.nextToken());
            }
        }
        final String[] attrArray = attrList.toArray(StaticUtils.NO_STRINGS);
        final PostReadRequestControl c = new PostReadRequestControl(attrArray);
        addControls.add(c);
        modifyControls.add(c);
        modifyDNControls.add(c);
    }
    if (proxyAs.isPresent() && (!useTransaction.isPresent()) && (!multiUpdateErrorBehavior.isPresent())) {
        final ProxiedAuthorizationV2RequestControl c = new ProxiedAuthorizationV2RequestControl(proxyAs.getValue());
        addControls.add(c);
        deleteControls.add(c);
        modifyControls.add(c);
        modifyDNControls.add(c);
        searchControls.add(c);
    }
    if (proxyV1As.isPresent() && (!useTransaction.isPresent()) && (!multiUpdateErrorBehavior.isPresent())) {
        final ProxiedAuthorizationV1RequestControl c = new ProxiedAuthorizationV1RequestControl(proxyV1As.getValue());
        addControls.add(c);
        deleteControls.add(c);
        modifyControls.add(c);
        modifyDNControls.add(c);
        searchControls.add(c);
    }
    if (uniquenessAttribute.isPresent() || uniquenessFilter.isPresent()) {
        final UniquenessRequestControlProperties uniquenessProperties;
        if (uniquenessAttribute.isPresent()) {
            uniquenessProperties = new UniquenessRequestControlProperties(uniquenessAttribute.getValues());
            if (uniquenessFilter.isPresent()) {
                uniquenessProperties.setFilter(uniquenessFilter.getValue());
            }
        } else {
            uniquenessProperties = new UniquenessRequestControlProperties(uniquenessFilter.getValue());
        }
        if (uniquenessBaseDN.isPresent()) {
            uniquenessProperties.setBaseDN(uniquenessBaseDN.getStringValue());
        }
        if (uniquenessMultipleAttributeBehavior.isPresent()) {
            final String value = uniquenessMultipleAttributeBehavior.getValue().toLowerCase();
            switch(value) {
                case "unique-within-each-attribute":
                    uniquenessProperties.setMultipleAttributeBehavior(UniquenessMultipleAttributeBehavior.UNIQUE_WITHIN_EACH_ATTRIBUTE);
                    break;
                case "unique-across-all-attributes-including-in-same-entry":
                    uniquenessProperties.setMultipleAttributeBehavior(UniquenessMultipleAttributeBehavior.UNIQUE_ACROSS_ALL_ATTRIBUTES_INCLUDING_IN_SAME_ENTRY);
                    break;
                case "unique-across-all-attributes-except-in-same-entry":
                    uniquenessProperties.setMultipleAttributeBehavior(UniquenessMultipleAttributeBehavior.UNIQUE_ACROSS_ALL_ATTRIBUTES_EXCEPT_IN_SAME_ENTRY);
                    break;
                case "unique-in-combination":
                    uniquenessProperties.setMultipleAttributeBehavior(UniquenessMultipleAttributeBehavior.UNIQUE_IN_COMBINATION);
                    break;
            }
        }
        if (uniquenessPreCommitValidationLevel.isPresent()) {
            final String value = uniquenessPreCommitValidationLevel.getValue().toLowerCase();
            switch(value) {
                case "none":
                    uniquenessProperties.setPreCommitValidationLevel(UniquenessValidationLevel.NONE);
                    break;
                case "all-subtree-views":
                    uniquenessProperties.setPreCommitValidationLevel(UniquenessValidationLevel.ALL_SUBTREE_VIEWS);
                    break;
                case "all-backend-sets":
                    uniquenessProperties.setPreCommitValidationLevel(UniquenessValidationLevel.ALL_BACKEND_SETS);
                    break;
                case "all-available-backend-servers":
                    uniquenessProperties.setPreCommitValidationLevel(UniquenessValidationLevel.ALL_AVAILABLE_BACKEND_SERVERS);
                    break;
            }
        }
        if (uniquenessPostCommitValidationLevel.isPresent()) {
            final String value = uniquenessPostCommitValidationLevel.getValue().toLowerCase();
            switch(value) {
                case "none":
                    uniquenessProperties.setPostCommitValidationLevel(UniquenessValidationLevel.NONE);
                    break;
                case "all-subtree-views":
                    uniquenessProperties.setPostCommitValidationLevel(UniquenessValidationLevel.ALL_SUBTREE_VIEWS);
                    break;
                case "all-backend-sets":
                    uniquenessProperties.setPostCommitValidationLevel(UniquenessValidationLevel.ALL_BACKEND_SETS);
                    break;
                case "all-available-backend-servers":
                    uniquenessProperties.setPostCommitValidationLevel(UniquenessValidationLevel.ALL_AVAILABLE_BACKEND_SERVERS);
                    break;
            }
        }
        final UniquenessRequestControl c = new UniquenessRequestControl(true, null, uniquenessProperties);
        addControls.add(c);
        modifyControls.add(c);
        modifyDNControls.add(c);
    }
}
Also used : RouteToServerRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.RouteToServerRequestControl) UniquenessRequestControlProperties(com.unboundid.ldap.sdk.unboundidds.controls.UniquenessRequestControlProperties) AssuredReplicationRemoteLevel(com.unboundid.ldap.sdk.unboundidds.controls.AssuredReplicationRemoteLevel) AssuredReplicationRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.AssuredReplicationRequestControl) ArrayList(java.util.ArrayList) ProxiedAuthorizationV2RequestControl(com.unboundid.ldap.sdk.controls.ProxiedAuthorizationV2RequestControl) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) PreReadRequestControl(com.unboundid.ldap.sdk.controls.PreReadRequestControl) PermissiveModifyRequestControl(com.unboundid.ldap.sdk.controls.PermissiveModifyRequestControl) NameWithEntryUUIDRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.NameWithEntryUUIDRequestControl) AssertionRequestControl(com.unboundid.ldap.sdk.controls.AssertionRequestControl) HardDeleteRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.HardDeleteRequestControl) ReplicationRepairRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.ReplicationRepairRequestControl) IgnoreNoUserModificationRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.IgnoreNoUserModificationRequestControl) GetServerIDRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.GetServerIDRequestControl) ManageDsaITRequestControl(com.unboundid.ldap.sdk.controls.ManageDsaITRequestControl) SuppressReferentialIntegrityUpdatesRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.SuppressReferentialIntegrityUpdatesRequestControl) NoOpRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.NoOpRequestControl) SoftDeleteRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.SoftDeleteRequestControl) SuppressType(com.unboundid.ldap.sdk.unboundidds.controls.SuppressType) SuppressOperationalAttributeUpdateRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.SuppressOperationalAttributeUpdateRequestControl) OperationPurposeRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.OperationPurposeRequestControl) ProxiedAuthorizationV1RequestControl(com.unboundid.ldap.sdk.controls.ProxiedAuthorizationV1RequestControl) StringTokenizer(java.util.StringTokenizer) PasswordPolicyRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.PasswordPolicyRequestControl) GeneratePasswordRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.GeneratePasswordRequestControl) GetBackendSetIDRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.GetBackendSetIDRequestControl) AssuredReplicationLocalLevel(com.unboundid.ldap.sdk.unboundidds.controls.AssuredReplicationLocalLevel) PasswordUpdateBehaviorRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.PasswordUpdateBehaviorRequestControl) PostReadRequestControl(com.unboundid.ldap.sdk.controls.PostReadRequestControl) SubtreeDeleteRequestControl(com.unboundid.ldap.sdk.controls.SubtreeDeleteRequestControl) UniquenessRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.UniquenessRequestControl)

Aggregations

PasswordPolicyRequestControl (com.unboundid.ldap.sdk.unboundidds.controls.PasswordPolicyRequestControl)5 Control (com.unboundid.ldap.sdk.Control)4 OperationPurposeRequestControl (com.unboundid.ldap.sdk.unboundidds.controls.OperationPurposeRequestControl)4 ArrayList (java.util.ArrayList)4 ASN1OctetString (com.unboundid.asn1.ASN1OctetString)3 AssertionRequestControl (com.unboundid.ldap.sdk.controls.AssertionRequestControl)3 AuthorizationIdentityRequestControl (com.unboundid.ldap.sdk.controls.AuthorizationIdentityRequestControl)3 ManageDsaITRequestControl (com.unboundid.ldap.sdk.controls.ManageDsaITRequestControl)3 ProxiedAuthorizationV1RequestControl (com.unboundid.ldap.sdk.controls.ProxiedAuthorizationV1RequestControl)3 ProxiedAuthorizationV2RequestControl (com.unboundid.ldap.sdk.controls.ProxiedAuthorizationV2RequestControl)3 AssuredReplicationRequestControl (com.unboundid.ldap.sdk.unboundidds.controls.AssuredReplicationRequestControl)3 GetAuthorizationEntryRequestControl (com.unboundid.ldap.sdk.unboundidds.controls.GetAuthorizationEntryRequestControl)3 GetBackendSetIDRequestControl (com.unboundid.ldap.sdk.unboundidds.controls.GetBackendSetIDRequestControl)3 GetServerIDRequestControl (com.unboundid.ldap.sdk.unboundidds.controls.GetServerIDRequestControl)3 GetUserResourceLimitsRequestControl (com.unboundid.ldap.sdk.unboundidds.controls.GetUserResourceLimitsRequestControl)3 PermissiveModifyRequestControl (com.unboundid.ldap.sdk.controls.PermissiveModifyRequestControl)2 PostReadRequestControl (com.unboundid.ldap.sdk.controls.PostReadRequestControl)2 PreReadRequestControl (com.unboundid.ldap.sdk.controls.PreReadRequestControl)2 SimplePagedResultsControl (com.unboundid.ldap.sdk.controls.SimplePagedResultsControl)2 SubtreeDeleteRequestControl (com.unboundid.ldap.sdk.controls.SubtreeDeleteRequestControl)2