You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2013/03/19 16:06:51 UTC
svn commit: r1458326 -
/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/
Author: ilgrosso
Date: Tue Mar 19 15:06:51 2013
New Revision: 1458326
URL: http://svn.apache.org/r1458326
Log:
[SYNCOPE-338] Spring Security annotations moved to *Internal() Spring MVC conrtoller methods
Modified:
syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ConfigurationController.java
syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/LoggerController.java
syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/NotificationController.java
syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/PolicyController.java
syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ReportController.java
syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/TaskController.java
syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserController.java
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ConfigurationController.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ConfigurationController.java?rev=1458326&r1=1458325&r2=1458326&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ConfigurationController.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ConfigurationController.java Tue Mar 19 15:06:51 2013
@@ -126,7 +126,6 @@ public class ConfigurationController ext
@PreAuthorize("hasRole('CONFIGURATION_READ')")
@RequestMapping(method = RequestMethod.GET, value = "/read/{key}")
public ConfigurationTO read(final HttpServletResponse response, @PathVariable("key") final String key) {
-
ConfigurationTO result;
try {
SyncopeConf conf = confDAO.find(key);
@@ -202,9 +201,7 @@ public class ConfigurationController ext
return new ModelAndView().addObject(htmlTemplates);
}
- @PreAuthorize("hasRole('CONFIGURATION_READ')")
@RequestMapping(method = RequestMethod.GET, value = "/dbexport")
- @Transactional(readOnly = true)
public void dbExport(final HttpServletResponse response) {
response.setContentType(MediaType.TEXT_XML);
response.setHeader(SyncopeConstants.CONTENT_DISPOSITION_HEADER,
@@ -216,6 +213,7 @@ public class ConfigurationController ext
}
}
+ @PreAuthorize("hasRole('CONFIGURATION_READ')")
@Transactional(readOnly = true)
public void dbExportInternal(final OutputStream os) {
try {
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/LoggerController.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/LoggerController.java?rev=1458326&r1=1458325&r2=1458326&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/LoggerController.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/LoggerController.java Tue Mar 19 15:06:51 2013
@@ -170,7 +170,7 @@ public class LoggerController extends Ab
} else if (expectedType != syncopeLogger.getType()) {
throwInvalidLogger(expectedType);
}
-
+
LoggerTO loggerToDelete = new LoggerTO();
BeanUtils.copyProperties(syncopeLogger, loggerToDelete);
@@ -184,7 +184,7 @@ public class LoggerController extends Ab
auditManager.audit(Category.logger, LoggerSubCategory.setLevel, Result.success, String.format(
"Successfully deleted logger %s (%s)", name, expectedType));
-
+
return loggerToDelete;
}
@@ -197,7 +197,6 @@ public class LoggerController extends Ab
@PreAuthorize("hasRole('AUDIT_DISABLE')")
@RequestMapping(method = RequestMethod.PUT, value = "/audit/disable")
public void disableAudit(@RequestBody final AuditLoggerName auditLoggerName) {
-
try {
delete(auditLoggerName.toLoggerName(), SyncopeLoggerType.AUDIT);
} catch (NotFoundException e) {
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/NotificationController.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/NotificationController.java?rev=1458326&r1=1458325&r2=1458326&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/NotificationController.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/NotificationController.java Tue Mar 19 15:06:51 2013
@@ -82,7 +82,6 @@ public class NotificationController exte
return notificationTOs;
}
- @PreAuthorize("hasRole('NOTIFICATION_CREATE')")
@RequestMapping(method = RequestMethod.POST, value = "/create")
public NotificationTO create(final HttpServletResponse response, @RequestBody final NotificationTO notificationTO) {
NotificationTO savedNotificationTO = createInternal(notificationTO);
@@ -90,6 +89,7 @@ public class NotificationController exte
return savedNotificationTO;
}
+ @PreAuthorize("hasRole('NOTIFICATION_CREATE')")
public NotificationTO createInternal(final NotificationTO notificationTO) {
LOG.debug("Notification create called with parameter {}", notificationTO);
Notification notification = notificationDAO.save(binder.createNotification(notificationTO));
@@ -122,7 +122,6 @@ public class NotificationController exte
@PreAuthorize("hasRole('CONNECTOR_DELETE')")
@RequestMapping(method = RequestMethod.GET, value = "/delete/{notificationId}")
public NotificationTO delete(@PathVariable("notificationId") final Long notificationId) {
-
Notification notification = notificationDAO.find(notificationId);
if (notification == null) {
LOG.error("Could not find notificatin '" + notificationId + "'");
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/PolicyController.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/PolicyController.java?rev=1458326&r1=1458325&r2=1458326&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/PolicyController.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/PolicyController.java Tue Mar 19 15:06:51 2013
@@ -66,24 +66,22 @@ public class PolicyController extends Ab
@Autowired
private PolicyDataBinder binder;
- @PreAuthorize("hasRole('POLICY_CREATE')")
@RequestMapping(method = RequestMethod.POST, value = "/password/create")
public PasswordPolicyTO create(final HttpServletResponse response, @RequestBody final PasswordPolicyTO policyTO) {
return createInternal(policyTO);
}
- @PreAuthorize("hasRole('POLICY_CREATE')")
@RequestMapping(method = RequestMethod.POST, value = "/account/create")
public AccountPolicyTO create(final HttpServletResponse response, @RequestBody final AccountPolicyTO policyTO) {
return createInternal(policyTO);
}
- @PreAuthorize("hasRole('POLICY_CREATE')")
@RequestMapping(method = RequestMethod.POST, value = "/sync/create")
public SyncPolicyTO create(final HttpServletResponse response, @RequestBody final SyncPolicyTO policyTO) {
return createInternal(policyTO);
}
+ @PreAuthorize("hasRole('POLICY_CREATE')")
public <T extends PolicyTO> T createInternal(final T policyTO) {
LOG.debug("Creating policy " + policyTO);
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ReportController.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ReportController.java?rev=1458326&r1=1458325&r2=1458326&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ReportController.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ReportController.java Tue Mar 19 15:06:51 2013
@@ -98,7 +98,6 @@ public class ReportController extends Ab
@Autowired
private ReportDataBinder binder;
- @PreAuthorize("hasRole('REPORT_CREATE')")
@RequestMapping(method = RequestMethod.POST, value = "/create")
public ReportTO create(final HttpServletResponse response, @RequestBody final ReportTO reportTO) {
ReportTO createdReportTO = createInternal(reportTO);
@@ -106,6 +105,7 @@ public class ReportController extends Ab
return createdReportTO;
}
+ @PreAuthorize("hasRole('REPORT_CREATE')")
public ReportTO createInternal(final ReportTO reportTO) {
LOG.debug("Creating report " + reportTO);
@@ -150,11 +150,12 @@ public class ReportController extends Ab
} catch (Exception e) {
LOG.error("While registering quartz job for report " + report.getId(), e);
- SyncopeClientCompositeErrorException scce = new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
+ SyncopeClientCompositeErrorException sccee =
+ new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
SyncopeClientException sce = new SyncopeClientException(SyncopeClientExceptionType.Scheduling);
sce.addElement(e.getMessage());
- scce.addException(sce);
- throw scce;
+ sccee.addException(sce);
+ throw sccee;
}
auditManager.audit(Category.report, ReportSubCategory.update, Result.success,
@@ -199,13 +200,13 @@ public class ReportController extends Ab
return result;
}
- @PreAuthorize("hasRole('REPORT_LIST')")
@RequestMapping(method = RequestMethod.GET, value = "/reportletConfClasses")
public ModelAndView getReportletConfClasses() {
Set<String> reportletConfClasses = getReportletConfClassesInternal();
return new ModelAndView().addObject(reportletConfClasses);
}
+ @PreAuthorize("hasRole('REPORT_LIST')")
@SuppressWarnings("rawtypes")
public Set<String> getReportletConfClassesInternal() {
Set<String> reportletConfClasses = new HashSet<String>();
@@ -251,7 +252,6 @@ public class ReportController extends Ab
return binder.getReportExecTO(reportExec);
}
- @PreAuthorize("hasRole('REPORT_READ')")
@RequestMapping(method = RequestMethod.GET, value = "/execution/export/{executionId}")
@Transactional(readOnly = true)
public void exportExecutionResult(final HttpServletResponse response,
@@ -275,6 +275,7 @@ public class ReportController extends Ab
exportExecutionResultInternal(os, reportExec, format);
}
+ @PreAuthorize("hasRole('REPORT_READ')")
public void exportExecutionResultInternal(final OutputStream os, final ReportExec reportExec,
final ReportExecExportFormat format) {
@@ -338,14 +339,15 @@ public class ReportController extends Ab
"Successfully exported report execution: " + reportExec.getId());
}
+ @PreAuthorize("hasRole('REPORT_READ')")
public ReportExec getAndCheckReportExecInternal(final Long executionId) {
ReportExec reportExec = reportExecDAO.find(executionId);
if (reportExec == null) {
throw new NotFoundException("Report execution " + executionId);
}
if (!ReportExecStatus.SUCCESS.name().equals(reportExec.getStatus()) || reportExec.getExecResult() == null) {
- SyncopeClientCompositeErrorException sccee = new SyncopeClientCompositeErrorException(
- HttpStatus.BAD_REQUEST);
+ SyncopeClientCompositeErrorException sccee =
+ new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
SyncopeClientException sce = new SyncopeClientException(SyncopeClientExceptionType.InvalidReportExec);
sce.addElement(reportExec.getExecResult() == null
? "No report data produced"
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/TaskController.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/TaskController.java?rev=1458326&r1=1458325&r2=1458326&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/TaskController.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/TaskController.java Tue Mar 19 15:06:51 2013
@@ -99,13 +99,11 @@ public class TaskController extends Abst
@Autowired
private ImplementationClassNamesLoader classNamesLoader;
- @PreAuthorize("hasRole('TASK_CREATE')")
@RequestMapping(method = RequestMethod.POST, value = "/create/sync")
public TaskTO createSyncTask(final HttpServletResponse response, @RequestBody final SyncTaskTO taskTO) {
return createSchedTask(response, taskTO);
}
- @PreAuthorize("hasRole('TASK_CREATE')")
@RequestMapping(method = RequestMethod.POST, value = "/create/sched")
public TaskTO createSchedTask(final HttpServletResponse response, @RequestBody final SchedTaskTO taskTO) {
TaskTO createdTaskTO = createSchedTaskInternal(taskTO);
@@ -113,6 +111,7 @@ public class TaskController extends Abst
return createdTaskTO;
}
+ @PreAuthorize("hasRole('TASK_CREATE')")
public TaskTO createSchedTaskInternal(final SchedTaskTO taskTO) {
LOG.debug("Creating task " + taskTO);
@@ -180,12 +179,12 @@ public class TaskController extends Abst
return binder.getTaskTO(task, taskUtil);
}
- @PreAuthorize("hasRole('TASK_LIST')")
@RequestMapping(method = RequestMethod.GET, value = "/{kind}/count")
public ModelAndView count(@PathVariable("kind") final String kind) {
return new ModelAndView().addObject(countInternal(kind));
}
+ @PreAuthorize("hasRole('TASK_LIST')")
public int countInternal(final String kind) {
return taskDAO.count(getTaskUtil(kind).taskClass());
}
@@ -445,9 +444,9 @@ public class TaskController extends Abst
}
@PreAuthorize("(hasRole('TASK_DELETE') and #bulkAction.operation == #bulkAction.operation.DELETE) or "
- + "(hasRole('TASK_EXECUTE') and "
- + "(#bulkAction.operation == #bulkAction.operation.EXECUTE or "
- + "#bulkAction.operation == #bulkAction.operation.DRYRUN))")
+ + "(hasRole('TASK_EXECUTE') and "
+ + "(#bulkAction.operation == #bulkAction.operation.EXECUTE or "
+ + "#bulkAction.operation == #bulkAction.operation.DRYRUN))")
@RequestMapping(method = RequestMethod.POST, value = "/bulk")
public BulkActionRes bulkAction(@RequestBody final BulkAction bulkAction) {
LOG.debug("Bulk action '{}' called on '{}'", bulkAction.getOperation(), bulkAction.getTargets());
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserController.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserController.java?rev=1458326&r1=1458325&r2=1458326&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserController.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserController.java Tue Mar 19 15:06:51 2013
@@ -117,49 +117,49 @@ public class UserController {
@Autowired
protected ConnObjectUtil connObjectUtil;
- @PreAuthorize("hasRole('USER_READ')")
@RequestMapping(method = RequestMethod.GET, value = "/verifyPassword/{username}")
- @Transactional(readOnly = true)
public ModelAndView verifyPassword(@PathVariable("username") String username,
@RequestParam("password") final String password) {
return new ModelAndView().addObject(verifyPasswordInternal(username, password));
}
+ @PreAuthorize("hasRole('USER_READ')")
+ @Transactional(readOnly = true)
public Boolean verifyPasswordInternal(final String username, final String password) {
auditManager.audit(Category.user, UserSubCategory.create, Result.success,
"Verified password for: " + username);
return binder.verifyPassword(username, password);
}
- @PreAuthorize("hasRole('USER_LIST')")
@RequestMapping(method = RequestMethod.GET, value = "/count")
- @Transactional(readOnly = true, rollbackFor = {Throwable.class})
public ModelAndView count() {
return new ModelAndView().addObject(countInternal());
}
+ @PreAuthorize("hasRole('USER_LIST')")
@Transactional(readOnly = true, rollbackFor = {Throwable.class})
public int countInternal() {
return userDAO.count(EntitlementUtil.getRoleIds(EntitlementUtil.getOwnedEntitlementNames()));
}
- @PreAuthorize("hasRole('USER_READ')")
@RequestMapping(method = RequestMethod.POST, value = "/search/count")
- @Transactional(readOnly = true, rollbackFor = {Throwable.class})
public ModelAndView searchCount(@RequestBody final NodeCond searchCondition)
throws InvalidSearchConditionException {
return new ModelAndView().addObject(searchCountInternal(searchCondition));
}
+ @PreAuthorize("hasRole('USER_READ')")
+ @Transactional(readOnly = true, rollbackFor = {Throwable.class})
public int searchCountInternal(final NodeCond searchCondition) throws InvalidSearchConditionException {
if (!searchCondition.isValid()) {
LOG.error("Invalid search condition: {}", searchCondition);
throw new InvalidSearchConditionException();
}
- final Set<Long> adminRoleIds = EntitlementUtil.getRoleIds(EntitlementUtil.getOwnedEntitlementNames());
- return searchDAO.count(adminRoleIds, searchCondition, AttributableUtil.getInstance(AttributableType.USER));
+
+ return searchDAO.count(EntitlementUtil.getRoleIds(EntitlementUtil.getOwnedEntitlementNames()),
+ searchCondition, AttributableUtil.getInstance(AttributableType.USER));
}
@PreAuthorize("hasRole('USER_LIST')")
@@ -214,7 +214,6 @@ public class UserController {
@RequestMapping(method = RequestMethod.GET, value = "/readByUsername/{username}")
@Transactional(readOnly = true, rollbackFor = {Throwable.class})
public UserTO read(@PathVariable final String username) {
-
UserTO result = binder.getUserTO(username);
auditManager.audit(Category.user, UserSubCategory.read, Result.success,
@@ -273,7 +272,6 @@ public class UserController {
return result;
}
- @PreAuthorize("hasRole('USER_CREATE')")
@RequestMapping(method = RequestMethod.POST, value = "/create")
public UserTO create(final HttpServletResponse response, @RequestBody final UserTO userTO) {
UserTO savedTO = createInternal(userTO);
@@ -281,6 +279,7 @@ public class UserController {
return savedTO;
}
+ @PreAuthorize("hasRole('USER_CREATE')")
public UserTO createInternal(final UserTO userTO) {
LOG.debug("User create called with {}", userTO);
@@ -700,9 +699,9 @@ public class UserController {
}
@PreAuthorize("(hasRole('USER_DELETE') and #bulkAction.operation == #bulkAction.operation.DELETE) or "
- + "(hasRole('USER_UPDATE') and "
- + "(#bulkAction.operation == #bulkAction.operation.REACTIVATE or "
- + "#bulkAction.operation == #bulkAction.operation.SUSPEND))")
+ + "(hasRole('USER_UPDATE') and "
+ + "(#bulkAction.operation == #bulkAction.operation.REACTIVATE or "
+ + "#bulkAction.operation == #bulkAction.operation.SUSPEND))")
@RequestMapping(method = RequestMethod.POST, value = "/bulk")
public BulkActionRes bulkAction(@RequestBody final BulkAction bulkAction) {
LOG.debug("Bulk action '{}' called on '{}'", bulkAction.getOperation(), bulkAction.getTargets());