public Object getData() { if (data == null && dataString != null) { data = ResourceUtils.decodeBytesData(dataString); } return data; } }
private static String getResourcePathFromRequest(FacesContext context) { String resourceName = ResourceUtils.decodeResourceURL(context); if (resourceName != null) { if (resourceName.startsWith(RICHFACES_RESOURCE_IDENTIFIER)) { return resourceName.substring(RICHFACES_RESOURCE_IDENTIFIER.length()); } else { return null; } } else { LOGGER.warn("Resource key not found" + resourceName); return null; } }
public static byte[] decodeBytesData(String encodedData) { byte[] objectArray = null; try { byte[] dataArray = encodedData.getBytes("ISO-8859-1"); objectArray = decrypt(dataArray); } catch (UnsupportedEncodingException e1) { // default encoding always presented. } return objectArray; }
formattedExpireDate = ResourceUtils.formatHttpDate(currentTime + secondToMillis(maxAge)); } else { Date expired = getExpires(facesContext); formattedExpireDate = ResourceUtils.formatHttpDate(expired); maxAge = millisToSecond(expired.getTime() - currentTime); } else { maxAge = getLongConfigurationValue(facesContext, CoreConfiguration.Items.resourcesTTL); formattedExpireDate = ResourceUtils.formatHttpDate(currentTime + secondToMillis(maxAge));
char c = s.charAt(idx); if (!isLegalURIQueryChar(c)) { builder.append(s.substring(start, idx)); for (int i = 0; i < limit; i++) { int b = (0xFF & byteBuffer.get()); builder.append(escapeURIByte(b));
private static ByteBuffer readContent(InputStream is) throws IOException { if (is == null) { throw new NullPointerException("Resource input stream is null"); } FastBufferOutputStream os = new FastBufferOutputStream(); try { ResourceUtils.copyStreamContent(is, os); } finally { try { is.close(); } catch (IOException e) { if (LOGGER.isDebugEnabled()) { LOGGER.debug(e.getMessage(), e); } } try { os.close(); } catch (IOException e) { if (LOGGER.isDebugEnabled()) { LOGGER.debug(e.getMessage(), e); } } } ByteBuffer buffer = os.getFirstBuffer(); buffer.compact(); return buffer; }
public String encodeJSFMapping(FacesContext context, String resourcePath) { return ResourceUtils.encodeJSFURL(context, resourcePath); }
public String encodeResourceRequestPath(FacesContext context, String libraryName, String resourceName, Object resourceData, String resourceVersion) { String encodedDataString = null; if (resourceData != null) { encodedDataString = ResourceUtils.encodeBytesData((byte[]) resourceData); } return ResourceHandlerImpl.RICHFACES_RESOURCE_IDENTIFIER + encodeResource(libraryName, resourceName, encodedDataString, resourceVersion); }
public static String encodeBytesData(byte[] data) { if (data != null) { try { byte[] dataArray = encrypt(data); return new String(dataArray, "ISO-8859-1"); } catch (Exception e) { RESOURCE_LOGGER.error(Messages.getMessage(Messages.QUERY_STRING_BUILDING_ERROR), e); } } return null; }
sb.append(ResourceUtils.encodeURIQueryPart(resourceVersion)); sb.append(ResourceUtils.encodeURIQueryPart(encodedResourceData)); sb.append(ResourceUtils.encodeURIQueryPart(libraryName));
@Override public Map<String, String> getResponseHeaders() { Map<String, String> headers = new HashMap<String, String>(); FacesContext facesContext = FacesContext.getCurrentInstance(); if (isResourceRequest()) { int contentLength = getContentLength(facesContext); if (contentLength >= 0) { headers.put("Content-Length", String.valueOf(contentLength)); } String contentType = getContentType(); if (contentType != null) { headers.put("Content-Type", contentType); } Date lastModified = getLastModified(facesContext); if (lastModified != null) { headers.put("Last-Modified", ResourceUtils.formatHttpDate(lastModified)); } headers.put("Date", ResourceUtils.formatHttpDate(getCurrentTime())); addCacheControlResponseHeaders(facesContext, headers); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Created set of response headers"); // TODO - security - can we log header values? for (Entry<String, String> entry : headers.entrySet()) { LOGGER.debug(MessageFormat.format("\t{0}={1}", entry.getKey(), entry.getValue())); } } } return headers; }
ResourceUtils.copyStreamContent(is, os); } finally { if (is != null) {