use of org.apache.cxf.jaxrs.ext.multipart.MultipartInputFilter in project cxf by apache.
the class AbstractJwsMultipartVerificationFilter method addMultipartFilterIfNeeded.
protected void addMultipartFilterIfNeeded(MediaType contentType) {
if (contentType != null && "multipart".equals(contentType.getType())) {
Message m = JAXRSUtils.getCurrentMessage();
MultipartInputFilter jwsFilter = new JwsMultipartSignatureInFilter(m, sigVerifier, bufferPayload, useJwsJsonSignatureFormat);
AttachmentUtils.addMultipartInFilter(jwsFilter);
}
}
use of org.apache.cxf.jaxrs.ext.multipart.MultipartInputFilter in project cxf by apache.
the class AttachmentUtils method addMultipartInFilter.
public static void addMultipartInFilter(MultipartInputFilter filter) {
Message m = JAXRSUtils.getCurrentMessage();
List<MultipartInputFilter> inFilters = CastUtils.cast((List<?>) m.get(IN_FILTERS));
if (inFilters == null) {
inFilters = new ArrayList<>();
m.put(IN_FILTERS, inFilters);
}
inFilters.add(filter);
}
use of org.apache.cxf.jaxrs.ext.multipart.MultipartInputFilter in project cxf by apache.
the class AttachmentUtils method getMultipartBody.
public static MultipartBody getMultipartBody(MessageContext mc, String attachmentDir, String attachmentThreshold, String attachmentMaxSize) {
if (attachmentDir != null) {
mc.put(AttachmentDeserializer.ATTACHMENT_DIRECTORY, attachmentDir);
}
if (attachmentThreshold != null) {
mc.put(AttachmentDeserializer.ATTACHMENT_MEMORY_THRESHOLD, attachmentThreshold);
}
if (attachmentMaxSize != null) {
mc.put(AttachmentDeserializer.ATTACHMENT_MAX_SIZE, attachmentMaxSize);
}
boolean embeddedAttachment = mc.get("org.apache.cxf.multipart.embedded") != null;
String propertyName = embeddedAttachment ? MultipartBody.INBOUND_MESSAGE_ATTACHMENTS + ".embedded" : MultipartBody.INBOUND_MESSAGE_ATTACHMENTS;
MultipartBody body = (MultipartBody) mc.get(propertyName);
if (!embeddedAttachment && mc.get(IN_FILTERS) != null) {
List<MultipartInputFilter> filters = CastUtils.cast((List<?>) mc.get(IN_FILTERS));
for (MultipartInputFilter filter : filters) {
filter.filter(body.getAllAttachments());
}
}
return body;
}
Aggregations