atg.projects.store.servlet.pipeline
Class ProtocolSwitchServlet

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.nucleus.TimedOperationService
              extended by atg.servlet.pipeline.PipelineableServletImpl
                  extended by atg.servlet.pipeline.InsertableServletImpl
                      extended by atg.projects.store.servlet.pipeline.ProtocolSwitchServlet
All Implemented Interfaces:
atg.naming.NameContextBindingListener, atg.naming.NameContextElement, atg.naming.NameResolver, atg.nucleus.AdminableService, atg.nucleus.logging.ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, atg.nucleus.logging.VariableArgumentApplicationLogging, atg.nucleus.naming.ComponentNameResolver, atg.nucleus.Service, atg.nucleus.ServiceListener, atg.servlet.pipeline.InsertableServlet, atg.servlet.pipeline.PipelineableServlet, java.util.EventListener, javax.servlet.Servlet

public class ProtocolSwitchServlet
extends atg.servlet.pipeline.InsertableServletImpl

This pipeline servlet performs switching between a secure sever and a non-secure server. A list of secure paths and the enable property controls the switching. The servlet is configured with a list of URL mappings; if the URL being accessed is in the URL mapping, the request is passed off to the secure server. The nonSecureHostName and secureHostname are default taken from atg/dynamo/Configuration. These can be overwridden at the component level.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string.
protected  boolean mEnabled
          Enabled property.
protected  java.lang.String mHostName
          Host name.
protected  int mHttpPort
          Http port.
protected  int mHttpsPort
          Https port.
protected  java.lang.String[] mIgnoreList
          List of paths to ignore.
protected  java.lang.String mSecureHostName
          Secure host name.
protected  java.lang.String[] mSecureList
          List of secure paths to protect.
static java.lang.String NONSECURE_PROTOCOL
          Nonsecure protocol constant.
static java.lang.String SECURE_PROTOCOL
          Secure protocol constant.
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
ProtocolSwitchServlet()
           
 
Method Summary
 void doStartService()
          Called after the service has been created, placed into the naming hierarchy, and initialized with its configured property values.
 java.lang.String getHostName()
           
 int getHttpPort()
           
 int getHttpsPort()
           
 java.lang.String[] getIgnoreList()
           
protected  java.lang.String getNonSecureUrl(java.lang.String pUrl)
          Build a nonSecure url.
 java.lang.String getSecureHostName()
           
 java.lang.String[] getSecureList()
           
protected  java.lang.String getSecureUrl(java.lang.String pUrl)
          Build a Secure url.
protected  boolean isCurrentPathInIgnoreList(java.lang.String pPath)
          Method used check if the requested URI is part of the ignored list.
protected  boolean isCurrentPathInSecureList(java.lang.String pPath)
          Method used check if the requested URI is part of the secure list.
 boolean isEnabled()
           
 void service(atg.servlet.DynamoHttpServletRequest pRequest, atg.servlet.DynamoHttpServletResponse pResponse)
          Called in the pipeline when a request needs to be processed.
 void setEnabled(boolean pEnabled)
           
 void setHostName(java.lang.String pHostName)
           
 void setHttpPort(int pHttpPort)
           
 void setHttpsPort(int pHttpsPort)
           
 void setIgnoreList(java.lang.String[] pIgnoreList)
           
 void setSecureHostName(java.lang.String pSecureHostName)
           
 void setSecureList(java.lang.String[] pSecureList)
          Set the secure list.
 
Methods inherited from class atg.servlet.pipeline.InsertableServletImpl
getInsertAfterServlet, setInsertAfterServlet
 
Methods inherited from class atg.servlet.pipeline.PipelineableServletImpl
createAdminServlet, destroy, getAdminServlet, getNextServlet, getServletConfig, getServletInfo, init, isUsePathInfo, passRequest, passRequest, service, service, setNextServlet, setServletInfo, setUsePathInfo
 
Methods inherited from class atg.nucleus.TimedOperationService
getAverageRequestHandlingTime, getHandledRequestCount, getRequestStartTime, getTotalRequestHandlingTime, isKeepingStatistics, notifyHandledRequest, resetStatistics, setKeepingStatistics
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, doStopService, getAbsoluteName, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface atg.servlet.pipeline.PipelineableServlet
getNextServlet, passRequest, setNextServlet
 
Methods inherited from interface javax.servlet.Servlet
destroy, getServletConfig, getServletInfo, init, service
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string.


SECURE_PROTOCOL

public static final java.lang.String SECURE_PROTOCOL
Secure protocol constant.

See Also:
Constant Field Values

NONSECURE_PROTOCOL

public static final java.lang.String NONSECURE_PROTOCOL
Nonsecure protocol constant.

See Also:
Constant Field Values

mSecureList

protected java.lang.String[] mSecureList
List of secure paths to protect.


mIgnoreList

protected java.lang.String[] mIgnoreList
List of paths to ignore.


mHostName

protected java.lang.String mHostName
Host name.


mHttpPort

protected int mHttpPort
Http port.


mHttpsPort

protected int mHttpsPort
Https port.


mSecureHostName

protected java.lang.String mSecureHostName
Secure host name.


mEnabled

protected boolean mEnabled
Enabled property.

Constructor Detail

ProtocolSwitchServlet

public ProtocolSwitchServlet()
Method Detail

getIgnoreList

public java.lang.String[] getIgnoreList()
Returns:
the ignore list.

setIgnoreList

public void setIgnoreList(java.lang.String[] pIgnoreList)
Parameters:
pIgnoreList - - the ignore list to set.

getSecureHostName

public java.lang.String getSecureHostName()
Returns:
secure host name.

setSecureHostName

public void setSecureHostName(java.lang.String pSecureHostName)
Parameters:
pSecureHostName - - secure host name.

getHttpsPort

public int getHttpsPort()
Returns:
https port.

setHttpsPort

public void setHttpsPort(int pHttpsPort)
Parameters:
pHttpsPort - - https port.

getHttpPort

public int getHttpPort()
Returns:
http port.

setHttpPort

public void setHttpPort(int pHttpPort)
Parameters:
pHttpPort - - http port.

getHostName

public java.lang.String getHostName()
Returns:
host name.

setHostName

public void setHostName(java.lang.String pHostName)
Parameters:
pHostName - - host name.

setSecureList

public void setSecureList(java.lang.String[] pSecureList)
Set the secure list. This should normally be a directory, but can be the prefix to any portion of a url.

Parameters:
pSecureList - - array of protected urls

getSecureList

public java.lang.String[] getSecureList()
Returns:
list of pages that should be rendered by the secure server.

isEnabled

public boolean isEnabled()
Returns:
the enabled status.

setEnabled

public void setEnabled(boolean pEnabled)
Parameters:
pEnabled - - the enabled status to set.

service

public void service(atg.servlet.DynamoHttpServletRequest pRequest,
                    atg.servlet.DynamoHttpServletResponse pResponse)
             throws java.io.IOException,
                    javax.servlet.ServletException
Called in the pipeline when a request needs to be processed. The following conditions cause the request to be passed off to the next servlet in the pipeline:
  • If a protocol switch is not required Otherwise, a call is made to ProtocolSwitchURLGenerator to generate a URL for the protocol to be switched to by checking if the requested URI is in the secure list.

    Overrides:
    service in class atg.servlet.pipeline.PipelineableServletImpl
    Parameters:
    pRequest - The servlet's request
    pResponse - The servlet's response
    Throws:
    javax.servlet.ServletException - if an error occurred while processing the servlet request
    java.io.IOException - if an error occurred while reading or writing the servlet request

  • isCurrentPathInSecureList

    protected boolean isCurrentPathInSecureList(java.lang.String pPath)
    Method used check if the requested URI is part of the secure list. We assume that the secure list contains paths with the context root if needed. This allows us to protect servlets that aren't under the context root as well.

    Parameters:
    pPath - The requested URI without query parameters
    Returns:
    true if the requested URI is in the secure list, false otherwise.

    isCurrentPathInIgnoreList

    protected boolean isCurrentPathInIgnoreList(java.lang.String pPath)
    Method used check if the requested URI is part of the ignored list. We assume that the ignored list contains paths with the context root if needed. This allows us to protect servlets that aren't under the context root as well.

    Parameters:
    pPath - The requested URI without query parameters
    Returns:
    true if the requested URI is in the secure list, false otherwise.

    getNonSecureUrl

    protected java.lang.String getNonSecureUrl(java.lang.String pUrl)
    Build a nonSecure url. If passed /cmo/user/foo/, this will create http://localhost:8840/cmo/user/foo/ (if localhost is the configured hostname)

    Parameters:
    pUrl - - url to build full url for
    Returns:
    nonsecure URL

    getSecureUrl

    protected java.lang.String getSecureUrl(java.lang.String pUrl)
    Build a Secure url. If passed /cmo/user/foo/, this will create https://localhost:8843/cmo/user/foo/ (if localhost is the configured hostname)

    Parameters:
    pUrl - - url to build full url for
    Returns:
    secure URL

    doStartService

    public void doStartService()
                        throws atg.nucleus.ServiceException
    Called after the service has been created, placed into the naming hierarchy, and initialized with its configured property values. Makes sure all the required properties have been set in the .properties file.

    Overrides:
    doStartService in class atg.servlet.pipeline.InsertableServletImpl
    Throws:
    atg.nucleus.ServiceException - if the service had a problem starting up