Search in sources :

Example 1 with MultipartInputFilter

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);
    }
}
Also used : MultipartInputFilter(org.apache.cxf.jaxrs.ext.multipart.MultipartInputFilter) Message(org.apache.cxf.message.Message)

Example 2 with MultipartInputFilter

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);
}
Also used : MultipartInputFilter(org.apache.cxf.jaxrs.ext.multipart.MultipartInputFilter) Message(org.apache.cxf.message.Message)

Example 3 with MultipartInputFilter

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;
}
Also used : MultipartInputFilter(org.apache.cxf.jaxrs.ext.multipart.MultipartInputFilter) MultipartBody(org.apache.cxf.jaxrs.ext.multipart.MultipartBody)

Aggregations

MultipartInputFilter (org.apache.cxf.jaxrs.ext.multipart.MultipartInputFilter)3 Message (org.apache.cxf.message.Message)2 MultipartBody (org.apache.cxf.jaxrs.ext.multipart.MultipartBody)1