public class

MimeSniffingKit

extends Object
java.lang.Object
   ↳ com.atlassian.jira.web.servlet.MimeSniffingKit

Class Overview

This class can sniff a file according to the current JIRA settings and determine how an attachment should be handled

Summary

Constants
String CONTENT_DISPOSITION_ATTACHMENT
String CONTENT_DISPOSITION_INLINE
Public Constructors
MimeSniffingKit(ApplicationProperties applicationProperties, HostileExtensionDetector hostileExtensionDetector)
Public Methods
void setAttachmentResponseHeaders(Attachment attachment, String userAgent, HttpServletResponse httpServletResponse)
Sets the appropriate HTTP response headers on an attachment download response.
void setAttachmentResponseHeaders(String fileName, String mimeContentType, HttpServletResponse httpServletResponse)
Sets the appropriate HTTP response headers on an attachment download response.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String CONTENT_DISPOSITION_ATTACHMENT

Constant Value: "attachment"

public static final String CONTENT_DISPOSITION_INLINE

Constant Value: "inline"

Public Constructors

public MimeSniffingKit (ApplicationProperties applicationProperties, HostileExtensionDetector hostileExtensionDetector)

Public Methods

public void setAttachmentResponseHeaders (Attachment attachment, String userAgent, HttpServletResponse httpServletResponse)

Sets the appropriate HTTP response headers on an attachment download response. Depending on the JIRA security settings and the browser making the request, this can contain headers such as Content-Disposition and X-Download-Options to force downloading rather than opening attachments.

Parameters
attachment the Attachment in play
userAgent the User-agent request header
httpServletResponse the attachment download response
Throws
IOException if stuff goes wrong

public void setAttachmentResponseHeaders (String fileName, String mimeContentType, HttpServletResponse httpServletResponse)

Sets the appropriate HTTP response headers on an attachment download response. Depending on the JIRA security settings and the browser making the request, this can contain headers such as Content-Disposition and X-Download-Options to force downloading rather than opening attachments.

Parameters
fileName the name of the file
mimeContentType the content-type of the file
httpServletResponse the attachment download response
Throws
IOException if stuff goes wrong