Search in sources :

Example 1 with PasswordUpdateBehaviorRequestControlProperties

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

the class ParallelUpdate method getOperationControls.

/**
 * Updates the provided lists with the appropriate controls to include in
 * each type of request.
 *
 * @param  addControls       The list that should be updated with controls to
 *                           include in add requests.  It must not be
 *                           {@code null} and must be updatable.
 * @param  deleteControls    The list that should be updated with controls to
 *                           include in delete requests.  It must not be
 *                           {@code null} and must be updatable.
 * @param  modifyControls    The list that should be updated with controls to
 *                           include in modify requests.  It must not be
 *                           {@code null} and must be updatable.
 * @param  modifyDNControls  The list that should be updated with controls to
 *                           include in modify DN requests.  It must not be
 *                           {@code null} and must be updatable.
 *
 * @throws  LDAPException  If a problem is encountered while creating any of
 *                         the controls.
 */
private void getOperationControls(@NotNull final List<Control> addControls, @NotNull final List<Control> deleteControls, @NotNull final List<Control> modifyControls, @NotNull final List<Control> modifyDNControls) throws LDAPException {
    if (addControlArg.isPresent()) {
        addControls.addAll(addControlArg.getValues());
    }
    if (deleteControlArg.isPresent()) {
        deleteControls.addAll(deleteControlArg.getValues());
    }
    if (modifyControlArg.isPresent()) {
        modifyControls.addAll(modifyControlArg.getValues());
    }
    if (modifyDNControlArg.isPresent()) {
        modifyDNControls.addAll(modifyDNControlArg.getValues());
    }
    if (proxyAsArg.isPresent()) {
        final ProxiedAuthorizationV2RequestControl c = new ProxiedAuthorizationV2RequestControl(proxyAsArg.getValue());
        addControls.add(c);
        deleteControls.add(c);
        modifyControls.add(c);
        modifyDNControls.add(c);
    } else if (proxyV1AsArg.isPresent()) {
        final ProxiedAuthorizationV1RequestControl c = new ProxiedAuthorizationV1RequestControl(proxyV1AsArg.getValue());
        addControls.add(c);
        deleteControls.add(c);
        modifyControls.add(c);
        modifyDNControls.add(c);
    }
    if (usePermissiveModifyArg.isPresent()) {
        modifyControls.add(new PermissiveModifyRequestControl(true));
    }
    if (ignoreNoUserModificationArg.isPresent()) {
        final IgnoreNoUserModificationRequestControl c = new IgnoreNoUserModificationRequestControl();
        addControls.add(c);
        modifyControls.add(c);
    }
    if (useManageDsaITArg.isPresent()) {
        final ManageDsaITRequestControl c = new ManageDsaITRequestControl(true);
        addControls.add(c);
        deleteControls.add(c);
        modifyControls.add(c);
        modifyDNControls.add(c);
    }
    if (nameWithEntryUUIDArg.isPresent()) {
        addControls.add(new NameWithEntryUUIDRequestControl(true));
    }
    if (softDeleteArg.isPresent()) {
        deleteControls.add(new SoftDeleteRequestControl(true, true));
    } else if (hardDeleteArg.isPresent()) {
        deleteControls.add(new HardDeleteRequestControl(true));
    }
    if (operationPurposeArg.isPresent()) {
        final OperationPurposeRequestControl c = new OperationPurposeRequestControl(false, "parallel-update", Version.NUMERIC_VERSION_STRING, ParallelUpdate.class.getName() + ".getOperationControls", operationPurposeArg.getValue());
        addControls.add(c);
        deleteControls.add(c);
        modifyControls.add(c);
        modifyDNControls.add(c);
    }
    if (replicationRepairArg.isPresent()) {
        final ReplicationRepairRequestControl c = new ReplicationRepairRequestControl();
        addControls.add(c);
        deleteControls.add(c);
        modifyControls.add(c);
        modifyDNControls.add(c);
    }
    if (suppressReferentialIntegrityUpdatesArg.isPresent()) {
        final SuppressReferentialIntegrityUpdatesRequestControl c = new SuppressReferentialIntegrityUpdatesRequestControl(true);
        deleteControls.add(c);
        modifyDNControls.add(c);
    }
    if (useAssuredReplicationArg.isPresent()) {
        final AssuredReplicationLocalLevel localLevel;
        if (assuredReplicationLocalLevelArg.isPresent()) {
            final String localLevelStr = StaticUtils.toLowerCase(assuredReplicationLocalLevelArg.getValue());
            switch(localLevelStr) {
                case ASSURED_REPLICATION_LOCAL_LEVEL_NONE:
                    localLevel = AssuredReplicationLocalLevel.NONE;
                    break;
                case ASSURED_REPLICATION_LOCAL_LEVEL_RECEIVED_ANY_SERVER:
                    localLevel = AssuredReplicationLocalLevel.RECEIVED_ANY_SERVER;
                    break;
                case ASSURED_REPLICATION_LOCAL_LEVEL_PROCESSED_ALL_SERVERS:
                    localLevel = AssuredReplicationLocalLevel.PROCESSED_ALL_SERVERS;
                    break;
                default:
                    // This should never happen.
                    localLevel = null;
                    break;
            }
        } else {
            localLevel = null;
        }
        final AssuredReplicationRemoteLevel remoteLevel;
        if (assuredReplicationRemoteLevelArg.isPresent()) {
            final String remoteLevelStr = StaticUtils.toLowerCase(assuredReplicationRemoteLevelArg.getValue());
            switch(remoteLevelStr) {
                case ASSURED_REPLICATION_REMOTE_LEVEL_NONE:
                    remoteLevel = AssuredReplicationRemoteLevel.NONE;
                    break;
                case ASSURED_REPLICATION_REMOTE_LEVEL_RECEIVED_ANY_REMOTE_LOCATION:
                    remoteLevel = AssuredReplicationRemoteLevel.RECEIVED_ANY_REMOTE_LOCATION;
                    break;
                case ASSURED_REPLICATION_REMOTE_LEVEL_RECEIVED_ALL_REMOTE_LOCATIONS:
                    remoteLevel = AssuredReplicationRemoteLevel.RECEIVED_ALL_REMOTE_LOCATIONS;
                    break;
                case ASSURED_REPLICATION_REMOTE_LEVEL_PROCESSED_ALL_REMOTE_SERVERS:
                    remoteLevel = AssuredReplicationRemoteLevel.PROCESSED_ALL_REMOTE_SERVERS;
                    break;
                default:
                    // This should never happen.
                    remoteLevel = null;
                    break;
            }
        } else {
            remoteLevel = null;
        }
        final Long timeoutMillis;
        if (assuredReplicationTimeoutArg.isPresent()) {
            timeoutMillis = assuredReplicationTimeoutArg.getValue(TimeUnit.MILLISECONDS);
        } else {
            timeoutMillis = null;
        }
        final AssuredReplicationRequestControl c = new AssuredReplicationRequestControl(true, localLevel, null, remoteLevel, null, timeoutMillis, false);
        addControls.add(c);
        deleteControls.add(c);
        modifyControls.add(c);
        modifyDNControls.add(c);
    }
    if (passwordUpdateBehaviorArg.isPresent()) {
        final PasswordUpdateBehaviorRequestControlProperties properties = new PasswordUpdateBehaviorRequestControlProperties();
        for (final String argValue : passwordUpdateBehaviorArg.getValues()) {
            final int equalPos = argValue.indexOf('=');
            if (equalPos < 0) {
                throw new LDAPException(ResultCode.PARAM_ERROR, ERR_PARALLEL_UPDATE_MALFORMED_PW_UPDATE_VALUE.get(argValue, passwordUpdateBehaviorArg.getIdentifierString()));
            }
            final String propertyName = argValue.substring(0, equalPos).trim();
            final String lowerName = StaticUtils.toLowerCase(propertyName);
            switch(lowerName) {
                case PW_UPDATE_BEHAVIOR_NAME_IS_SELF_CHANGE:
                    properties.setIsSelfChange(getBooleanPWUpdateBehaviorValue(argValue));
                    break;
                case PW_UPDATE_BEHAVIOR_NAME_ALLOW_PRE_ENCODED_PW:
                    properties.setAllowPreEncodedPassword(getBooleanPWUpdateBehaviorValue(argValue));
                    break;
                case PW_UPDATE_BEHAVIOR_NAME_SKIP_PW_VALIDATION:
                    properties.setSkipPasswordValidation(getBooleanPWUpdateBehaviorValue(argValue));
                    break;
                case PW_UPDATE_BEHAVIOR_NAME_IGNORE_PW_HISTORY:
                    properties.setIgnorePasswordHistory(getBooleanPWUpdateBehaviorValue(argValue));
                    break;
                case PW_UPDATE_BEHAVIOR_NAME_IGNORE_MIN_PW_AGE:
                    properties.setIgnoreMinimumPasswordAge(getBooleanPWUpdateBehaviorValue(argValue));
                    break;
                case PW_UPDATE_BEHAVIOR_NAME_MUST_CHANGE_PW:
                    properties.setMustChangePassword(getBooleanPWUpdateBehaviorValue(argValue));
                    break;
                case PW_UPDATE_BEHAVIOR_NAME_PW_STORAGE_SCHEME:
                    final String propertyValue = argValue.substring(equalPos + 1).trim();
                    properties.setPasswordStorageScheme(propertyValue);
                    break;
                default:
                    throw new LDAPException(ResultCode.PARAM_ERROR, ERR_PARALLEL_UPDATE_UNKNOWN_PW_UPDATE_PROP.get(argValue, passwordUpdateBehaviorArg.getIdentifierString(), PW_UPDATE_BEHAVIOR_NAME_IS_SELF_CHANGE, PW_UPDATE_BEHAVIOR_NAME_ALLOW_PRE_ENCODED_PW, PW_UPDATE_BEHAVIOR_NAME_SKIP_PW_VALIDATION, PW_UPDATE_BEHAVIOR_NAME_IGNORE_PW_HISTORY, PW_UPDATE_BEHAVIOR_NAME_IGNORE_MIN_PW_AGE, PW_UPDATE_BEHAVIOR_NAME_PW_STORAGE_SCHEME, PW_UPDATE_BEHAVIOR_NAME_MUST_CHANGE_PW));
            }
        }
        final PasswordUpdateBehaviorRequestControl c = new PasswordUpdateBehaviorRequestControl(properties, true);
        addControls.add(c);
        modifyControls.add(c);
    }
    if (suppressOperationalAttributeUpdatesArg.isPresent()) {
        final EnumSet<SuppressType> suppressTypes = EnumSet.noneOf(SuppressType.class);
        for (final String s : suppressOperationalAttributeUpdatesArg.getValues()) {
            if (s.equalsIgnoreCase(SUPPRESS_OP_ATTR_LAST_ACCESS_TIME)) {
                suppressTypes.add(SuppressType.LAST_ACCESS_TIME);
            } else if (s.equalsIgnoreCase(SUPPRESS_OP_ATTR_LAST_LOGIN_TIME)) {
                suppressTypes.add(SuppressType.LAST_LOGIN_TIME);
            } else if (s.equalsIgnoreCase(SUPPRESS_OP_ATTR_LAST_LOGIN_IP)) {
                suppressTypes.add(SuppressType.LAST_LOGIN_IP);
            }
        }
        final SuppressOperationalAttributeUpdateRequestControl c = new SuppressOperationalAttributeUpdateRequestControl(true, suppressTypes);
        addControls.add(c);
        deleteControls.add(c);
        modifyControls.add(c);
        modifyDNControls.add(c);
    }
}
Also used : SuppressReferentialIntegrityUpdatesRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.SuppressReferentialIntegrityUpdatesRequestControl) AssuredReplicationRemoteLevel(com.unboundid.ldap.sdk.unboundidds.controls.AssuredReplicationRemoteLevel) SoftDeleteRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.SoftDeleteRequestControl) AssuredReplicationRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.AssuredReplicationRequestControl) PasswordUpdateBehaviorRequestControlProperties(com.unboundid.ldap.sdk.unboundidds.controls.PasswordUpdateBehaviorRequestControlProperties) ProxiedAuthorizationV2RequestControl(com.unboundid.ldap.sdk.controls.ProxiedAuthorizationV2RequestControl) SuppressType(com.unboundid.ldap.sdk.unboundidds.controls.SuppressType) SuppressOperationalAttributeUpdateRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.SuppressOperationalAttributeUpdateRequestControl) PermissiveModifyRequestControl(com.unboundid.ldap.sdk.controls.PermissiveModifyRequestControl) OperationPurposeRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.OperationPurposeRequestControl) ProxiedAuthorizationV1RequestControl(com.unboundid.ldap.sdk.controls.ProxiedAuthorizationV1RequestControl) NameWithEntryUUIDRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.NameWithEntryUUIDRequestControl) LDAPException(com.unboundid.ldap.sdk.LDAPException) HardDeleteRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.HardDeleteRequestControl) ReplicationRepairRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.ReplicationRepairRequestControl) IgnoreNoUserModificationRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.IgnoreNoUserModificationRequestControl) AtomicLong(java.util.concurrent.atomic.AtomicLong) AssuredReplicationLocalLevel(com.unboundid.ldap.sdk.unboundidds.controls.AssuredReplicationLocalLevel) PasswordUpdateBehaviorRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.PasswordUpdateBehaviorRequestControl) ManageDsaITRequestControl(com.unboundid.ldap.sdk.controls.ManageDsaITRequestControl)

Example 2 with PasswordUpdateBehaviorRequestControlProperties

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

the class LDAPModify method createPasswordUpdateBehaviorRequestControl.

/**
 * Creates the password update behavior request control that should be
 * included in add and modify requests.
 *
 * @param  argIdentifier  The identifier string for the argument used to
 *                        configure the password update behavior request
 *                        control.
 * @param  argValues      The set of values for the password update behavior
 *                        request control.
 *
 * @return  The password update behavior request control that was created.
 *
 * @throws  LDAPException  If a problem is encountered while creating the
 *                         control.
 */
@NotNull()
static PasswordUpdateBehaviorRequestControl createPasswordUpdateBehaviorRequestControl(@NotNull final String argIdentifier, @NotNull final List<String> argValues) throws LDAPException {
    final PasswordUpdateBehaviorRequestControlProperties properties = new PasswordUpdateBehaviorRequestControlProperties();
    for (final String argValue : argValues) {
        int delimiterPos = argValue.indexOf('=');
        if (delimiterPos < 0) {
            delimiterPos = argValue.indexOf(':');
        }
        if ((delimiterPos <= 0) || (delimiterPos >= (argValue.length() - 1))) {
            throw new LDAPException(ResultCode.PARAM_ERROR, ERR_LDAPMODIFY_MALFORMED_PW_UPDATE_BEHAVIOR.get(argValue, argIdentifier));
        }
        final String name = argValue.substring(0, delimiterPos).trim();
        final String value = argValue.substring(delimiterPos + 1).trim();
        if (name.equalsIgnoreCase("is-self-change") || name.equalsIgnoreCase("self-change") || name.equalsIgnoreCase("isSelfChange") || name.equalsIgnoreCase("selfChange")) {
            properties.setIsSelfChange(parseBooleanValue(name, value));
        } else if (name.equalsIgnoreCase("allow-pre-encoded-password") || name.equalsIgnoreCase("allow-pre-encoded-passwords") || name.equalsIgnoreCase("allow-pre-encoded") || name.equalsIgnoreCase("allowPreEncodedPassword") || name.equalsIgnoreCase("allowPreEncodedPasswords") || name.equalsIgnoreCase("allowPreEncoded")) {
            properties.setAllowPreEncodedPassword(parseBooleanValue(name, value));
        } else if (name.equalsIgnoreCase("skip-password-validation") || name.equalsIgnoreCase("skip-password-validators") || name.equalsIgnoreCase("skip-validation") || name.equalsIgnoreCase("skip-validators") || name.equalsIgnoreCase("skipPasswordValidation") || name.equalsIgnoreCase("skipPasswordValidators") || name.equalsIgnoreCase("skipValidation") || name.equalsIgnoreCase("skipValidators")) {
            properties.setSkipPasswordValidation(parseBooleanValue(name, value));
        } else if (name.equalsIgnoreCase("ignore-password-history") || name.equalsIgnoreCase("skip-password-history") || name.equalsIgnoreCase("ignore-history") || name.equalsIgnoreCase("skip-history") || name.equalsIgnoreCase("ignorePasswordHistory") || name.equalsIgnoreCase("skipPasswordHistory") || name.equalsIgnoreCase("ignoreHistory") || name.equalsIgnoreCase("skipHistory")) {
            properties.setIgnorePasswordHistory(parseBooleanValue(name, value));
        } else if (name.equalsIgnoreCase("ignore-minimum-password-age") || name.equalsIgnoreCase("ignore-min-password-age") || name.equalsIgnoreCase("ignore-password-age") || name.equalsIgnoreCase("skip-minimum-password-age") || name.equalsIgnoreCase("skip-min-password-age") || name.equalsIgnoreCase("skip-password-age") || name.equalsIgnoreCase("ignoreMinimumPasswordAge") || name.equalsIgnoreCase("ignoreMinPasswordAge") || name.equalsIgnoreCase("ignorePasswordAge") || name.equalsIgnoreCase("skipMinimumPasswordAge") || name.equalsIgnoreCase("skipMinPasswordAge") || name.equalsIgnoreCase("skipPasswordAge")) {
            properties.setIgnoreMinimumPasswordAge(parseBooleanValue(name, value));
        } else if (name.equalsIgnoreCase("password-storage-scheme") || name.equalsIgnoreCase("password-scheme") || name.equalsIgnoreCase("storage-scheme") || name.equalsIgnoreCase("scheme") || name.equalsIgnoreCase("passwordStorageScheme") || name.equalsIgnoreCase("passwordScheme") || name.equalsIgnoreCase("storageScheme")) {
            properties.setPasswordStorageScheme(value);
        } else if (name.equalsIgnoreCase("must-change-password") || name.equalsIgnoreCase("mustChangePassword")) {
            properties.setMustChangePassword(parseBooleanValue(name, value));
        }
    }
    return new PasswordUpdateBehaviorRequestControl(properties, true);
}
Also used : LDAPException(com.unboundid.ldap.sdk.LDAPException) PasswordUpdateBehaviorRequestControlProperties(com.unboundid.ldap.sdk.unboundidds.controls.PasswordUpdateBehaviorRequestControlProperties) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) PasswordUpdateBehaviorRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.PasswordUpdateBehaviorRequestControl) NotNull(com.unboundid.util.NotNull)

Aggregations

LDAPException (com.unboundid.ldap.sdk.LDAPException)2 PasswordUpdateBehaviorRequestControl (com.unboundid.ldap.sdk.unboundidds.controls.PasswordUpdateBehaviorRequestControl)2 PasswordUpdateBehaviorRequestControlProperties (com.unboundid.ldap.sdk.unboundidds.controls.PasswordUpdateBehaviorRequestControlProperties)2 ASN1OctetString (com.unboundid.asn1.ASN1OctetString)1 ManageDsaITRequestControl (com.unboundid.ldap.sdk.controls.ManageDsaITRequestControl)1 PermissiveModifyRequestControl (com.unboundid.ldap.sdk.controls.PermissiveModifyRequestControl)1 ProxiedAuthorizationV1RequestControl (com.unboundid.ldap.sdk.controls.ProxiedAuthorizationV1RequestControl)1 ProxiedAuthorizationV2RequestControl (com.unboundid.ldap.sdk.controls.ProxiedAuthorizationV2RequestControl)1 AssuredReplicationLocalLevel (com.unboundid.ldap.sdk.unboundidds.controls.AssuredReplicationLocalLevel)1 AssuredReplicationRemoteLevel (com.unboundid.ldap.sdk.unboundidds.controls.AssuredReplicationRemoteLevel)1 AssuredReplicationRequestControl (com.unboundid.ldap.sdk.unboundidds.controls.AssuredReplicationRequestControl)1 HardDeleteRequestControl (com.unboundid.ldap.sdk.unboundidds.controls.HardDeleteRequestControl)1 IgnoreNoUserModificationRequestControl (com.unboundid.ldap.sdk.unboundidds.controls.IgnoreNoUserModificationRequestControl)1 NameWithEntryUUIDRequestControl (com.unboundid.ldap.sdk.unboundidds.controls.NameWithEntryUUIDRequestControl)1 OperationPurposeRequestControl (com.unboundid.ldap.sdk.unboundidds.controls.OperationPurposeRequestControl)1 ReplicationRepairRequestControl (com.unboundid.ldap.sdk.unboundidds.controls.ReplicationRepairRequestControl)1 SoftDeleteRequestControl (com.unboundid.ldap.sdk.unboundidds.controls.SoftDeleteRequestControl)1 SuppressOperationalAttributeUpdateRequestControl (com.unboundid.ldap.sdk.unboundidds.controls.SuppressOperationalAttributeUpdateRequestControl)1 SuppressReferentialIntegrityUpdatesRequestControl (com.unboundid.ldap.sdk.unboundidds.controls.SuppressReferentialIntegrityUpdatesRequestControl)1 SuppressType (com.unboundid.ldap.sdk.unboundidds.controls.SuppressType)1