use of com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType in project midpoint by Evolveum.
the class FocusProcessor method processActivationLockout.
private <F extends FocusType> void processActivationLockout(LensFocusContext<UserType> focusContext, XMLGregorianCalendar now, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, PolicyViolationException {
ObjectDelta<UserType> focusPrimaryDelta = focusContext.getPrimaryDelta();
if (focusPrimaryDelta != null) {
PropertyDelta<LockoutStatusType> lockoutStatusDelta = focusContext.getPrimaryDelta().findPropertyDelta(SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS);
if (lockoutStatusDelta != null) {
if (lockoutStatusDelta.isAdd()) {
for (PrismPropertyValue<LockoutStatusType> pval : lockoutStatusDelta.getValuesToAdd()) {
if (pval.getValue() == LockoutStatusType.LOCKED) {
throw new SchemaException("Lockout status cannot be changed to LOCKED value");
}
}
} else if (lockoutStatusDelta.isReplace()) {
for (PrismPropertyValue<LockoutStatusType> pval : lockoutStatusDelta.getValuesToReplace()) {
if (pval.getValue() == LockoutStatusType.LOCKED) {
throw new SchemaException("Lockout status cannot be changed to LOCKED value");
}
}
}
}
}
ActivationType activationNew = null;
ActivationType activationCurrent = null;
LockoutStatusType lockoutStatusNew = null;
LockoutStatusType lockoutStatusCurrent = null;
PrismObject<UserType> focusNew = focusContext.getObjectNew();
if (focusNew != null) {
activationNew = focusNew.asObjectable().getActivation();
if (activationNew != null) {
lockoutStatusNew = activationNew.getLockoutStatus();
}
}
PrismObject<UserType> focusCurrent = focusContext.getObjectCurrent();
if (focusCurrent != null) {
activationCurrent = focusCurrent.asObjectable().getActivation();
if (activationCurrent != null) {
lockoutStatusCurrent = activationCurrent.getLockoutStatus();
}
}
if (lockoutStatusNew == lockoutStatusCurrent) {
// No change, (almost) no work
LOGGER.trace("Skipping lockout processing because there was no change ({} -> {})", lockoutStatusCurrent, lockoutStatusNew);
return;
}
LOGGER.trace("Lockout change {} -> {}", lockoutStatusCurrent, lockoutStatusNew);
if (lockoutStatusNew == LockoutStatusType.NORMAL) {
CredentialsType credentialsTypeNew = focusNew.asObjectable().getCredentials();
if (credentialsTypeNew != null) {
resetFailedLogins(focusContext, credentialsTypeNew.getPassword(), SchemaConstants.PATH_CREDENTIALS_PASSWORD_FAILED_LOGINS);
resetFailedLogins(focusContext, credentialsTypeNew.getNonce(), SchemaConstants.PATH_CREDENTIALS_NONCE_FAILED_LOGINS);
resetFailedLogins(focusContext, credentialsTypeNew.getSecurityQuestions(), SchemaConstants.PATH_CREDENTIALS_SECURITY_QUESTIONS_FAILED_LOGINS);
}
if (activationNew != null && activationNew.getLockoutExpirationTimestamp() != null) {
PrismContainerDefinition<ActivationType> activationDefinition = getActivationDefinition();
PrismPropertyDefinition<XMLGregorianCalendar> lockoutExpirationTimestampDef = activationDefinition.findPropertyDefinition(ActivationType.F_LOCKOUT_EXPIRATION_TIMESTAMP);
PropertyDelta<XMLGregorianCalendar> lockoutExpirationTimestampDelta = lockoutExpirationTimestampDef.createEmptyDelta(new ItemPath(UserType.F_ACTIVATION, ActivationType.F_LOCKOUT_EXPIRATION_TIMESTAMP));
lockoutExpirationTimestampDelta.setValueToReplace();
focusContext.swallowToProjectionWaveSecondaryDelta(lockoutExpirationTimestampDelta);
}
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType in project midpoint by Evolveum.
the class FocusProcessor method processActivationAdministrativeAndValidity.
private <F extends FocusType> void processActivationAdministrativeAndValidity(LensFocusContext<F> focusContext, XMLGregorianCalendar now, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, PolicyViolationException {
TimeIntervalStatusType validityStatusNew = null;
TimeIntervalStatusType validityStatusCurrent = null;
XMLGregorianCalendar validityChangeTimestamp = null;
String lifecycleStateNew = null;
String lifecycleStateCurrent = null;
ActivationType activationNew = null;
ActivationType activationCurrent = null;
PrismObject<F> focusNew = focusContext.getObjectNew();
if (focusNew != null) {
F focusTypeNew = focusNew.asObjectable();
activationNew = focusTypeNew.getActivation();
if (activationNew != null) {
validityStatusNew = activationComputer.getValidityStatus(activationNew, now);
validityChangeTimestamp = activationNew.getValidityChangeTimestamp();
}
lifecycleStateNew = focusTypeNew.getLifecycleState();
}
PrismObject<F> focusCurrent = focusContext.getObjectCurrent();
if (focusCurrent != null) {
F focusCurrentType = focusCurrent.asObjectable();
activationCurrent = focusCurrentType.getActivation();
if (activationCurrent != null) {
validityStatusCurrent = activationComputer.getValidityStatus(activationCurrent, validityChangeTimestamp);
}
lifecycleStateCurrent = focusCurrentType.getLifecycleState();
}
if (validityStatusCurrent == validityStatusNew) {
// No change, (almost) no work
if (validityStatusNew != null && activationNew.getValidityStatus() == null) {
// There was no validity change. But the status is not recorded. So let's record it so it can be used in searches.
recordValidityDelta(focusContext, validityStatusNew, now);
} else {
LOGGER.trace("Skipping validity processing because there was no change ({} -> {})", validityStatusCurrent, validityStatusNew);
}
} else {
LOGGER.trace("Validity change {} -> {}", validityStatusCurrent, validityStatusNew);
recordValidityDelta(focusContext, validityStatusNew, now);
}
ActivationStatusType effectiveStatusNew = activationComputer.getEffectiveStatus(lifecycleStateNew, activationNew, validityStatusNew);
ActivationStatusType effectiveStatusCurrent = activationComputer.getEffectiveStatus(lifecycleStateCurrent, activationCurrent, validityStatusCurrent);
if (effectiveStatusCurrent == effectiveStatusNew) {
// No change, (almost) no work
if (effectiveStatusNew != null && (activationNew == null || activationNew.getEffectiveStatus() == null)) {
// There was no effective status change. But the status is not recorded. So let's record it so it can be used in searches.
recordEffectiveStatusDelta(focusContext, effectiveStatusNew, now);
} else {
if (focusContext.getPrimaryDelta() != null && focusContext.getPrimaryDelta().hasItemDelta(SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS)) {
LOGGER.trace("Forcing effective status delta even though there was no change ({} -> {}) because there is explicit administrativeStatus delta", effectiveStatusCurrent, effectiveStatusNew);
// We need this to force the change down to the projections later in the activation processor
// some of the mappings will use effectiveStatus as a source, therefore there has to be a delta for the mapping to work correctly
recordEffectiveStatusDelta(focusContext, effectiveStatusNew, now);
} else {
LOGGER.trace("Skipping effective status processing because there was no change ({} -> {})", effectiveStatusCurrent, effectiveStatusNew);
}
}
} else {
LOGGER.trace("Effective status change {} -> {}", effectiveStatusCurrent, effectiveStatusNew);
recordEffectiveStatusDelta(focusContext, effectiveStatusNew, now);
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType in project midpoint by Evolveum.
the class FocusProcessor method recordValidityDelta.
private <F extends ObjectType> void recordValidityDelta(LensFocusContext<F> focusContext, TimeIntervalStatusType validityStatusNew, XMLGregorianCalendar now) throws SchemaException {
PrismContainerDefinition<ActivationType> activationDefinition = getActivationDefinition();
PrismPropertyDefinition<TimeIntervalStatusType> validityStatusDef = activationDefinition.findPropertyDefinition(ActivationType.F_VALIDITY_STATUS);
PropertyDelta<TimeIntervalStatusType> validityStatusDelta = validityStatusDef.createEmptyDelta(new ItemPath(UserType.F_ACTIVATION, ActivationType.F_VALIDITY_STATUS));
if (validityStatusNew == null) {
validityStatusDelta.setValueToReplace();
} else {
validityStatusDelta.setValueToReplace(new PrismPropertyValue<>(validityStatusNew, OriginType.USER_POLICY, null));
}
focusContext.swallowToProjectionWaveSecondaryDelta(validityStatusDelta);
PrismPropertyDefinition<XMLGregorianCalendar> validityChangeTimestampDef = activationDefinition.findPropertyDefinition(ActivationType.F_VALIDITY_CHANGE_TIMESTAMP);
PropertyDelta<XMLGregorianCalendar> validityChangeTimestampDelta = validityChangeTimestampDef.createEmptyDelta(new ItemPath(UserType.F_ACTIVATION, ActivationType.F_VALIDITY_CHANGE_TIMESTAMP));
validityChangeTimestampDelta.setValueToReplace(new PrismPropertyValue<>(now, OriginType.USER_POLICY, null));
focusContext.swallowToProjectionWaveSecondaryDelta(validityChangeTimestampDelta);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType in project midpoint by Evolveum.
the class AbstractModelIntegrationTest method createUser.
protected PrismObject<UserType> createUser(String name, String givenName, String familyName, Boolean enabled) throws SchemaException {
PrismObject<UserType> user = getUserDefinition().instantiate();
UserType userType = user.asObjectable();
userType.setName(PrismTestUtil.createPolyStringType(name));
userType.setGivenName(PrismTestUtil.createPolyStringType(givenName));
userType.setFamilyName(PrismTestUtil.createPolyStringType(familyName));
userType.setFullName(PrismTestUtil.createPolyStringType(givenName + " " + familyName));
if (enabled != null) {
ActivationType activation = new ActivationType();
userType.setActivation(activation);
if (enabled) {
activation.setAdministrativeStatus(ActivationStatusType.ENABLED);
} else {
activation.setAdministrativeStatus(ActivationStatusType.DISABLED);
}
}
return user;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType in project midpoint by Evolveum.
the class AbstractModelIntegrationTest method getActivation.
protected ActivationType getActivation(PrismObject<? extends ObjectType> obj) {
ObjectType objectType = obj.asObjectable();
ActivationType activation;
if (objectType instanceof ShadowType) {
activation = ((ShadowType) objectType).getActivation();
} else if (objectType instanceof UserType) {
activation = ((UserType) objectType).getActivation();
} else {
throw new IllegalArgumentException("Cannot get activation from " + obj);
}
assertNotNull("No activation in " + obj, activation);
return activation;
}
Aggregations