Search in sources :

Example 26 with NotFoundException

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);
}
Also used : NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) SecurityQuestion(org.apache.syncope.core.persistence.api.entity.user.SecurityQuestion) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 27 with NotFoundException

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);
}
Also used : TaskUtils(org.apache.syncope.core.persistence.api.entity.task.TaskUtils) NotificationTask(org.apache.syncope.core.persistence.api.entity.task.NotificationTask) SchedTask(org.apache.syncope.core.persistence.api.entity.task.SchedTask) Task(org.apache.syncope.core.persistence.api.entity.task.Task) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) Transactional(org.springframework.transaction.annotation.Transactional)

Example 28 with NotFoundException

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);
}
Also used : StandardEntitlement(org.apache.syncope.common.lib.types.StandardEntitlement) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) TaskTO(org.apache.syncope.common.lib.to.TaskTO) Date(java.util.Date) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) OrderByClause(org.apache.syncope.core.persistence.api.dao.search.OrderByClause) Autowired(org.springframework.beans.factory.annotation.Autowired) ArrayUtils(org.apache.commons.lang3.ArrayUtils) JobKey(org.quartz.JobKey) NotificationTask(org.apache.syncope.core.persistence.api.entity.task.NotificationTask) TaskDataBinder(org.apache.syncope.core.provisioning.api.data.TaskDataBinder) TaskDAO(org.apache.syncope.core.persistence.api.dao.TaskDAO) AnyTypeKind(org.apache.syncope.common.lib.types.AnyTypeKind) PropagationTaskTO(org.apache.syncope.common.lib.to.PropagationTaskTO) SchedTaskTO(org.apache.syncope.common.lib.to.SchedTaskTO) Pair(org.apache.commons.lang3.tuple.Pair) SchedulerException(org.quartz.SchedulerException) Map(java.util.Map) TaskExec(org.apache.syncope.core.persistence.api.entity.task.TaskExec) NotificationJobDelegate(org.apache.syncope.core.provisioning.api.notification.NotificationJobDelegate) ClientExceptionType(org.apache.syncope.common.lib.types.ClientExceptionType) SchedTask(org.apache.syncope.core.persistence.api.entity.task.SchedTask) JobTO(org.apache.syncope.common.lib.to.JobTO) TaskExecDAO(org.apache.syncope.core.persistence.api.dao.TaskExecDAO) Method(java.lang.reflect.Method) Triple(org.apache.commons.lang3.tuple.Triple) ExecTO(org.apache.syncope.common.lib.to.ExecTO) Task(org.apache.syncope.core.persistence.api.entity.task.Task) BulkActionResult(org.apache.syncope.common.lib.to.BulkActionResult) JobNamer(org.apache.syncope.core.provisioning.api.job.JobNamer) NotificationDAO(org.apache.syncope.core.persistence.api.dao.NotificationDAO) TaskUtils(org.apache.syncope.core.persistence.api.entity.task.TaskUtils) Collectors(java.util.stream.Collectors) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) List(java.util.List) JobAction(org.apache.syncope.common.lib.types.JobAction) Component(org.springframework.stereotype.Component) TaskUtilsFactory(org.apache.syncope.core.persistence.api.entity.task.TaskUtilsFactory) JobDataMap(org.quartz.JobDataMap) PropagationTaskExecutor(org.apache.syncope.core.provisioning.api.propagation.PropagationTaskExecutor) JobType(org.apache.syncope.common.lib.types.JobType) TaskJob(org.apache.syncope.core.provisioning.java.job.TaskJob) ConfDAO(org.apache.syncope.core.persistence.api.dao.ConfDAO) ExternalResourceDAO(org.apache.syncope.core.persistence.api.dao.ExternalResourceDAO) TaskType(org.apache.syncope.common.lib.types.TaskType) Transactional(org.springframework.transaction.annotation.Transactional) NotificationTask(org.apache.syncope.core.persistence.api.entity.task.NotificationTask) SchedTask(org.apache.syncope.core.persistence.api.entity.task.SchedTask) Task(org.apache.syncope.core.persistence.api.entity.task.Task) ExecTO(org.apache.syncope.common.lib.to.ExecTO) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 29 with NotFoundException

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());
}
Also used : User(org.apache.syncope.core.persistence.api.entity.user.User) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) Transactional(org.springframework.transaction.annotation.Transactional)

Example 30 with NotFoundException

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);
}
Also used : User(org.apache.syncope.core.persistence.api.entity.user.User) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

NotFoundException (org.apache.syncope.core.persistence.api.dao.NotFoundException)110 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)87 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)41 Transactional (org.springframework.transaction.annotation.Transactional)21 Date (java.util.Date)12 ExternalResource (org.apache.syncope.core.persistence.api.entity.resource.ExternalResource)10 SchedulerException (org.quartz.SchedulerException)10 ArrayList (java.util.ArrayList)8 List (java.util.List)8 AnyType (org.apache.syncope.core.persistence.api.entity.AnyType)8 Report (org.apache.syncope.core.persistence.api.entity.Report)8 SchedTask (org.apache.syncope.core.persistence.api.entity.task.SchedTask)8 User (org.apache.syncope.core.persistence.api.entity.user.User)8 HashMap (java.util.HashMap)7 Collectors (java.util.stream.Collectors)7 Pair (org.apache.commons.lang3.tuple.Pair)7 ExecTO (org.apache.syncope.common.lib.to.ExecTO)7 Autowired (org.springframework.beans.factory.annotation.Autowired)7 StringUtils (org.apache.commons.lang3.StringUtils)6 DuplicateException (org.apache.syncope.core.persistence.api.dao.DuplicateException)6