=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/DefaultSecurityService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/DefaultSecurityService.java 2014-08-15 07:40:20 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/DefaultSecurityService.java 2014-09-08 03:44:30 +0000 @@ -145,9 +145,9 @@ return true; } - public boolean sendRestoreMessage( UserCredentials credentials, String rootPath, RestoreOptions restoreOptions ) + public boolean validateRestore( UserCredentials credentials, RestoreOptions restoreOptions ) { - if ( credentials == null || rootPath == null ) + if ( credentials == null || restoreOptions == null ) { return false; } @@ -174,7 +174,24 @@ if ( credentials.hasAnyAuthority( Arrays.asList( UserAuthorityGroup.CRITICAL_AUTHS ) ) ) { - log.info( "Not allowed to " + restoreType.name() + " users with critical authorities" ); + log.info( "Not allowed to " + restoreType.name() + " users with critical authorities" ); + return false; + } + + return true; + } + + public boolean sendRestoreMessage( UserCredentials credentials, String rootPath, RestoreOptions restoreOptions ) + { + if ( credentials == null || rootPath == null || restoreOptions == null ) + { + return false; + } + + RestoreType restoreType = restoreOptions.getRestoreType(); + + if ( validateRestore( credentials, restoreOptions ) == false ) + { return false; } === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/SecurityService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/SecurityService.java 2014-05-24 18:16:41 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/SecurityService.java 2014-09-08 03:44:30 +0000 @@ -45,6 +45,14 @@ * @return true if the invitation was sent, otherwise false. */ boolean prepareUserForInvite( User user ); + + /** + * Validates whether a restore is allowed. + * + * @param credentials the credentials for the user to send restore message. + * @param restoreOptions restore options, including type of restore. + */ + boolean validateRestore( UserCredentials credentials, RestoreOptions restoreOptions ); /** * Invokes the initRestore method and dispatches email messages with