Skip to content

Commit

Permalink
fixed privilege issue in mailbox scanner. issue #2246
Browse files Browse the repository at this point in the history
  • Loading branch information
j-dimension committed Oct 1, 2024
1 parent 9c1eabf commit d5a9002
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 16 deletions.
Binary file modified j-lawyer-client/lib/j-lawyer-cloud/j-lawyer-cloud.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -705,10 +705,10 @@ public HashMap<String, Object> getPlaceHolderValues(String content, ArchiveFileB
}

if(formPlaceHolders==null && contextArchiveFile != null) {
formPlaceHolders = forms.getPlaceHoldersForCase(contextArchiveFile.getId());
formPlaceHolders = forms.getPlaceHoldersForCaseUnrestricted(contextArchiveFile.getId());
}
if(formPlaceHolderValues==null && contextArchiveFile != null) {
formPlaceHolderValues = forms.getPlaceHolderValuesForCase(contextArchiveFile.getId());
formPlaceHolderValues = forms.getPlaceHolderValuesForCaseUnrestricted(contextArchiveFile.getId());
}

ArrayList<String> placeHolderNames = getPlaceHoldersInTemplate(content, allPartyTypesPlaceholders, formPlaceHolders);
Expand All @@ -720,13 +720,13 @@ public HashMap<String, Object> getPlaceHolderValues(String content, ArchiveFileB
if (contextArchiveFile != null) {
try {
if(caseLawyer==null && !ServerStringUtils.isEmpty(contextArchiveFile.getLawyer()))
caseLawyer = sys.getUser(contextArchiveFile.getLawyer());
caseLawyer = sys.getUserUnrestricted(contextArchiveFile.getLawyer());
} catch (Exception ex) {
log.warn("Unable to load lawyer with id " + contextArchiveFile.getLawyer());
}
try {
if(caseAssistant==null && !ServerStringUtils.isEmpty(contextArchiveFile.getAssistant()))
caseAssistant = sys.getUser(contextArchiveFile.getAssistant());
caseAssistant = sys.getUserUnrestricted(contextArchiveFile.getAssistant());
} catch (Exception ex) {
log.warn("Unable to load assistant with id " + contextArchiveFile.getAssistant());
}
Expand All @@ -737,7 +737,7 @@ public HashMap<String, Object> getPlaceHolderValues(String content, ArchiveFileB
parties.add(new PartiesTriplet(aab.getAddressKey(), aab.getReferenceType(), aab));
}

return sys.getPlaceHolderValues(ht, contextArchiveFile, parties, "", null, formPlaceHolderValues, caseLawyer, caseAssistant, null, invoice, invoiceSender, null, null, null, null);
return sys.getPlaceHolderValuesUnrestricted(ht, contextArchiveFile, parties, "", null, formPlaceHolderValues, caseLawyer, caseAssistant, null, invoice, invoiceSender, null, null, null, null);

} catch (Exception ex) {
log.error("Error getting placeholder values", ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2001,16 +2001,23 @@ public boolean setDocumentContent(String id, byte[] content) throws Exception {
return true;
}

@Override
public String getNewDocumentNameUnrestricted(String fileName, Date date, DocumentNameTemplate tpl) throws Exception {
return getNewDocumentNameImpl(fileName, date, tpl);
}

@Override
@RolesAllowed({"loginRole"})
public String getNewDocumentName(String fileName, Date date, DocumentNameTemplate tpl) throws Exception {

return getNewDocumentNameImpl(fileName, date, tpl);
}

private String getNewDocumentNameImpl(String fileName, Date date, DocumentNameTemplate tpl) throws Exception {
try {
return FileNameGenerator.getFileName(tpl.getPattern(), date, fileName);
} catch (InvalidSchemaPatternException isp) {
throw new Exception(isp.getMessage());
}

}

@Override
Expand Down Expand Up @@ -3738,6 +3745,11 @@ public List<ArchiveFileAddressesBean> getInvolvementDetailsForCase(String archiv
public List<ArchiveFileAddressesBean> getInvolvementDetailsForCaseUnrestricted(String archiveFileKey) {
return this.getInvolvementDetailsForCaseImpl(archiveFileKey, true);
}

@Override
public List<ArchiveFileAddressesBean> getInvolvementDetailsForCaseUnrestricted(String archiveFileKey, boolean includeCases) {
return this.getInvolvementDetailsForCaseImpl(archiveFileKey, includeCases);
}

@Override
@RolesAllowed({"adminRole"})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,7 @@ public interface ArchiveFileServiceLocal {
public List<ArchiveFileAddressesBean> getInvolvementDetailsForCase(String archiveFileKey, boolean includeCases);

public List<ArchiveFileAddressesBean> getInvolvementDetailsForCaseUnrestricted(String archiveFileKey);
public List<ArchiveFileAddressesBean> getInvolvementDetailsForCaseUnrestricted(String archiveFileKey, boolean includeCases);

boolean doesDocumentExist(String caseId, String documentName);
boolean doesDocumentExistUnrestricted(String caseId, String documentName);
Expand All @@ -741,6 +742,7 @@ public interface ArchiveFileServiceLocal {

ArchiveFileDocumentsBean getDocument(String id) throws Exception;
String getNewDocumentName(String fileName, Date date, DocumentNameTemplate tpl) throws Exception;
String getNewDocumentNameUnrestricted(String fileName, Date date, DocumentNameTemplate tpl) throws Exception;

Collection<DocumentTagsBean> getDocumentTags(String documentId) throws Exception;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1042,9 +1042,18 @@ public ArchiveFileFormsBean getForm(String formId) throws Exception {

}

@Override
public Collection<String> getPlaceHoldersForCaseUnrestricted(String caseId) throws Exception {
return getPlaceHoldersForCaseImpl(caseId);
}

@Override
@RolesAllowed({"loginRole"})
public Collection<String> getPlaceHoldersForCase(String caseId) throws Exception {
return getPlaceHoldersForCaseImpl(caseId);
}

private Collection<String> getPlaceHoldersForCaseImpl(String caseId) throws Exception {
ArchiveFileBean caseBean = this.caseFacade.find(caseId);
if (caseBean == null) {
throw new Exception("Akte " + caseId + " ist nicht vorhanden!");
Expand All @@ -1068,12 +1077,20 @@ public Collection<String> getPlaceHoldersForCase(String caseId) throws Exception
}
}
return placeHolders;

}

@Override
public HashMap<String, String> getPlaceHolderValuesForCaseUnrestricted(String caseId) throws Exception {
return this.getPlaceHolderValuesForCaseImpl(caseId);
}

@Override
@RolesAllowed({"readArchiveFileRole"})
public HashMap<String, String> getPlaceHolderValuesForCase(String caseId) throws Exception {
return this.getPlaceHolderValuesForCaseImpl(caseId);
}

private HashMap<String, String> getPlaceHolderValuesForCaseImpl(String caseId) throws Exception {
ArchiveFileBean caseBean = this.caseFacade.find(caseId);
if (caseBean == null) {
throw new Exception("Akte " + caseId + " ist nicht vorhanden!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ public interface FormsServiceLocal {
ArchiveFileFormsBean addForm(String caseId, ArchiveFileFormsBean form) throws Exception;

List<ArchiveFileFormsBean> getFormsForCase(String caseId);

void removeFormType(String formTypeId) throws Exception;

void removeForm(String formId) throws Exception;
Expand All @@ -700,8 +700,10 @@ public interface FormsServiceLocal {
ArchiveFileFormsBean getForm(String id) throws Exception;

Collection<String> getPlaceHoldersForCase(String caseId) throws Exception;
Collection<String> getPlaceHoldersForCaseUnrestricted(String caseId) throws Exception;

HashMap<String, String> getPlaceHolderValuesForCase(String caseId) throws Exception;
HashMap<String, String> getPlaceHolderValuesForCaseUnrestricted(String caseId) throws Exception;

boolean installRepositoryPlugin(ServerFormPlugin plugin) throws Exception;
Map<String, ServerFormPlugin> getPluginsInRepository(String clientVersion) throws Exception;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1225,6 +1225,11 @@ public boolean setSetting(String key, String value) {
public AppUserBean getUser(String principalId) {
return this.userBeanFacade.findByPrincipalId(principalId);
}

@Override
public AppUserBean getUserUnrestricted(String principalId) {
return this.userBeanFacade.findByPrincipalIdUnrestricted(principalId);
}

@Override
@RolesAllowed({"loginRole"})
Expand Down Expand Up @@ -2377,6 +2382,11 @@ public String getTemplatesBaseDir(int templateType) throws Exception {
return getTemplatesBaseDir(templateType, null);
}

@Override
public HashMap<String, Object> getPlaceHolderValuesUnrestricted(HashMap<String, Object> placeHolders, ArchiveFileBean aFile, List<PartiesTriplet> selectedParties, String dictateSign, GenericCalculationTable calculationTable, HashMap<String, String> formsPlaceHolderValues, AppUserBean caseLawyer, AppUserBean caseAssistant, AppUserBean author, Invoice invoice, AppUserBean invoiceSender, GenericCalculationTable invoiceTable, GenericCalculationTable timesheetsTable, byte[] giroCode, String ingoText) throws Exception {
return PlaceHolderServerUtils.getPlaceHolderValues(placeHolders, aFile, selectedParties, dictateSign, calculationTable, formsPlaceHolderValues, caseLawyer, caseAssistant, author, invoice, invoiceSender, invoiceTable, timesheetsTable, giroCode, ingoText);
}

@Override
@RolesAllowed({"loginRole"})
public HashMap<String, Object> getPlaceHolderValues(HashMap<String, Object> placeHolders, ArchiveFileBean aFile, List<PartiesTriplet> selectedParties, String dictateSign, GenericCalculationTable calculationTable, HashMap<String, String> formsPlaceHolderValues, AppUserBean caseLawyer, AppUserBean caseAssistant, AppUserBean author, Invoice invoice, AppUserBean invoiceSender, GenericCalculationTable invoiceTable, GenericCalculationTable timesheetsTable, byte[] giroCode, String ingoText) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,7 @@ public interface SystemManagementLocal {
PartyTypeBean getPartyType(String id);

AppUserBean getUser(String principalId);
AppUserBean getUserUnrestricted(String principalId);

List<AppUserBean> getUsers();

Expand All @@ -730,6 +731,7 @@ public interface SystemManagementLocal {
List<String> getPlaceHoldersForTemplate(int templateType, String templatePath, String templateName, String caseId) throws Exception;

HashMap<String,Object> getPlaceHolderValues(HashMap<String,Object> placeHolders, ArchiveFileBean aFile, List<PartiesTriplet> selectedParties, String dictateSign, GenericCalculationTable calculationTable, HashMap<String,String> formsPlaceHolderValues, AppUserBean caseLawyer, AppUserBean caseAssistant, AppUserBean author, Invoice invoice, AppUserBean invoiceSender, GenericCalculationTable invoiceTable, GenericCalculationTable timesheetsTable, byte[] giroCode, String ingoText) throws Exception;
HashMap<String,Object> getPlaceHolderValuesUnrestricted(HashMap<String,Object> placeHolders, ArchiveFileBean aFile, List<PartiesTriplet> selectedParties, String dictateSign, GenericCalculationTable calculationTable, HashMap<String,String> formsPlaceHolderValues, AppUserBean caseLawyer, AppUserBean caseAssistant, AppUserBean author, Invoice invoice, AppUserBean invoiceSender, GenericCalculationTable invoiceTable, GenericCalculationTable timesheetsTable, byte[] giroCode, String ingoText) throws Exception;

DocumentNameTemplate getDefaultDocumentNameTemplate() throws Exception;
}
Original file line number Diff line number Diff line change
Expand Up @@ -1225,19 +1225,19 @@ private boolean saveToCase(Message msg, Date received, ArchiveFileBean toCase, A

ServerTemplatesUtil serverTemplates = new ServerTemplatesUtil(sysSvc, formsSvc);

List<ArchiveFileAddressesBean> involved = caseSvc.getInvolvementDetailsForCase(toCase.getId(), false);
List<ArchiveFileAddressesBean> involved = caseSvc.getInvolvementDetailsForCaseUnrestricted(toCase.getId(), false);
AppUserBean caseLawyer = null;
try {
caseLawyer = sysSvc.getUser(toCase.getLawyer());
caseLawyer = sysSvc.getUserUnrestricted(toCase.getLawyer());
} catch (Exception ex) {
}
AppUserBean caseAssistant = null;
try {
caseAssistant = sysSvc.getUser(toCase.getAssistant());
caseAssistant = sysSvc.getUserUnrestricted(toCase.getAssistant());
} catch (Exception ex) {
}
Collection<String> formPlaceHolders = formsSvc.getPlaceHoldersForCase(toCase.getId());
HashMap<String, String> formPlaceHolderValues = formsSvc.getPlaceHolderValuesForCase(toCase.getId());
Collection<String> formPlaceHolders = formsSvc.getPlaceHoldersForCaseUnrestricted(toCase.getId());
HashMap<String, String> formPlaceHolderValues = formsSvc.getPlaceHolderValuesForCaseUnrestricted(toCase.getId());

String newNameMsg = msg.getSubject();
if (newNameMsg == null) {
Expand All @@ -1246,7 +1246,7 @@ private boolean saveToCase(Message msg, Date received, ArchiveFileBean toCase, A
newNameMsg = newNameMsg + ".eml";
newNameMsg = ServerFileUtils.sanitizeFileName(newNameMsg);
String extension = ServerFileUtils.getExtension(newNameMsg);
String docName = caseSvc.getNewDocumentName(newNameMsg, received, nameTemplate);
String docName = caseSvc.getNewDocumentNameUnrestricted(newNameMsg, received, nameTemplate);
HashMap<String, Object> placeHolders = serverTemplates.getPlaceHolderValues(docName, toCase, involved, null, null, allPartyTypes, formPlaceHolders, formPlaceHolderValues, caseLawyer, caseAssistant);
docName = ServerTemplatesUtil.replacePlaceHolders(docName, placeHolders);
docName = ServerFileUtils.sanitizeFileName(docName);
Expand Down Expand Up @@ -1305,7 +1305,7 @@ private boolean saveToCase(Message msg, Date received, ArchiveFileBean toCase, A
}
newName = ServerFileUtils.sanitizeFileName(newName);
extension = ServerFileUtils.getExtension(newName);
docName = caseSvc.getNewDocumentName(newName, received, nameTemplate);
docName = caseSvc.getNewDocumentNameUnrestricted(newName, received, nameTemplate);
placeHolders = serverTemplates.getPlaceHolderValues(docName, toCase, involved, null, null, allPartyTypes, formPlaceHolders, formPlaceHolderValues, caseLawyer, caseAssistant);
docName = ServerTemplatesUtil.replacePlaceHolders(docName, placeHolders);
docName = ServerFileUtils.sanitizeFileName(docName);
Expand All @@ -1331,8 +1331,10 @@ private boolean saveToCase(Message msg, Date received, ArchiveFileBean toCase, A
} catch (Exception ex) {
try {
log.error("Unable to save message with subject '" + msg.getSubject() + "'", ex);
return false;
} catch (Exception t) {
log.error("Unable to save message with subject '" + msg.toString() + "'", ex);
return false;
}
}
return true;
Expand Down

0 comments on commit d5a9002

Please sign in to comment.