Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jasig.portal.serialize
Class ProxyWriter

    java.lang.Object
      org.jasig.portal.serialize.ProxyWriter

    public class ProxyWriter

extends java.lang.Object

This Class allows appending PROXY_REWRITE_PREFIX String in front of all the references to images, javascript files, etc.. that are on a remote location. This allows the browser while portal is running in https assume that these resources are secure resources(are referenced by https rather than http). This is because the resource URI insteadof http://www.abc.com/image.gif will be rewriten as as https://[portal address]/PROXY_REWRITE_PREFIX/www.abc.com/image.gif This class does the proxy rewrite in the following exceptional situations as well: 1. If the return code poting to the image is 3XX (the image refrence, refrences is a mapping to a diffrent location) In this case the final destination iddress n which the image or the resource is located is e and then the rewrite points to this location. 2. If the content of a channel is an include javascript file the file is rewriten to a location on a local virtual host and at the same time the image or other resources references are rewritten.

Since:
  uPortal 2.2
Version:
  $Revision: 1.11.4.1 $
Author:
  Kazem Naderi

Field Summary
`private static java.lang.String[]` | `_proxiableElements` The list of elemnets which src attribute is rewritten with proxy.
`protected boolean` | `_proxying` True if allow rewriting certain elements for proxying.
`private static org.apache.commons.logging.Log` | `log`
`private static java.lang.String` | `PROXIED_FILES_PATH`
`private static java.lang.String` | `PROXIED_FILES_URI`
`private static boolean` | `PROXY_ENABLED`
`private static java.lang.String` | `PROXY_REWRITE_NO_REDIRECT_DOMAIN`
`private static java.lang.String` | `PROXY_REWRITE_PREFIX`

Constructor Summary
`ProxyWriter()`

Method Summary
`private static java.lang.String` | `capture3XXCodes(java.lang.String value)` Capture 3xx return codes - specifically, if 301/302, then go tp the redirected url - note, this in turn may also be redirected.
`protected static java.lang.String` | `considerProxyRewrite(java.lang.String name, java.lang.String localName, java.lang.String value)` Examines whther or not the proxying should be done and if so handles differnt situations by delegating the rewrite to other methods n the class.
`private static java.lang.String` | `createProxyURL(java.lang.String srcValue)` This method receives an image source URL and modified it to be proxied.
`private static java.lang.String` | `extractURL(java.lang.String line)` This method takes a String (line) and parses out the value of src attribute in that string.
`private static java.lang.String` | `fileNameGenerator(java.lang.String addr)` This method uses a URI and creates an html file name by simply omiting some characters from the URI.
`private static java.lang.String` | `processLine(java.lang.String line)` This method parses a line recursivley and replaces all occurances of image references with a proxied reference.
`private static java.lang.String` | `reWrite(java.lang.String scriptUri)` This method rewrites include javascript files and replaces the refrences in these files to images' sources to use proxy.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### log

    private static final org.apache.commons.logging.Log log

### _proxying

    protected boolean _proxying

  True if allow rewriting certain elements for proxying.

### _proxiableElements

    private static final java.lang.String[] _proxiableElements

  The list of elemnets which src attribute is rewritten with proxy.

### PROXY_ENABLED

    private static boolean PROXY_ENABLED

### PROXIED_FILES_URI

    private static java.lang.String PROXIED_FILES_URI

### PROXIED_FILES_PATH

    private static java.lang.String PROXIED_FILES_PATH

### PROXY_REWRITE_PREFIX

    private static final java.lang.String PROXY_REWRITE_PREFIX

### PROXY_REWRITE_NO_REDIRECT_DOMAIN

    private static final java.lang.String PROXY_REWRITE_NO_REDIRECT_DOMAIN

Constructor Detail

### ProxyWriter

    public ProxyWriter()

Method Detail

### considerProxyRewrite

    protected static java.lang.String considerProxyRewrite(java.lang.String name,
                                                           java.lang.String localName,
                                                           java.lang.String value)

  Examines whther or not the proxying should be done and if so handles differnt situations by delegating the rewrite to other methods n the class.

  Parameters:
    `name` -
    `localName` -
    `value` -
  Returns:
    value

### capture3XXCodes

    private static java.lang.String capture3XXCodes(java.lang.String value)

  Capture 3xx return codes - specifically, if 301/302, then go tp the redirected url - note, this in turn may also be redirected. Note - do as little network connecting as possible. So as a start, assume "ubc.ca" domain images will not be redirected so skip these ones.

  Parameters:
    `value` -
  Returns:
    value

### reWrite

    private static java.lang.String reWrite(java.lang.String scriptUri)

  This method rewrites include javascript files and replaces the refrences in these files to images' sources to use proxy.

  Parameters:
    `scriptUri:` - The string representing the address of script
  Returns:
    value: The new address of the script file which image sources have been rewritten

### fileNameGenerator

    private static java.lang.String fileNameGenerator(java.lang.String addr)

  This method uses a URI and creates an html file name by simply omiting some characters from the URI. The purpose of using the address for the file name is that the file names will be unique and map to addresses.

  Parameters:
    `addr:` - is the address of the file

### processLine

    private static java.lang.String processLine(java.lang.String line)
                                         throws java.lang.Exception

  This method parses a line recursivley and replaces all occurances of image references with a proxied reference.

  Parameters:
    `line` - - is the portion of the line or the whole line to be processed.
  Returns:
    line - is the portion of the line or the line that has been processed.
  Throws:
    `java.lang.Exception`

### extractURL

    private static java.lang.String extractURL(java.lang.String line)

  This method takes a String (line) and parses out the value of src attribute in that string.

  Parameters:
    `line` - - String
  Returns:
    srcValue - String

### createProxyURL

    private static java.lang.String createProxyURL(java.lang.String srcValue)

  This method receives an image source URL and modified it to be proxied.

  Parameters:
    `srcValue` - - String
  Returns:
    srcNewValue - String

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD