use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.
the class SecurityQuestionLogic method update.
@PreAuthorize("hasRole('" + StandardEntitlement.SECURITY_QUESTION_UPDATE + "')")
public SecurityQuestionTO update(final SecurityQuestionTO securityQuestionTO) {
SecurityQuestion securityQuestion = securityQuestionDAO.find(securityQuestionTO.getKey());
if (securityQuestion == null) {
LOG.error("Could not find security question '" + securityQuestionTO.getKey() + "'");
throw new NotFoundException(String.valueOf(securityQuestionTO.getKey()));
}
binder.update(securityQuestion, securityQuestionTO);
securityQuestion = securityQuestionDAO.save(securityQuestion);
return binder.getSecurityQuestionTO(securityQuestion);
}
use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.
the class TaskLogic method read.
@PreAuthorize("hasRole('" + StandardEntitlement.TASK_READ + "')")
@Transactional(readOnly = true)
public <T extends TaskTO> T read(final TaskType type, final String key, final boolean details) {
Task task = taskDAO.find(key);
if (task == null) {
throw new NotFoundException("Task " + key);
}
TaskUtils taskUtils = taskUtilsFactory.getInstance(task);
if (type != null && taskUtils.getType() != type) {
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidRequest);
sce.getElements().add("Found " + type + ", expected " + taskUtils.getType());
throw sce;
}
return binder.getTaskTO(task, taskUtilsFactory.getInstance(task), details);
}
use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.
the class TaskLogic method listExecutions.
@PreAuthorize("hasRole('" + StandardEntitlement.TASK_READ + "')")
@Override
public Pair<Integer, List<ExecTO>> listExecutions(final String key, final int page, final int size, final List<OrderByClause> orderByClauses) {
Task task = taskDAO.find(key);
if (task == null) {
throw new NotFoundException("Task " + key);
}
Integer count = taskExecDAO.count(key);
List<ExecTO> result = taskExecDAO.findAll(task, page, size, orderByClauses).stream().map(taskExec -> binder.getExecTO(taskExec)).collect(Collectors.toList());
return Pair.of(count, result);
}
use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.
the class UserLogic method requestPasswordReset.
@PreAuthorize("isAnonymous() or hasRole('" + StandardEntitlement.ANONYMOUS + "')")
@Transactional
public void requestPasswordReset(final String username, final String securityAnswer) {
if (username == null) {
throw new NotFoundException("Null username");
}
User user = userDAO.findByUsername(username);
if (user == null) {
throw new NotFoundException("User " + username);
}
if (syncopeLogic.isPwdResetRequiringSecurityQuestions() && (securityAnswer == null || !securityAnswer.equals(user.getSecurityAnswer()))) {
throw SyncopeClientException.build(ClientExceptionType.InvalidSecurityAnswer);
}
provisioningManager.requestPasswordReset(user.getKey());
}
use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.
the class UserLogic method confirmPasswordReset.
@PreAuthorize("isAnonymous() or hasRole('" + StandardEntitlement.ANONYMOUS + "')")
@Transactional
public void confirmPasswordReset(final String token, final String password) {
User user = userDAO.findByToken(token);
if (user == null) {
throw new NotFoundException("User with token " + token);
}
provisioningManager.confirmPasswordReset(user.getKey(), token, password);
}
Aggregations