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);
}
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);
}
}
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;
}
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());
}
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);
}
Aggregations