Search in sources :

Example 96 with PrismPropertyValue

use of com.evolveum.midpoint.prism.PrismPropertyValue in project midpoint by Evolveum.

the class WebComponentUtil method encryptCredentials.

public static void encryptCredentials(ObjectDelta delta, boolean encrypt, MidPointApplication app) {
    if (delta == null || delta.isEmpty()) {
        return;
    }
    PropertyDelta propertyDelta = delta.findPropertyDelta(new ItemPath(SchemaConstantsGenerated.C_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE));
    if (propertyDelta == null) {
        return;
    }
    Collection<PrismPropertyValue<ProtectedStringType>> values = propertyDelta.getValues(ProtectedStringType.class);
    for (PrismPropertyValue<ProtectedStringType> value : values) {
        ProtectedStringType string = value.getValue();
        encryptProtectedString(string, encrypt, app);
    }
}
Also used : PropertyDelta(com.evolveum.midpoint.prism.delta.PropertyDelta) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue)

Example 97 with PrismPropertyValue

use of com.evolveum.midpoint.prism.PrismPropertyValue in project midpoint by Evolveum.

the class FocusProjectionsTabPanel method unlockShadowPerformed.

private void unlockShadowPerformed(AjaxRequestTarget target, IModel<List<FocusSubwrapperDto<ShadowType>>> model, List<FocusSubwrapperDto<ShadowType>> selected) {
    if (!isAnyProjectionSelected(target, model)) {
        return;
    }
    for (FocusSubwrapperDto<ShadowType> account : selected) {
        if (!account.isLoadedOK()) {
            continue;
        }
        ObjectWrapper<ShadowType> wrapper = account.getObject();
        wrapper.setSelected(false);
        ContainerWrapper<ActivationType> activation = wrapper.findContainerWrapper(new ItemPath(ShadowType.F_ACTIVATION));
        if (activation == null) {
            warn(getString("pageAdminFocus.message.noActivationFound", wrapper.getDisplayName()));
            continue;
        }
        PropertyWrapper lockedProperty = activation.findPropertyWrapper(ActivationType.F_LOCKOUT_STATUS);
        if (lockedProperty == null || lockedProperty.getValues().size() != 1) {
            warn(getString("pageAdminFocus.message.noLockoutStatusPropertyFound", wrapper.getDisplayName()));
            continue;
        }
        ValueWrapper value = (ValueWrapper) lockedProperty.getValues().get(0);
        ((PrismPropertyValue) value.getValue()).setValue(LockoutStatusType.NORMAL);
        // TODO only for really unlocked accounts
        info(getString("pageAdminFocus.message.unlocked", wrapper.getDisplayName()));
    }
    target.add(getFeedbackPanel(), get(createComponentPath(ID_SHADOWS)));
}
Also used : ItemPath(com.evolveum.midpoint.prism.path.ItemPath) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue)

Example 98 with PrismPropertyValue

use of com.evolveum.midpoint.prism.PrismPropertyValue in project midpoint by Evolveum.

the class SynchronizationUtils method getSituationFromSameChannel.

private static List<PrismPropertyValue<SynchronizationSituationDescriptionType>> getSituationFromSameChannel(PrismObject prismObject, String channel) {
    ShadowType target = (ShadowType) prismObject.asObjectable();
    List<SynchronizationSituationDescriptionType> syncSituationDescriptions = ((ShadowType) target).getSynchronizationSituationDescription();
    List<PrismPropertyValue<SynchronizationSituationDescriptionType>> valuesToDelete = new ArrayList<PrismPropertyValue<SynchronizationSituationDescriptionType>>();
    if (syncSituationDescriptions == null || syncSituationDescriptions.isEmpty()) {
        return null;
    }
    for (SynchronizationSituationDescriptionType syncSituationDescription : syncSituationDescriptions) {
        if (StringUtils.isEmpty(syncSituationDescription.getChannel()) && StringUtils.isEmpty(channel)) {
            valuesToDelete.add(new PrismPropertyValue<SynchronizationSituationDescriptionType>(syncSituationDescription));
            continue;
        // return syncSituationDescription;
        }
        if ((StringUtils.isEmpty(syncSituationDescription.getChannel()) && channel != null) || (StringUtils.isEmpty(channel) && syncSituationDescription.getChannel() != null)) {
            // return null;
            continue;
        }
        if (syncSituationDescription.getChannel().equals(channel)) {
            valuesToDelete.add(new PrismPropertyValue<SynchronizationSituationDescriptionType>(syncSituationDescription));
            continue;
        // return syncSituationDescription;
        }
    }
    return valuesToDelete;
}
Also used : ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ArrayList(java.util.ArrayList) SynchronizationSituationDescriptionType(com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationSituationDescriptionType) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue)

Example 99 with PrismPropertyValue

use of com.evolveum.midpoint.prism.PrismPropertyValue in project midpoint by Evolveum.

the class CryptoUtil method checkEncrypted.

// Checks that everything is encrypted
public static <T extends ObjectType> void checkEncrypted(final PrismObject<T> object) {
    Visitor visitor = new Visitor() {

        @Override
        public void visit(Visitable visitable) {
            if (!(visitable instanceof PrismPropertyValue)) {
                return;
            }
            PrismPropertyValue<?> pval = (PrismPropertyValue<?>) visitable;
            checkEncrypted(pval);
        }
    };
    try {
        object.accept(visitor);
    } catch (IllegalStateException e) {
        throw new IllegalStateException(e.getMessage() + " in " + object, e);
    }
}
Also used : Visitor(com.evolveum.midpoint.prism.Visitor) Visitable(com.evolveum.midpoint.prism.Visitable) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue)

Example 100 with PrismPropertyValue

use of com.evolveum.midpoint.prism.PrismPropertyValue in project midpoint by Evolveum.

the class CryptoUtil method checkEncrypted.

// Checks that everything is encrypted
public static <T extends ObjectType> void checkEncrypted(final ObjectDelta<T> delta) {
    Visitor visitor = new Visitor() {

        @Override
        public void visit(Visitable visitable) {
            if (!(visitable instanceof PrismPropertyValue)) {
                return;
            }
            PrismPropertyValue<?> pval = (PrismPropertyValue<?>) visitable;
            checkEncrypted(pval);
        }
    };
    try {
        delta.accept(visitor);
    } catch (IllegalStateException e) {
        throw new IllegalStateException(e.getMessage() + " in delta " + delta, e);
    }
}
Also used : Visitor(com.evolveum.midpoint.prism.Visitor) Visitable(com.evolveum.midpoint.prism.Visitable) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue)

Aggregations

PrismPropertyValue (com.evolveum.midpoint.prism.PrismPropertyValue)176 PrismPropertyDefinition (com.evolveum.midpoint.prism.PrismPropertyDefinition)93 Test (org.testng.annotations.Test)83 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)81 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)81 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)60 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)43 QName (javax.xml.namespace.QName)35 PrismObject (com.evolveum.midpoint.prism.PrismObject)29 PrismPropertyDefinitionImpl (com.evolveum.midpoint.prism.PrismPropertyDefinitionImpl)19 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)17 ArrayList (java.util.ArrayList)16 Task (com.evolveum.midpoint.task.api.Task)12 ExpressionEvaluationContext (com.evolveum.midpoint.repo.common.expression.ExpressionEvaluationContext)11 PropertyDelta (com.evolveum.midpoint.prism.delta.PropertyDelta)10 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)9 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)9 PrismProperty (com.evolveum.midpoint.prism.PrismProperty)8 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)8 File (java.io.File)8