public boolean isAuthorized(final String uri) { return authorizedResources.contains(WroUtil.removeQueryString(uri)); }
public boolean isAuthorized(final String uri) { return authorizedResources.contains(WroUtil.removeQueryString(uri)); }
public void add(final String uri) { notNull(uri); LOG.debug("authorize: {}", uri); //ignore query string added to authorized resources list. authorizedResources.add(WroUtil.removeQueryString(uri)); }
public void add(final String uri) { notNull(uri); LOG.debug("authorize: {}", uri); //ignore query string added to authorized resources list. authorizedResources.add(WroUtil.removeQueryString(uri)); }
@Override public boolean isAuthorized(final String uri) { for (final String pattern : patterns) { if (matcher.match(pattern, WroUtil.removeQueryString(uri))) { return true; } } return false; }
@Override public boolean isAuthorized(final String uri) { for (final String pattern : patterns) { if (matcher.match(pattern, WroUtil.removeQueryString(uri))) { return true; } } return false; }
/** * Returns a valid HTTP contentType's for a given filename. It first relies on the custom defaultContentTypeMap and if * not found it will fall back to defaultFileTypeMap from javax.activation.FileTypeMap. Examples: - "somefile.css" * resolves to "text/css". - "somefile.js.png" resolves to "image/png" - "/blah/index.html resolves to "text/html". * <p/> * The implementation uses reflection to load <code>javax.activation.FileTypeMap</code> class (available in jdk6) in * order to be compatible with jdk5. If this class is not available, the default content type is returned. * * @param fileName * with an filename extension * @return contentType */ public static String get(final String fileName) { final String extension = FilenameUtils.getExtension(WroUtil.removeQueryString(fileName.toLowerCase())); if (defaultContentTypeMap.containsKey(extension)) { return defaultContentTypeMap.get(extension); } try { final Class<?> fileTypeMapClass = ClassLoader.getSystemClassLoader().loadClass("javax.activation.FileTypeMap"); LOG.debug("using {} to resolve contentType", fileTypeMapClass.getName()); final Object fileTypeMap = fileTypeMapClass.getMethod("getDefaultFileTypeMap").invoke(fileTypeMapClass); return (String) fileTypeMapClass.getMethod("getContentType", String.class).invoke(fileTypeMap, fileName); } catch (final Exception e) { LOG.debug("FileTypeMap is not available (probably jdk5 is used). Exception {}, with message: {}", e.getClass(), e.getMessage()); LOG.debug("Will use default content type: {} for fileName: {}", DEFAULT_CONTENT_TYPE, fileName); } return DEFAULT_CONTENT_TYPE; }