org.apache.jetspeed.services.webpage
Class JetspeedSiteSession

java.lang.Object
  extended byorg.apache.jetspeed.services.webpage.AbstractSiteSession
      extended byorg.apache.jetspeed.services.webpage.JetspeedSiteSession
All Implemented Interfaces:
SiteSession

public class JetspeedSiteSession
extends AbstractSiteSession

Represents a session with a site

This class extends AbstractSiteSession, implementing the specific code login and logout to a site. The content rewriter is also specialized here to handle the specific needs

Sessions are stored in the SessionMap per Jetspeed Session. (The SessionMap is stored in the Servlet Session)


Field Summary
 
Fields inherited from class org.apache.jetspeed.services.webpage.AbstractSiteSession
cacheCount, cookies, hitCount, proxyBase, targetBase
 
Constructor Summary
JetspeedSiteSession(Site site, java.lang.String proxyBase, java.lang.String userName)
          Create a session, which maintains sessions with one website.
 
Method Summary
 void drainContent(java.net.URLConnection con, javax.servlet.http.HttpServletResponse response)
          Retrieves the content from the URL Connection stream and writes it to servlet response
 java.lang.String getContentAsString(java.net.URLConnection con, ProxyRunData data, java.lang.String url)
          Gets the HTML content from the URL Connection stream and returns it as a Stream
 Site getSite()
          Gets the network element object associated with this session.
 java.lang.String getUserName()
          Gets the user name who owns this session.
 boolean logon(ProxyRunData data)
          Logs on to the Secured site 'automatically', using a predefined exchange based on a logon-screen POST to the site, sending the logon credentials and security permissions.
 boolean logout(ProxyRunData data)
          Logs out to the Network Element by sending the session id cookie to a pre-defined logout-URL in the Network Element.
 void proxy(java.lang.String site, ProxyRunData data)
          Given a site URL, proxies the content of that site.
 void rewriteContent(ProxyRunData data, java.net.URLConnection con, int contentType, java.lang.String url)
          Reads stream from proxied host, runs HTML parser against that stream, rewriting relevant links, and writes the parsed stream back to the client.
 
Methods inherited from class org.apache.jetspeed.services.webpage.AbstractSiteSession
addCookieToSession, dispatch, getBinaryContent, getCacheCount, getHitCount, getHTMLContent, incCacheCount, incHitCount
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JetspeedSiteSession

public JetspeedSiteSession(Site site,
                           java.lang.String proxyBase,
                           java.lang.String userName)
Create a session, which maintains sessions with one website.

Parameters:
site - the site to manage.
proxyBase - the proxy server host URL base address.
Method Detail

logon

public boolean logon(ProxyRunData data)
              throws java.io.IOException
Logs on to the Secured site 'automatically', using a predefined exchange based on a logon-screen POST to the site, sending the logon credentials and security permissions.

Parameters:
data - the request specific rundata.
Throws:
java.io.IOException - a servlet exception.

rewriteContent

public void rewriteContent(ProxyRunData data,
                           java.net.URLConnection con,
                           int contentType,
                           java.lang.String url)
                    throws java.io.IOException
Reads stream from proxied host, runs HTML parser against that stream, rewriting relevant links, and writes the parsed stream back to the client.

Parameters:
con - the URLConnection with proxied host.
contentType - the contentType of the request.
Throws:
java.io.IOException - a servlet exception.

drainContent

public void drainContent(java.net.URLConnection con,
                         javax.servlet.http.HttpServletResponse response)
                  throws java.io.IOException
Retrieves the content from the URL Connection stream and writes it to servlet response

Parameters:
con - The URLConnection to read from.
Throws:
java.io.IOException - a servlet exception.

getContentAsString

public java.lang.String getContentAsString(java.net.URLConnection con,
                                           ProxyRunData data,
                                           java.lang.String url)
                                    throws java.io.IOException
Gets the HTML content from the URL Connection stream and returns it as a Stream

Parameters:
con - The URLConnection to read from.
data - the request specific rundata.
Returns:
The HTML Content from the stream.
Throws:
java.io.IOException - a servlet exception.

getSite

public Site getSite()
Gets the network element object associated with this session.

Returns:
A network element object for this session.

getUserName

public java.lang.String getUserName()
Gets the user name who owns this session.

Returns:
The string value of the user name.

logout

public boolean logout(ProxyRunData data)
               throws java.io.IOException
Logs out to the Network Element by sending the session id cookie to a pre-defined logout-URL in the Network Element. The logout-URL is defined in the proxy configuration. We communicate with a specific MNE logout resource form via HTTP GET.

Parameters:
data - the request specific rundata.
Throws:
java.io.IOException - a servlet exception.

proxy

public void proxy(java.lang.String site,
                  ProxyRunData data)
           throws java.io.IOException
Description copied from interface: SiteSession
Given a site URL, proxies the content of that site. The actual rules on rewriting the proxied resource are dependent on implementation and configuration parameters. For example, all HTTP hyperlinks(HREFs) could be rewritten as proxied hyperlinks back to this Proxy. Or all relative references to web resources (images, stylesheets, ...) could be rewritten as absolute references, but are not proxied.

Parameters:
site - the proxied resource address.
data - the request specific rundata.
Throws:
java.io.IOException - a servlet exception.


Copyright © 2000-2005 Apache Software Foundation. All Rights Reserved.