diff --git a/trunk/workflow-manager/src/main/java/org/mitre/mpf/mvc/CustomJacksonHttpMessageConverter.java b/trunk/workflow-manager/src/main/java/org/mitre/mpf/mvc/CustomJacksonHttpMessageConverter.java index 17f423165..b0643297c 100644 --- a/trunk/workflow-manager/src/main/java/org/mitre/mpf/mvc/CustomJacksonHttpMessageConverter.java +++ b/trunk/workflow-manager/src/main/java/org/mitre/mpf/mvc/CustomJacksonHttpMessageConverter.java @@ -43,7 +43,8 @@ public class CustomJacksonHttpMessageConverter extends MappingJackson2HttpMessageConverter { // These classes should use the internal Spring HttpMessageConverters. - private static final ImmutableList> BLACKLIST = ImmutableList.of(String.class, Resource.class); + private static final ImmutableList> DENY_LIST + = ImmutableList.of(String.class, Resource.class); @Inject CustomJacksonHttpMessageConverter(ObjectMapper objectMapper) { @@ -53,7 +54,7 @@ public class CustomJacksonHttpMessageConverter extends MappingJackson2HttpMessag @Override public boolean canWrite(Class clazz, MediaType mediaType) { - return BLACKLIST.stream().noneMatch(blc -> blc.isAssignableFrom(clazz)) + return DENY_LIST.stream().noneMatch(blc -> blc.isAssignableFrom(clazz)) && super.canWrite(clazz, mediaType); } } diff --git a/trunk/workflow-manager/src/main/java/org/mitre/mpf/wfm/util/MediaTypeUtils.java b/trunk/workflow-manager/src/main/java/org/mitre/mpf/wfm/util/MediaTypeUtils.java index 20453e643..a8941c416 100644 --- a/trunk/workflow-manager/src/main/java/org/mitre/mpf/wfm/util/MediaTypeUtils.java +++ b/trunk/workflow-manager/src/main/java/org/mitre/mpf/wfm/util/MediaTypeUtils.java @@ -46,7 +46,7 @@ public class MediaTypeUtils { private static final Logger LOG = LoggerFactory.getLogger(MediaTypeUtils.class); - private final PropertiesConfiguration _whiteListPropertiesConfig; + private final PropertiesConfiguration _mediaTypePropertiesConfig; @Inject public MediaTypeUtils(PropertiesUtil propertiesUtil) throws ConfigurationException { @@ -57,33 +57,32 @@ public MediaTypeUtils(PropertiesUtil propertiesUtil) throws ConfigurationExcepti .setListDelimiterHandler(new DefaultListDelimiterHandler(',')); var builder = new FileBasedConfigurationBuilder<>(PropertiesConfiguration.class); - _whiteListPropertiesConfig = builder + _mediaTypePropertiesConfig = builder .configure(configBuilderParameters) .getConfiguration(); } /** - * Uses the media mimeType and any whitelisted properties to determine how to process - * a piece of media. + * Uses the media mimeType and media type properties file to determine how to process a piece + * of media. * * @param mimeType The mime-type of the media. * @return The MediaType to treat the media as. */ public MediaType parse(String mimeType) { - var whiteListKey = "whitelist." + mimeType; - var typeFromWhitelist = _whiteListPropertiesConfig.getString(whiteListKey); - if (typeFromWhitelist != null && !typeFromWhitelist.isBlank()) { - var trimmedUpper = typeFromWhitelist.strip().toUpperCase(); + var mediaType = _mediaTypePropertiesConfig.getString(mimeType); + if (mediaType != null && !mediaType.isBlank()) { + var trimmedUpper = mediaType.strip().toUpperCase(); try { return MediaType.valueOf(trimmedUpper); } catch (IllegalArgumentException e) { LOG.error( - "The \"{}\" property from the media type white list file contained the invalid value of \"{}\".", - whiteListKey, typeFromWhitelist); + "The \"{}\" property from the media types file contained the invalid value of \"{}\".", + mimeType, mediaType); + } } - return Stream.of(MediaType.values()) .filter(mt -> StringUtils.startsWithIgnoreCase(mimeType, mt.toString())) .findAny() diff --git a/trunk/workflow-manager/src/main/resources/properties/mediaType.properties b/trunk/workflow-manager/src/main/resources/properties/mediaType.properties index f4a6740cd..ed703e20b 100644 --- a/trunk/workflow-manager/src/main/resources/properties/mediaType.properties +++ b/trunk/workflow-manager/src/main/resources/properties/mediaType.properties @@ -24,16 +24,14 @@ # limitations under the License. # ############################################################################# -####################### -# FILE TYPE WHITELIST # -####################### - -# Properties should be defined in the format "whitelist.", and values should be -# in the set of {VIDEO, IMAGE, AUDIO} -# Adding whitelisted types inappropriately may cause components to crash. Please add or +########################### +# FILE TYPE CONFIGURATION # +########################### +# Property keys should be mime types and values should be in the set of {VIDEO, IMAGE, AUDIO}. +# Adding mime type mappings inappropriately may cause components to crash. Please add or # change values with caution. -# for .gz you need both whitelist.binary/octet-stream and whitelist.application/gzip -whitelist.application/x-matroska=VIDEO -whitelist.application/x-vnd.rn-realmedia=VIDEO -whitelist.application/mp4=VIDEO -whitelist.image/gif=VIDEO \ No newline at end of file +# For .gz you need both binary/octet-stream and application/gzip. +application/x-matroska=VIDEO +application/x-vnd.rn-realmedia=VIDEO +application/mp4=VIDEO +image/gif=VIDEO