Skip to content

Commit

Permalink
do not emit AuthorisationException if Rollback is desired
Browse files Browse the repository at this point in the history
  • Loading branch information
rkrenn committed Dec 10, 2024
1 parent 4e8949e commit febb09f
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ public interface AuthorisationExceptionCodes {
public final static String NOT_AUTHENTICATED = "not_authenticated";
public static final String PARAMETER_DISJUNCTIVE_RESTRICTION_NOT_SATISFIED = "parameter_disjunctive_restriction_not_satisfied";
public static final String PARAMETER_RESTRICTION_VIOLATED = "parameter_restriction_violated";
public final static String FILE_NOT_PUBLIC = "file_not_public";
public final static String FILE_NOT_ACTIVE = "file_not_active";
public final static String HYPERLINK_NOT_ACTIVE = "hyperlink_not_active";
public final static String ENCRYPTED_FILE = "encrypted_file";
// public final static String FILE_NOT_PUBLIC = "file_not_public";
// public final static String FILE_NOT_ACTIVE = "file_not_active";
// public final static String ALL_DEPARMTENTS_PERMISSION_REQUIRED = "all_deparmtents_permission_required";
// public final static String HYPERLINK_NOT_ACTIVE = "hyperlink_not_active";
//public final static String ENCRYPTED_FILE = "encrypted_file";
}
Original file line number Diff line number Diff line change
Expand Up @@ -835,4 +835,9 @@ public interface ServiceExceptionCodes {
public static final String JOB_INVALID_EMAIL_RECIPIENTS = "job_invalid_email_recipients";
public static final String JOB_ALREADY_EXISTS = "job_already_exists";
public static final String VISIT_ID_NOT_NULL = "visit_id_not_null";
public final static String FILE_NOT_PUBLIC = "file_not_public";
public final static String FILE_NOT_ACTIVE = "file_not_active";
public final static String ALL_DEPARMTENTS_PERMISSION_REQUIRED = "all_deparmtents_permission_required";
public final static String HYPERLINK_NOT_ACTIVE = "hyperlink_not_active";
public final static String ENCRYPTED_FILE = "encrypted_file";
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
import org.openjdk.nashorn.api.scripting.JSObject;
import org.phoenixctms.ctsms.domain.File;
import org.phoenixctms.ctsms.domain.FileDao;
import org.phoenixctms.ctsms.util.AuthorisationExceptionCodes;
import org.phoenixctms.ctsms.util.CheckIDUtil;
import org.phoenixctms.ctsms.util.CommonUtil;
import org.phoenixctms.ctsms.util.CoreUtil;
import org.phoenixctms.ctsms.util.DefaultSettings;
import org.phoenixctms.ctsms.util.L10nUtil;
import org.phoenixctms.ctsms.util.L10nUtil.Locales;
import org.phoenixctms.ctsms.util.ServiceExceptionCodes;
import org.phoenixctms.ctsms.util.SettingCodes;
import org.phoenixctms.ctsms.util.Settings;
import org.phoenixctms.ctsms.util.Settings.Bundle;
Expand Down Expand Up @@ -217,10 +217,10 @@ public ArrayList<ValidationError> updateInputFieldVariables() throws ScriptExcep
public String getScript(String resource, Long fileId) throws Exception {
File file = CheckIDUtil.checkFileId(fileId, fileDao);
if (CommonUtil.getUseFileEncryption(file.getModule())) {
throw L10nUtil.initAuthorisationException(AuthorisationExceptionCodes.ENCRYPTED_FILE, fileId.toString());
throw L10nUtil.initServiceException(ServiceExceptionCodes.ENCRYPTED_FILE, fileId.toString());
}
if (!file.isPublicFile()) {
throw L10nUtil.initAuthorisationException(AuthorisationExceptionCodes.FILE_NOT_PUBLIC, fileId.toString());
throw L10nUtil.initServiceException(ServiceExceptionCodes.FILE_NOT_PUBLIC, fileId.toString());
}
FileContentOutVO result = fileDao.toFileContentOutVO(file);
return new String(result.getDatas(), SCRIPT_CHARSET);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,11 @@
import org.phoenixctms.ctsms.enumeration.FileModule;
import org.phoenixctms.ctsms.enumeration.PermissionProfile;
import org.phoenixctms.ctsms.enumeration.PermissionProfileGroup;
import org.phoenixctms.ctsms.exception.AuthorisationException;
import org.phoenixctms.ctsms.exception.ServiceException;
import org.phoenixctms.ctsms.pdf.PDFMerger;
import org.phoenixctms.ctsms.security.CipherStream;
import org.phoenixctms.ctsms.security.CipherText;
import org.phoenixctms.ctsms.security.CryptoUtil;
import org.phoenixctms.ctsms.util.AuthorisationExceptionCodes;
import org.phoenixctms.ctsms.util.CheckIDUtil;
import org.phoenixctms.ctsms.util.CommonUtil;
import org.phoenixctms.ctsms.util.CoreUtil;
Expand Down Expand Up @@ -324,7 +322,7 @@ private void checkMimeType(String mimeType, FileModule module) throws ServiceExc
}
}

private void checkActivePermission(File file) throws AuthorisationException {
private void checkActivePermission(File file) throws ServiceException {
//if (!file.isActive()) {
User user = CoreUtil.getUser();
//!file.getDepartments().contains(user.getDepartment()
Expand All @@ -337,7 +335,7 @@ private void checkActivePermission(File file) throws AuthorisationException {
PermissionProfile.INVENTORY_DETAIL_ALL_DEPARTMENTS,
PermissionProfile.INVENTORY_VIEW_ALL_DEPARTMENTS)) {
if (!file.isActive() || !file.getDepartments().contains(user.getDepartment())) {
throw L10nUtil.initAuthorisationException(AuthorisationExceptionCodes.FILE_NOT_ACTIVE, file.getId().toString());
throw L10nUtil.initServiceException(ServiceExceptionCodes.FILE_NOT_ACTIVE, file.getId().toString());
}
}
break;
Expand All @@ -347,7 +345,7 @@ private void checkActivePermission(File file) throws AuthorisationException {
PermissionProfile.STAFF_DETAIL_ALL_DEPARTMENTS,
PermissionProfile.STAFF_VIEW_ALL_DEPARTMENTS)) {
if (!file.isActive() || !file.getDepartments().contains(user.getDepartment())) {
throw L10nUtil.initAuthorisationException(AuthorisationExceptionCodes.FILE_NOT_ACTIVE, file.getId().toString());
throw L10nUtil.initServiceException(ServiceExceptionCodes.FILE_NOT_ACTIVE, file.getId().toString());
}
}
break;
Expand All @@ -357,7 +355,7 @@ private void checkActivePermission(File file) throws AuthorisationException {
PermissionProfile.COURSE_DETAIL_ALL_DEPARTMENTS,
PermissionProfile.COURSE_VIEW_ALL_DEPARTMENTS)) {
if (!file.isActive() || !file.getDepartments().contains(user.getDepartment())) {
throw L10nUtil.initAuthorisationException(AuthorisationExceptionCodes.FILE_NOT_ACTIVE, file.getId().toString());
throw L10nUtil.initServiceException(ServiceExceptionCodes.FILE_NOT_ACTIVE, file.getId().toString());
}
}
break;
Expand All @@ -367,7 +365,7 @@ private void checkActivePermission(File file) throws AuthorisationException {
PermissionProfile.TRIAL_DETAIL_ALL_DEPARTMENTS,
PermissionProfile.TRIAL_VIEW_ALL_DEPARTMENTS)) {
if (!file.isActive() || !file.getDepartments().contains(user.getDepartment())) {
throw L10nUtil.initAuthorisationException(AuthorisationExceptionCodes.FILE_NOT_ACTIVE, file.getId().toString());
throw L10nUtil.initServiceException(ServiceExceptionCodes.FILE_NOT_ACTIVE, file.getId().toString());
}
}
break;
Expand All @@ -377,7 +375,7 @@ private void checkActivePermission(File file) throws AuthorisationException {
PermissionProfile.PROBAND_DETAIL_ALL_DEPARTMENTS,
PermissionProfile.PROBAND_VIEW_ALL_DEPARTMENTS)) {
if (!file.isActive() || !file.getDepartments().contains(user.getDepartment())) {
throw L10nUtil.initAuthorisationException(AuthorisationExceptionCodes.FILE_NOT_ACTIVE, file.getId().toString());
throw L10nUtil.initServiceException(ServiceExceptionCodes.FILE_NOT_ACTIVE, file.getId().toString());
}
}
break;
Expand All @@ -387,7 +385,7 @@ private void checkActivePermission(File file) throws AuthorisationException {
PermissionProfile.MASS_MAIL_DETAIL_ALL_DEPARTMENTS,
PermissionProfile.MASS_MAIL_VIEW_ALL_DEPARTMENTS)) {
if (!file.isActive() || !file.getDepartments().contains(user.getDepartment())) {
throw L10nUtil.initAuthorisationException(AuthorisationExceptionCodes.FILE_NOT_ACTIVE, file.getId().toString());
throw L10nUtil.initServiceException(ServiceExceptionCodes.FILE_NOT_ACTIVE, file.getId().toString());
}
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@
import org.phoenixctms.ctsms.enumeration.JournalModule;
import org.phoenixctms.ctsms.enumeration.PermissionProfile;
import org.phoenixctms.ctsms.enumeration.PermissionProfileGroup;
import org.phoenixctms.ctsms.exception.AuthorisationException;
import org.phoenixctms.ctsms.exception.ServiceException;
import org.phoenixctms.ctsms.util.AuthorisationExceptionCodes;
import org.phoenixctms.ctsms.util.CheckIDUtil;
import org.phoenixctms.ctsms.util.CommonUtil;
import org.phoenixctms.ctsms.util.CoreUtil;
Expand Down Expand Up @@ -164,7 +162,7 @@ private void checkHyperlinkModuleId(HyperlinkModule module, Long id) throws Serv
}
}

private void checkActivePermission(Hyperlink hyperlink) throws AuthorisationException {
private void checkActivePermission(Hyperlink hyperlink) throws ServiceException {
//if (!hyperlink.isActive()) {
User user = CoreUtil.getUser();
if (!user.equals(hyperlink.getModifiedUser())) {
Expand All @@ -176,7 +174,7 @@ private void checkActivePermission(Hyperlink hyperlink) throws AuthorisationExce
PermissionProfile.INVENTORY_DETAIL_ALL_DEPARTMENTS,
PermissionProfile.INVENTORY_VIEW_ALL_DEPARTMENTS)) {
if (!hyperlink.isActive() || !hyperlink.getDepartments().contains(user.getDepartment())) {
throw L10nUtil.initAuthorisationException(AuthorisationExceptionCodes.HYPERLINK_NOT_ACTIVE, hyperlink.getId().toString());
throw L10nUtil.initServiceException(ServiceExceptionCodes.HYPERLINK_NOT_ACTIVE, hyperlink.getId().toString());
}
}
break;
Expand All @@ -186,7 +184,7 @@ private void checkActivePermission(Hyperlink hyperlink) throws AuthorisationExce
PermissionProfile.STAFF_DETAIL_ALL_DEPARTMENTS,
PermissionProfile.STAFF_VIEW_ALL_DEPARTMENTS)) {
if (!hyperlink.isActive() || !hyperlink.getDepartments().contains(user.getDepartment())) {
throw L10nUtil.initAuthorisationException(AuthorisationExceptionCodes.HYPERLINK_NOT_ACTIVE, hyperlink.getId().toString());
throw L10nUtil.initServiceException(ServiceExceptionCodes.HYPERLINK_NOT_ACTIVE, hyperlink.getId().toString());
}
}
break;
Expand All @@ -196,7 +194,7 @@ private void checkActivePermission(Hyperlink hyperlink) throws AuthorisationExce
PermissionProfile.COURSE_DETAIL_ALL_DEPARTMENTS,
PermissionProfile.COURSE_VIEW_ALL_DEPARTMENTS)) {
if (!hyperlink.isActive() || !hyperlink.getDepartments().contains(user.getDepartment())) {
throw L10nUtil.initAuthorisationException(AuthorisationExceptionCodes.HYPERLINK_NOT_ACTIVE, hyperlink.getId().toString());
throw L10nUtil.initServiceException(ServiceExceptionCodes.HYPERLINK_NOT_ACTIVE, hyperlink.getId().toString());
}
}
break;
Expand All @@ -206,7 +204,7 @@ private void checkActivePermission(Hyperlink hyperlink) throws AuthorisationExce
PermissionProfile.TRIAL_DETAIL_ALL_DEPARTMENTS,
PermissionProfile.TRIAL_VIEW_ALL_DEPARTMENTS)) {
if (!hyperlink.isActive() || !hyperlink.getDepartments().contains(user.getDepartment())) {
throw L10nUtil.initAuthorisationException(AuthorisationExceptionCodes.HYPERLINK_NOT_ACTIVE, hyperlink.getId().toString());
throw L10nUtil.initServiceException(ServiceExceptionCodes.HYPERLINK_NOT_ACTIVE, hyperlink.getId().toString());
}
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@
import org.phoenixctms.ctsms.security.CryptoUtil;
import org.phoenixctms.ctsms.security.PasswordPolicy;
import org.phoenixctms.ctsms.security.otp.OTPAuthenticator;
import org.phoenixctms.ctsms.util.AuthorisationExceptionCodes;
import org.phoenixctms.ctsms.util.CheckIDUtil;
import org.phoenixctms.ctsms.util.CommonUtil;
import org.phoenixctms.ctsms.util.Compile;
Expand Down Expand Up @@ -992,10 +991,10 @@ protected FileStreamOutVO handleGetPublicFileStream(Long fileId)
FileDao fileDao = this.getFileDao();
File file = CheckIDUtil.checkFileId(fileId, fileDao);
if (CommonUtil.getUseFileEncryption(file.getModule())) {
throw L10nUtil.initAuthorisationException(AuthorisationExceptionCodes.ENCRYPTED_FILE, fileId.toString());
throw L10nUtil.initServiceException(ServiceExceptionCodes.ENCRYPTED_FILE, fileId.toString());
}
if (!file.isPublicFile()) {
throw L10nUtil.initAuthorisationException(AuthorisationExceptionCodes.FILE_NOT_PUBLIC, fileId.toString());
throw L10nUtil.initServiceException(ServiceExceptionCodes.FILE_NOT_PUBLIC, fileId.toString());
}
FileStreamOutVO result = fileDao.toFileStreamOutVO(file);
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ criteria_modified_different_property=not allowed to perform unsaved query - prop
no_host=not allowed to perform operation {0} - host address unknown
host_not_allowed_or_unknown_host=not allowed to perform operation {0} from host address {1}

file_not_public=file ID {0} is not exposed to the internet
file_not_active=file ID {0} is not approved
hyperlink_not_active=hyperlink ID {0} is not approved

encrypted_file=file ID {0} is encrypted


Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,5 @@ criteria_modified_different_property=Ausf\u00FChrung nicht gespeicherter Abfrage
no_host=Ausf\u00FChrung der Operation {0} nicht erlaubt - Host-Adresse nicht bekannt
host_not_allowed_or_unknown_host=Ausf\u00FChrung der Operation {0} von Host-Adresse {1} nicht erlaubt

file_not_public=Datei ID {0} ist nicht im Internet abrufbar
file_not_active=Datei ID {0} ist nicht freigegeben
hyperlink_not_active=Hyperlink ID {0} ist nicht freigegeben

encrypted_file=Datei ID {0} ist verschl\u00FCsselt

Original file line number Diff line number Diff line change
Expand Up @@ -982,4 +982,12 @@ job_email_recipients_not_null=no email address(es) required
job_invalid_email_recipients=invalid email address(es): {1}
job_already_exists=repeating job ''{0}'' already exists

visit_id_not_null=visit ID must be null
visit_id_not_null=visit ID must be null

file_not_public=file ID {0} is not exposed to the internet
file_not_active=file ID {0} is not approved
hyperlink_not_active=hyperlink ID {0} is not approved

all_deparmtents_permission_required=permission for all sites required

encrypted_file=file ID {0} is encrypted
Original file line number Diff line number Diff line change
Expand Up @@ -984,4 +984,11 @@ job_email_recipients_not_null=keine Email Adresse(n) erforderlich
job_invalid_email_recipients=ung\u00FCltige Email Adresse(n): {1}
job_already_exists=wiederholender Job ''{0}'' existiert bereits

visit_id_not_null=Visite ID muss null sein
visit_id_not_null=Visite ID muss null sein

file_not_public=Datei ID {0} ist nicht im Internet abrufbar
file_not_active=Datei ID {0} ist nicht freigegeben
hyperlink_not_active=Hyperlink ID {0} ist nicht freigegeben
all_deparmtents_permission_required=Berechtigung f\u00FCr alle Sites erforderlich

encrypted_file=Datei ID {0} ist verschl\u00FCsselt

0 comments on commit febb09f

Please sign in to comment.