use of com.evolveum.midpoint.xml.ns._public.common.common_3.NonceType in project midpoint by Evolveum.
the class PageRegistrationConfirmation method assignAdditionalRoleIfPresent.
private OperationResult assignAdditionalRoleIfPresent(String userOid, NonceType nonceType, OperationResult result) {
// SecurityContextHolder.getContext().setAuthentication(token);
return runPrivileged(() -> {
List<ItemDelta> userDeltas = new ArrayList<>();
if (nonceType.getName() != null) {
Task task = createAnonymousTask(OPERATION_FINISH_REGISTRATION);
ObjectDelta<UserType> assignRoleDelta = null;
try {
AssignmentType assignment = new AssignmentType();
assignment.setTargetRef(ObjectTypeUtil.createObjectRef(nonceType.getName(), ObjectTypes.ABSTRACT_ROLE));
getPrismContext().adopt(assignment);
userDeltas.add((ItemDelta) ContainerDelta.createModificationAdd(UserType.F_ASSIGNMENT, UserType.class, getPrismContext(), assignment));
assignRoleDelta = ObjectDelta.createModifyDelta(userOid, userDeltas, UserType.class, getPrismContext());
assignRoleDelta.setPrismContext(getPrismContext());
} catch (SchemaException e) {
result.recordFatalError("Could not create delta");
return result;
}
WebModelServiceUtils.save(assignRoleDelta, result, task, PageRegistrationConfirmation.this);
result.computeStatusIfUnknown();
}
return result;
});
// SecurityContextHolder.getContext().setAuthentication(null);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.NonceType in project midpoint by Evolveum.
the class PageSelfRegistration method createCredentials.
private void createCredentials(UserType user, NonceCredentialsPolicyType noncePolicy, Task task, OperationResult result) throws ExpressionEvaluationException, SchemaException, ObjectNotFoundException {
NonceType nonceType = createNonce(noncePolicy, task, result);
// PasswordType password = createPassword();
CredentialsType credentials = user.getCredentials();
if (user.getCredentials() == null) {
credentials = new CredentialsType();
user.setCredentials(credentials);
}
credentials.setNonce(nonceType);
// credentials.setPassword(password);
// return credentials;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.NonceType in project midpoint by Evolveum.
the class PageRegistrationConfirmation method removeNonce.
private OperationResult removeNonce(final String userOid, final NonceType nonce) {
return runPrivileged(() -> {
OperationResult result = new OperationResult("assignDefaultRoles");
Task task = createAnonymousTask("assignDefaultRoles");
ObjectDelta<UserType> userAssignmentsDelta;
try {
userAssignmentsDelta = ObjectDelta.createModificationDeleteContainer(UserType.class, userOid, new ItemPath(UserType.F_CREDENTIALS, CredentialsType.F_NONCE), getPrismContext(), nonce);
userAssignmentsDelta.addModificationReplaceProperty(UserType.F_LIFECYCLE_STATE, SchemaConstants.LIFECYCLE_ACTIVE);
} catch (SchemaException e) {
result.recordFatalError("Could not create delta");
LOGGER.error("Could not prepare delta for removing nonce and lyfecycle state {}", e.getMessage());
return result;
}
WebModelServiceUtils.save(userAssignmentsDelta, result, task, PageRegistrationConfirmation.this);
result.computeStatusIfUnknown();
return result;
});
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.NonceType in project midpoint by Evolveum.
the class PageForgotPassword method saveUserNonce.
private OperationResult saveUserNonce(final UserType user, final NonceCredentialsPolicyType noncePolicy) {
return runPrivileged(new Producer<OperationResult>() {
private static final long serialVersionUID = 1L;
@Override
public OperationResult run() {
Task task = createAnonymousTask("generateUserNonce");
task.setChannel(SchemaConstants.CHANNEL_RESET_PASSWORD_URI);
task.setOwner(user.asPrismObject());
OperationResult result = new OperationResult("generateUserNonce");
ProtectedStringType nonceCredentials = new ProtectedStringType();
try {
nonceCredentials.setClearValue(generateNonce(noncePolicy, task, user.asPrismObject(), result));
// NonceType nonceType = new NonceType();
// nonceType.setValue(nonceCredentials);
ObjectDelta<UserType> nonceDelta = getPrismContext().deltaFactory().object().createModificationReplaceProperty(UserType.class, user.getOid(), SchemaConstants.PATH_NONCE_VALUE, nonceCredentials);
WebModelServiceUtils.save(nonceDelta, result, task, PageForgotPassword.this);
} catch (SchemaException | ExpressionEvaluationException | ObjectNotFoundException | CommunicationException | ConfigurationException | SecurityViolationException e) {
result.recordFatalError(getString("PageForgotPassword.message.saveUserNonce.fatalError"));
LoggingUtils.logException(LOGGER, "Failed to generate nonce for user: " + e.getMessage(), e);
}
result.computeStatusIfUnknown();
return result;
}
});
}
Aggregations