Search in sources :

Example 1 with OperationPurposeRequestControl

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

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

the class LDAPSearch method getSearchControls.

/**
 * Retrieves a list of the controls that should be used when processing search
 * operations.
 *
 * @return  A list of the controls that should be used when processing search
 *          operations.
 *
 * @throws  LDAPException  If a problem is encountered while generating the
 *                         controls for a search request.
 */
@NotNull()
private List<Control> getSearchControls() {
    final ArrayList<Control> controls = new ArrayList<>(10);
    if (searchControl.isPresent()) {
        controls.addAll(searchControl.getValues());
    }
    if (joinRequestControl != null) {
        controls.add(joinRequestControl);
    }
    if (matchedValuesRequestControl != null) {
        controls.add(matchedValuesRequestControl);
    }
    if (matchingEntryCountRequestControl != null) {
        controls.add(matchingEntryCountRequestControl);
    }
    if (overrideSearchLimitsRequestControl != null) {
        controls.add(overrideSearchLimitsRequestControl);
    }
    if (persistentSearchRequestControl != null) {
        controls.add(persistentSearchRequestControl);
    }
    if (sortRequestControl != null) {
        controls.add(sortRequestControl);
    }
    if (vlvRequestControl != null) {
        controls.add(vlvRequestControl);
    }
    controls.addAll(routeToBackendSetRequestControls);
    if (accountUsable.isPresent()) {
        controls.add(new AccountUsableRequestControl(true));
    }
    if (getBackendSetID.isPresent()) {
        controls.add(new GetBackendSetIDRequestControl(false));
    }
    if (getServerID.isPresent()) {
        controls.add(new GetServerIDRequestControl(false));
    }
    if (includeReplicationConflictEntries.isPresent()) {
        controls.add(new ReturnConflictEntriesRequestControl(true));
    }
    if (includeSoftDeletedEntries.isPresent()) {
        final String valueStr = StaticUtils.toLowerCase(includeSoftDeletedEntries.getValue());
        if (valueStr.equals("with-non-deleted-entries")) {
            controls.add(new SoftDeletedEntryAccessRequestControl(true, true, false));
        } else if (valueStr.equals("without-non-deleted-entries")) {
            controls.add(new SoftDeletedEntryAccessRequestControl(true, false, false));
        } else {
            controls.add(new SoftDeletedEntryAccessRequestControl(true, false, true));
        }
    }
    if (draftLDUPSubentries.isPresent()) {
        controls.add(new DraftLDUPSubentriesRequestControl(true));
    }
    if (rfc3672Subentries.isPresent()) {
        controls.add(new RFC3672SubentriesRequestControl(rfc3672Subentries.getValue()));
    }
    if (manageDsaIT.isPresent()) {
        controls.add(new ManageDsaITRequestControl(true));
    }
    if (realAttributesOnly.isPresent()) {
        controls.add(new RealAttributesOnlyRequestControl(true));
    }
    if (routeToServer.isPresent()) {
        controls.add(new RouteToServerRequestControl(false, routeToServer.getValue(), false, false, false));
    }
    if (virtualAttributesOnly.isPresent()) {
        controls.add(new VirtualAttributesOnlyRequestControl(true));
    }
    if (excludeBranch.isPresent()) {
        final ArrayList<String> dns = new ArrayList<>(excludeBranch.getValues().size());
        for (final DN dn : excludeBranch.getValues()) {
            dns.add(dn.toString());
        }
        controls.add(new ExcludeBranchRequestControl(true, dns));
    }
    if (assertionFilter.isPresent()) {
        controls.add(new AssertionRequestControl(assertionFilter.getValue(), true));
    }
    if (getEffectiveRightsAuthzID.isPresent()) {
        final String[] attributes;
        if (getEffectiveRightsAttribute.isPresent()) {
            attributes = new String[getEffectiveRightsAttribute.getValues().size()];
            for (int i = 0; i < attributes.length; i++) {
                attributes[i] = getEffectiveRightsAttribute.getValues().get(i);
            }
        } else {
            attributes = StaticUtils.NO_STRINGS;
        }
        controls.add(new GetEffectiveRightsRequestControl(true, getEffectiveRightsAuthzID.getValue(), attributes));
    }
    if (operationPurpose.isPresent()) {
        controls.add(new OperationPurposeRequestControl(true, "ldapsearch", Version.NUMERIC_VERSION_STRING, "LDAPSearch.getSearchControls", operationPurpose.getValue()));
    }
    if (proxyAs.isPresent()) {
        controls.add(new ProxiedAuthorizationV2RequestControl(proxyAs.getValue()));
    }
    if (proxyV1As.isPresent()) {
        controls.add(new ProxiedAuthorizationV1RequestControl(proxyV1As.getValue()));
    }
    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);
            }
        }
        controls.add(new SuppressOperationalAttributeUpdateRequestControl(suppressTypes));
    }
    if (rejectUnindexedSearch.isPresent()) {
        controls.add(new RejectUnindexedSearchRequestControl());
    }
    if (permitUnindexedSearch.isPresent()) {
        controls.add(new PermitUnindexedSearchRequestControl());
    }
    return controls;
}
Also used : RouteToServerRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.RouteToServerRequestControl) ArrayList(java.util.ArrayList) ProxiedAuthorizationV2RequestControl(com.unboundid.ldap.sdk.controls.ProxiedAuthorizationV2RequestControl) JoinBaseDN(com.unboundid.ldap.sdk.unboundidds.controls.JoinBaseDN) DN(com.unboundid.ldap.sdk.DN) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) GetEffectiveRightsRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.GetEffectiveRightsRequestControl) 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) AssertionRequestControl(com.unboundid.ldap.sdk.controls.AssertionRequestControl) DraftLDUPSubentriesRequestControl(com.unboundid.ldap.sdk.controls.DraftLDUPSubentriesRequestControl) SoftDeletedEntryAccessRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.SoftDeletedEntryAccessRequestControl) GetServerIDRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.GetServerIDRequestControl) ManageDsaITRequestControl(com.unboundid.ldap.sdk.controls.ManageDsaITRequestControl) AccountUsableRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.AccountUsableRequestControl) PermitUnindexedSearchRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.PermitUnindexedSearchRequestControl) ReturnConflictEntriesRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.ReturnConflictEntriesRequestControl) RealAttributesOnlyRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.RealAttributesOnlyRequestControl) 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) RFC3672SubentriesRequestControl(com.unboundid.ldap.sdk.controls.RFC3672SubentriesRequestControl) GetBackendSetIDRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.GetBackendSetIDRequestControl) ExcludeBranchRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.ExcludeBranchRequestControl) RejectUnindexedSearchRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.RejectUnindexedSearchRequestControl) VirtualAttributesOnlyRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.VirtualAttributesOnlyRequestControl) NotNull(com.unboundid.util.NotNull)

Example 3 with OperationPurposeRequestControl

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

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

the class AuditLogMessage method decodeOperationPurposeRequestControl.

/**
 * Decodes the operation purpose request control, if any, from the provided
 * set of name-value pairs.
 *
 * @param  nameValuePairs  The map containing the header properties as
 *                         name-value pairs.  It must not be {@code null}.
 *
 * @return  The operation purpose request control retrieved and decoded from
 *          the provided set of name-value pairs, or {@code null} if no
 *          valid operation purpose request control was included.
 */
@Nullable()
private static OperationPurposeRequestControl decodeOperationPurposeRequestControl(@NotNull final Map<String, String> nameValuePairs) {
    final String valueString = nameValuePairs.get("operationPurpose");
    if (valueString == null) {
        return null;
    }
    try {
        final JSONObject o = new JSONObject(valueString);
        final String applicationName = o.getFieldAsString("applicationName");
        final String applicationVersion = o.getFieldAsString("applicationVersion");
        final String codeLocation = o.getFieldAsString("codeLocation");
        final String requestPurpose = o.getFieldAsString("requestPurpose");
        return new OperationPurposeRequestControl(false, applicationName, applicationVersion, codeLocation, requestPurpose);
    } catch (final Exception e) {
        Debug.debugException(e);
        return null;
    }
}
Also used : OperationPurposeRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.OperationPurposeRequestControl) JSONObject(com.unboundid.util.json.JSONObject) ParseException(java.text.ParseException) Nullable(com.unboundid.util.Nullable)

Example 5 with OperationPurposeRequestControl

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

the class MoveSubtree method getAuthenticatedUserDN.

/**
 * Retrieves the DN of the user authenticated on the provided connection.  It
 * will first try to look at the last successful bind request processed on the
 * connection, and will fall back to using the "Who Am I?" extended request.
 *
 * @param  connection        The connection for which to make the
 *                           determination.
 * @param  isSource          Indicates whether the connection is to the source
 *                           or target server.
 * @param  opPurposeControl  An optional operation purpose request control
 *                           that may be included in the request.
 *
 * @return  The DN of the user authenticated on the provided connection, or
 *          {@code null} if the connection is not authenticated.
 *
 * @throws  LDAPException  If a problem is encountered while making the
 *                         determination.
 */
@Nullable()
private static String getAuthenticatedUserDN(@NotNull final LDAPConnection connection, final boolean isSource, @Nullable final OperationPurposeRequestControl opPurposeControl) throws LDAPException {
    final BindRequest bindRequest = InternalSDKHelper.getLastBindRequest(connection);
    if ((bindRequest != null) && (bindRequest instanceof SimpleBindRequest)) {
        final SimpleBindRequest r = (SimpleBindRequest) bindRequest;
        return r.getBindDN();
    }
    final Control[] controls;
    if (opPurposeControl == null) {
        controls = StaticUtils.NO_CONTROLS;
    } else {
        controls = new Control[] { opPurposeControl };
    }
    final String connectionName = isSource ? INFO_MOVE_SUBTREE_CONNECTION_NAME_SOURCE.get() : INFO_MOVE_SUBTREE_CONNECTION_NAME_TARGET.get();
    final WhoAmIExtendedResult whoAmIResult;
    try {
        whoAmIResult = (WhoAmIExtendedResult) connection.processExtendedOperation(new WhoAmIExtendedRequest(controls));
    } catch (final LDAPException le) {
        Debug.debugException(le);
        throw new LDAPException(le.getResultCode(), ERR_MOVE_SUBTREE_ERROR_INVOKING_WHO_AM_I.get(connectionName, StaticUtils.getExceptionMessage(le)), le);
    }
    if (whoAmIResult.getResultCode() != ResultCode.SUCCESS) {
        throw new LDAPException(whoAmIResult.getResultCode(), ERR_MOVE_SUBTREE_ERROR_INVOKING_WHO_AM_I.get(connectionName, whoAmIResult.getDiagnosticMessage()));
    }
    final String authzID = whoAmIResult.getAuthorizationID();
    if ((authzID != null) && authzID.startsWith("dn:")) {
        return authzID.substring(3);
    } else {
        throw new LDAPException(ResultCode.UNWILLING_TO_PERFORM, ERR_MOVE_SUBTREE_CANNOT_IDENTIFY_CONNECTED_USER.get(connectionName));
    }
}
Also used : WhoAmIExtendedResult(com.unboundid.ldap.sdk.extensions.WhoAmIExtendedResult) SimpleBindRequest(com.unboundid.ldap.sdk.SimpleBindRequest) Control(com.unboundid.ldap.sdk.Control) RealAttributesOnlyRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.RealAttributesOnlyRequestControl) OperationPurposeRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.OperationPurposeRequestControl) SuppressReferentialIntegrityUpdatesRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.SuppressReferentialIntegrityUpdatesRequestControl) SoftDeletedEntryAccessRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.SoftDeletedEntryAccessRequestControl) ManageDsaITRequestControl(com.unboundid.ldap.sdk.controls.ManageDsaITRequestControl) ReturnConflictEntriesRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.ReturnConflictEntriesRequestControl) DraftLDUPSubentriesRequestControl(com.unboundid.ldap.sdk.controls.DraftLDUPSubentriesRequestControl) LDAPException(com.unboundid.ldap.sdk.LDAPException) WhoAmIExtendedRequest(com.unboundid.ldap.sdk.extensions.WhoAmIExtendedRequest) BindRequest(com.unboundid.ldap.sdk.BindRequest) SimpleBindRequest(com.unboundid.ldap.sdk.SimpleBindRequest) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Nullable(com.unboundid.util.Nullable)

Aggregations

OperationPurposeRequestControl (com.unboundid.ldap.sdk.unboundidds.controls.OperationPurposeRequestControl)18 ManageDsaITRequestControl (com.unboundid.ldap.sdk.controls.ManageDsaITRequestControl)11 Control (com.unboundid.ldap.sdk.Control)10 SuppressReferentialIntegrityUpdatesRequestControl (com.unboundid.ldap.sdk.unboundidds.controls.SuppressReferentialIntegrityUpdatesRequestControl)10 ASN1OctetString (com.unboundid.asn1.ASN1OctetString)9 LDAPException (com.unboundid.ldap.sdk.LDAPException)8 DraftLDUPSubentriesRequestControl (com.unboundid.ldap.sdk.controls.DraftLDUPSubentriesRequestControl)7 RealAttributesOnlyRequestControl (com.unboundid.ldap.sdk.unboundidds.controls.RealAttributesOnlyRequestControl)7 ReturnConflictEntriesRequestControl (com.unboundid.ldap.sdk.unboundidds.controls.ReturnConflictEntriesRequestControl)7 SoftDeletedEntryAccessRequestControl (com.unboundid.ldap.sdk.unboundidds.controls.SoftDeletedEntryAccessRequestControl)7 NotNull (com.unboundid.util.NotNull)7 ArrayList (java.util.ArrayList)7 DN (com.unboundid.ldap.sdk.DN)6 LDAPConnection (com.unboundid.ldap.sdk.LDAPConnection)5 LDAPSearchException (com.unboundid.ldap.sdk.LDAPSearchException)5 ProxiedAuthorizationV1RequestControl (com.unboundid.ldap.sdk.controls.ProxiedAuthorizationV1RequestControl)5 ProxiedAuthorizationV2RequestControl (com.unboundid.ldap.sdk.controls.ProxiedAuthorizationV2RequestControl)5 AssuredReplicationRequestControl (com.unboundid.ldap.sdk.unboundidds.controls.AssuredReplicationRequestControl)5 AssertionRequestControl (com.unboundid.ldap.sdk.controls.AssertionRequestControl)4 AuthorizationIdentityRequestControl (com.unboundid.ldap.sdk.controls.AuthorizationIdentityRequestControl)4