Search in sources :

Example 91 with FocusType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType in project midpoint by Evolveum.

the class ModelClientUtil method createAssignmentDeltaList.

@Deprecated
private static <O extends ObjectType, T extends ObjectType> ObjectDeltaListType createAssignmentDeltaList(Class<O> focusType, String focusOid, Class<T> targetType, String targetOid, ModificationTypeType modificationType) {
    AssignmentType assignment = new AssignmentType();
    ObjectReferenceType targetRef = new ObjectReferenceType();
    targetRef.setOid(targetOid);
    targetRef.setType(getTypeQName(targetType));
    assignment.setTargetRef(targetRef);
    return createModificationDeltaList(focusType, focusOid, "assignment", modificationType, assignment);
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)

Example 92 with FocusType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType in project midpoint by Evolveum.

the class CredentialPolicyEvaluator method createDeleteHistoryDeltasIfNeeded.

// TODO: generalize for other credentials
private <F extends FocusType> void createDeleteHistoryDeltasIfNeeded(int historyLength, int addedValues, PrismContainer<R> currentCredentialContainer) throws SchemaException {
    PrismContainer<PasswordHistoryEntryType> historyEntries = currentCredentialContainer.findOrCreateContainer(PasswordType.F_HISTORY_ENTRY);
    List<PrismContainerValue<PasswordHistoryEntryType>> historyEntryValues = historyEntries.getValues();
    if (historyEntries.size() == 0) {
        return;
    }
    // We need to delete one more entry than intuitively expected - because we are computing from the history entries 
    // in the old object. In the new object there will be one new history entry for the changed password.
    int numberOfHistoryEntriesToDelete = historyEntries.size() - historyLength + addedValues + 1;
    for (int i = 0; i < numberOfHistoryEntriesToDelete; i++) {
        ContainerDelta<PasswordHistoryEntryType> deleteHistoryDelta = ContainerDelta.createModificationDelete(new ItemPath(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_HISTORY_ENTRY), UserType.class, prismContext, historyEntryValues.get(i).clone());
        context.getFocusContext().swallowToSecondaryDelta(deleteHistoryDelta);
    }
}
Also used : PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue) PasswordHistoryEntryType(com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordHistoryEntryType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 93 with FocusType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType in project midpoint by Evolveum.

the class CredentialPolicyEvaluator method createAddHistoryDelta.

// TODO: generalize for other credentials
private <F extends FocusType> int createAddHistoryDelta(PrismContainer<R> oldCredentialContainer) throws SchemaException {
    R oldCredentialContainerType = oldCredentialContainer.getValue().asContainerable();
    MetadataType oldCredentialMetadata = oldCredentialContainerType.getMetadata();
    PrismProperty<ProtectedStringType> oldValueProperty = oldCredentialContainer.findProperty(getCredentialRelativeValuePath());
    if (oldValueProperty == null) {
        return 0;
    }
    ProtectedStringType newHistoryValue = oldValueProperty.getRealValue();
    ProtectedStringType passwordPsForStorage = newHistoryValue.clone();
    CredentialsStorageTypeType storageType = SecurityUtil.getCredentialStoragetTypeType(getCredentialPolicy().getHistoryStorageMethod());
    if (storageType == null) {
        storageType = CredentialsStorageTypeType.HASHING;
    }
    prepareProtectedStringForStorage(passwordPsForStorage, storageType);
    PrismContainerDefinition<PasswordHistoryEntryType> historyEntryDefinition = oldCredentialContainer.getDefinition().findContainerDefinition(PasswordType.F_HISTORY_ENTRY);
    PrismContainer<PasswordHistoryEntryType> historyEntry = historyEntryDefinition.instantiate();
    PrismContainerValue<PasswordHistoryEntryType> hisotryEntryValue = historyEntry.createNewValue();
    PasswordHistoryEntryType entryType = hisotryEntryValue.asContainerable();
    entryType.setValue(passwordPsForStorage);
    entryType.setMetadata(oldCredentialMetadata == null ? null : oldCredentialMetadata.clone());
    entryType.setChangeTimestamp(now);
    ContainerDelta<PasswordHistoryEntryType> addHisotryDelta = ContainerDelta.createModificationAdd(new ItemPath(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_HISTORY_ENTRY), UserType.class, prismContext, entryType.clone());
    context.getFocusContext().swallowToSecondaryDelta(addHisotryDelta);
    return 1;
}
Also used : CredentialsStorageTypeType(com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsStorageTypeType) PasswordHistoryEntryType(com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordHistoryEntryType) MetadataType(com.evolveum.midpoint.xml.ns._public.common.common_3.MetadataType) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 94 with FocusType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType in project midpoint by Evolveum.

the class ProjectionCredentialsProcessor method determinePasswordPolicy.

private <F extends FocusType> ValuePolicyType determinePasswordPolicy(LensContext<F> context, final LensProjectionContext projCtx, XMLGregorianCalendar now, Task task, OperationResult result) {
    ValuePolicyType passwordPolicy = projCtx.getAccountPasswordPolicy();
    if (passwordPolicy != null) {
        return passwordPolicy;
    }
    LensFocusContext<F> focusContext = context.getFocusContext();
    if (focusContext == null) {
        return null;
    }
    return SecurityUtil.getPasswordPolicy(focusContext.getSecurityPolicy());
}
Also used : ValuePolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType)

Example 95 with FocusType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType in project midpoint by Evolveum.

the class ProjectionCredentialsProcessor method processProjectionCredentialsFocus.

public <F extends FocusType> void processProjectionCredentialsFocus(LensContext<F> context, LensProjectionContext projectionContext, XMLGregorianCalendar now, Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, PolicyViolationException, CommunicationException, ConfigurationException, SecurityViolationException {
    ValuePolicyType passwordPolicy = determinePasswordPolicy(context, projectionContext, now, task, result);
    processProjectionPasswordMapping(context, projectionContext, passwordPolicy, now, task, result);
    validateProjectionPassword(context, projectionContext, passwordPolicy, now, task, result);
    applyMetadata(context, projectionContext, now, task, result);
}
Also used : ValuePolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType)

Aggregations

ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)27 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)25 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)23 FocusType (com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType)22 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)21 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)18 PrismObject (com.evolveum.midpoint.prism.PrismObject)16 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)15 ArrayList (java.util.ArrayList)15 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)14 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)12 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)10 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)9 LensProjectionContext (com.evolveum.midpoint.model.impl.lens.LensProjectionContext)8 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)8 QName (javax.xml.namespace.QName)8 PropertyDelta (com.evolveum.midpoint.prism.delta.PropertyDelta)7 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)7 PolicyViolationException (com.evolveum.midpoint.util.exception.PolicyViolationException)7 ActivationStatusType (com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType)7