@PreAuthorize("hasRole('" + StandardEntitlement.CONNECTOR_HISTORY_LIST + "')") @Transactional(readOnly = true) public List<ConnInstanceHistoryConfTO> list(final String key) { ConnInstance connInstance = connInstanceDAO.find(key); if (connInstance == null) { throw new NotFoundException("Connector '" + key + "'"); } return connInstanceHistoryConfDAO.findByEntity(connInstance).stream(). map(binder::getConnInstanceHistoryConfTO).collect(Collectors.toList()); }
@PreAuthorize("hasRole('" + StandardEntitlement.REMEDIATION_READ + "')") @Transactional(readOnly = true) public RemediationTO read(final String key) { Remediation remediation = remediationDAO.find(key); if (remediation == null) { LOG.error("Could not find remediation '" + key + "'"); throw new NotFoundException(key); } return binder.getRemediationTO(remediation); }
@PreAuthorize("hasRole('" + StandardEntitlement.REPORT_TEMPLATE_READ + "')") @Transactional(readOnly = true) public ReportTemplateTO read(final String key) { ReportTemplate reportTemplate = reportTemplateDAO.find(key); if (reportTemplate == null) { LOG.error("Could not find report template '" + key + "'"); throw new NotFoundException(key); } return getReportTemplateTO(key); }
@PreAuthorize("hasRole('" + StandardEntitlement.DYNREALM_READ + "')") @Transactional(readOnly = true) public DynRealmTO read(final String key) { DynRealm dynRealm = dynRealmDAO.find(key); if (dynRealm == null) { LOG.error("Could not find dynamic realm '" + key + "'"); throw new NotFoundException(key); } return binder.getDynRealmTO(dynRealm); }
@PreAuthorize("hasRole('" + StandardEntitlement.ANYTYPE_READ + "')") @Transactional(readOnly = true) public AnyTypeTO read(final String key) { AnyType anyType = anyTypeDAO.find(key); if (anyType == null) { LOG.error("Could not find anyType '" + key + "'"); throw new NotFoundException(key); } return binder.getAnyTypeTO(anyType); }
@PreAuthorize("hasRole('" + StandardEntitlement.RESOURCE_HISTORY_DELETE + "')") public void delete(final String key) { ExternalResourceHistoryConf resourceHistoryConf = resourceHistoryConfDAO.find(key); if (resourceHistoryConf == null) { throw new NotFoundException("Resource History Conf '" + key + "'"); } resourceHistoryConfDAO.delete(key); }
@PreAuthorize("hasRole('" + StandardEntitlement.SECURITY_QUESTION_DELETE + "')") public SecurityQuestionTO delete(final String key) { SecurityQuestion securityQuestion = securityQuestionDAO.find(key); if (securityQuestion == null) { LOG.error("Could not find security question '" + key + "'"); throw new NotFoundException(key); } SecurityQuestionTO deleted = binder.getSecurityQuestionTO(securityQuestion); securityQuestionDAO.delete(key); return deleted; }
@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); }
@PreAuthorize("hasRole('" + StandardEntitlement.AUDIT_READ + "')") @Transactional(readOnly = true) public LoggerTO readAudit(final String name) { return listAudits().stream(). filter(logger -> logger.toLoggerName().equals(name)).findFirst(). map(logger -> { LoggerTO loggerTO = new LoggerTO(); loggerTO.setKey(logger.toLoggerName()); loggerTO.setLevel(LoggerLevel.DEBUG); return loggerTO; }).orElseThrow(() -> new NotFoundException("Audit " + name)); }
@PreAuthorize("hasRole('" + StandardEntitlement.ANYTYPECLASS_DELETE + "')") public AnyTypeClassTO delete(final String key) { AnyTypeClass anyTypeClass = anyTypeClassDAO.find(key); if (anyTypeClass == null) { LOG.error("Could not find anyTypeClass '" + key + "'"); throw new NotFoundException(key); } AnyTypeClassTO deleted = binder.getAnyTypeClassTO(anyTypeClass); anyTypeClassDAO.delete(key); return deleted; }
@PreAuthorize("hasRole('" + SAML2SPEntitlement.IDP_READ + "')") @Transactional(readOnly = true) public SAML2IdPTO read(final String key) { check(); SAML2IdP idp = idpDAO.find(key); if (idp == null) { throw new NotFoundException("SAML 2.0 IdP '" + key + "'"); } return complete(idp, binder.getIdPTO(idp)); }
@PreAuthorize("hasRole('" + StandardEntitlement.CONNECTOR_READ + "')") @Transactional(readOnly = true) public ConnInstanceTO readByResource(final String resourceName, final String lang) { CurrentLocale.set(StringUtils.isBlank(lang) ? Locale.ENGLISH : new Locale(lang)); ExternalResource resource = resourceDAO.find(resourceName); if (resource == null) { throw new NotFoundException("Resource '" + resourceName + "'"); } ConnInstanceTO connInstance = binder.getConnInstanceTO(connFactory.getConnector(resource).getConnInstance()); connInstance.setKey(resource.getConnector().getKey()); return connInstance; }
@PreAuthorize("hasRole('" + StandardEntitlement.NOTIFICATION_UPDATE + "')") public NotificationTO update(final NotificationTO notificationTO) { Notification notification = notificationDAO.find(notificationTO.getKey()); if (notification == null) { LOG.error("Could not find notification '" + notificationTO.getKey() + "'"); throw new NotFoundException(String.valueOf(notificationTO.getKey())); } binder.update(notification, notificationTO); notification = notificationDAO.save(notification); return binder.getNotificationTO(notification); }
@PreAuthorize("hasRole('" + StandardEntitlement.DYNREALM_UPDATE + "')") public DynRealmTO update(final DynRealmTO dynRealmTO) { DynRealm dynRealm = dynRealmDAO.find(dynRealmTO.getKey()); if (dynRealm == null) { LOG.error("Could not find dynamic realm '" + dynRealmTO.getKey() + "'"); throw new NotFoundException(dynRealmTO.getKey()); } return binder.getDynRealmTO(binder.update(dynRealm, dynRealmTO)); }
@PreAuthorize("hasRole('" + StandardEntitlement.ROLE_UPDATE + "')") public RoleTO update(final RoleTO roleTO) { Role role = roleDAO.find(roleTO.getKey()); if (role == null) { LOG.error("Could not find role '" + roleTO.getKey() + "'"); throw new NotFoundException(roleTO.getKey()); } return binder.getRoleTO(binder.update(role, roleTO)); }
@PreAuthorize("isAuthenticated()") public Pair<String, Date> refresh() { AccessToken accessToken = accessTokenDAO.findByOwner(AuthContextUtils.getUsername()); if (accessToken == null) { throw new NotFoundException("AccessToken for " + AuthContextUtils.getUsername()); } return binder.update(accessToken, getAuthorities()); }
@PreAuthorize("hasRole('" + SAML2SPEntitlement.IDP_DELETE + "')") public void delete(final String key) { check(); SAML2IdP idp = idpDAO.find(key); if (idp == null) { throw new NotFoundException("SAML 2.0 IdP '" + key + "'"); } idpDAO.delete(key); cache.remove(idp.getEntityID()); }
@PreAuthorize("isAuthenticated()") public void logout() { AccessToken accessToken = accessTokenDAO.findByOwner(AuthContextUtils.getUsername()); if (accessToken == null) { throw new NotFoundException("AccessToken for " + AuthContextUtils.getUsername()); } delete(accessToken.getKey()); }
@PreAuthorize("hasRole('" + StandardEntitlement.DOMAIN_UPDATE + "') and authentication.details.domain == " + "T(org.apache.syncope.common.lib.SyncopeConstants).MASTER_DOMAIN") public DomainTO update(final DomainTO domainTO) { Domain domain = domainDAO.find(domainTO.getKey()); if (domain == null) { LOG.error("Could not find domain '" + domainTO.getKey() + "'"); throw new NotFoundException(domainTO.getKey()); } binder.update(domain, domainTO); domain = domainDAO.save(domain); return binder.getDomainTO(domain); }
@PreAuthorize("hasRole('" + StandardEntitlement.RELATIONSHIPTYPE_UPDATE + "')") public RelationshipTypeTO update(final RelationshipTypeTO relationshipTypeTO) { RelationshipType relationshipType = relationshipTypeDAO.find(relationshipTypeTO.getKey()); if (relationshipType == null) { LOG.error("Could not find relationshipType '" + relationshipTypeTO.getKey() + "'"); throw new NotFoundException(relationshipTypeTO.getKey()); } binder.update(relationshipType, relationshipTypeTO); relationshipType = relationshipTypeDAO.save(relationshipType); return binder.getRelationshipTypeTO(relationshipType); }