Skip to content
Snippets Groups Projects
Commit a4e007cc authored by OZGCloud's avatar OZGCloud
Browse files

OZG-5666 adjust empty attachments implementation

parent 7056c0f1
Branches
Tags
No related merge requests found
...@@ -139,14 +139,14 @@ public class AntragraumService { ...@@ -139,14 +139,14 @@ public class AntragraumService {
return postfachNachrichtService.findAnswers(BAYERN_ID_SERVICE_KONTO_TYPE, getPostfachId(samlToken), rueckfrageId); return postfachNachrichtService.findAnswers(BAYERN_ID_SERVICE_KONTO_TYPE, getPostfachId(samlToken), rueckfrageId);
} }
String getPostfachId(String samlToken) {
return decrypter.decryptPostfachId(parser.parse(samlToken));
}
void verifyToken(String token) { void verifyToken(String token) {
var errors = verifier.verify(token); var errors = verifier.verify(token);
if (CollectionUtils.isNotEmpty(errors)) { if (CollectionUtils.isNotEmpty(errors)) {
throw new SecurityException("SAML Token verification failed. Errors: %s".formatted(errors)); throw new SecurityException("SAML Token verification failed. Errors: %s".formatted(errors));
} }
} }
String getPostfachId(String samlToken) {
return decrypter.decryptPostfachId(parser.parse(samlToken));
}
} }
...@@ -88,8 +88,7 @@ public abstract class PostfachNachrichtMapper { ...@@ -88,8 +88,7 @@ public abstract class PostfachNachrichtMapper {
.setReplyOption(MapUtils.getString(mailMap, PostfachNachricht.FIELD_REPLY_OPTION)); .setReplyOption(MapUtils.getString(mailMap, PostfachNachricht.FIELD_REPLY_OPTION));
Optional.ofNullable(mailMap.get(PostfachNachricht.FIELD_ATTACHMENTS)) Optional.ofNullable(mailMap.get(PostfachNachricht.FIELD_ATTACHMENTS))
.map(String.class::cast) .filter(this::doesAttachmentsExists)
.map(StringUtils::trimToNull)
.map(this::getAttachments) .map(this::getAttachments)
.ifPresent(postfachMailBuilder::addAllAttachment); .ifPresent(postfachMailBuilder::addAllAttachment);
...@@ -101,6 +100,10 @@ public abstract class PostfachNachrichtMapper { ...@@ -101,6 +100,10 @@ public abstract class PostfachNachrichtMapper {
return postfachMailBuilder.build(); return postfachMailBuilder.build();
} }
private boolean doesAttachmentsExists(Object attachments) {
return (attachments instanceof String attachment && StringUtils.isNotBlank(attachment)) || attachments instanceof Collection;
}
private Iterable<String> getAttachments(Object attachments) { private Iterable<String> getAttachments(Object attachments) {
if (attachments instanceof String attachment) { if (attachments instanceof String attachment) {
return Collections.singletonList(attachment); return Collections.singletonList(attachment);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment