org.sandev.tools.UIProcessor
Class XHTMLSandUIServlet

java.lang.Object
  extended byjavax.servlet.GenericServlet
      extended byjavax.servlet.http.HttpServlet
          extended byorg.sandev.tools.UIProcessor.XHTMLSandUIServlet
All Implemented Interfaces:
GeneratedServletInterface, org.sandev.ui.util.SandUIAdaptor, java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig, org.sandev.ui.util.TemplateReader

public class XHTMLSandUIServlet
extends javax.servlet.http.HttpServlet
implements GeneratedServletInterface, org.sandev.ui.util.SandUIAdaptor, org.sandev.ui.util.TemplateReader

An XHTML servlet UI for processing a SandUI. XHTMLSandUIServlet is an XHTML servlet implementation of SandUIAdaptor that calls through to a local UIFormOwner node for processing.

The XHTMLSandUIServlet is initialized with:

  1. The SandUI definition. Either as XML saved from the UIEditor, or as an instance set directly.
  2. A UIFormOwner. Either as the name of a locally accessible node implementing UIFormOwner, or as an instance set directly.
  3. A SingletonAccessor. If not specified then the default is used.

Processing makes use of the XHTMLScreenAdaptor.

See Also:
Serialized Form

Field Summary
static java.lang.String AUTHPARAM
          The name of the session variable that holds the uniqueID of the user after they have logged in.
protected  java.lang.String charSerializerClassName
          This is the fully qualified class name of the CharSerializer we should use to read from sandUIFileName.
protected  javax.servlet.http.HttpServlet controlServlet
          The original servlet for this request.
protected  org.sandev.basics.util.SandEncryptor encryptor
          Our encryptor is used for securing the values of the remember me cookie.
protected  boolean fixedMode
          If true, the security settings declared in the SandUI are ignored.
protected  java.lang.String forgotPasswordPrimary
          The first field to prompt with if the user forgot their password.
protected  java.lang.String forgotPasswordSecondary
          the second field to prompt with if the user forgot their password.
protected  org.sandev.basics.util.UIFormManager formManager
          Our manager handles basic form context actions.
protected  org.sandev.basics.util.UIFormOwner formOwner
          The UIFormOwner instance we use for processing.
protected  java.lang.String localeOverrideCountry
          Override setting to hardcode the country this servlet will use regardless of incoming request Locale settings.
protected  java.lang.String localeOverrideLanguage
          Override setting to hardcode the language this servlet will use regardless of incoming request Locale settings.
protected  java.lang.String localeOverrideVariant
          Override setting to hardcode the variant this servlet will use regardless of incoming request Locale settings.
protected  boolean localLaunch
          Flag directing whether the servlet should launch the application nodes itself.
static java.lang.String LOGINFAIL
          The text for an invalid login message.
protected  java.lang.String nodeInstanceFactoryClassName
          This is the fully qualified class name of the NodeInstanceFactory we use if we are launching the SandRoot directly.
protected  java.lang.String ownerNodeName
          The name of the local node instance implementing UIFormOwner.
protected  java.lang.String rememberMeCookieName
          The name of the "remember me" login cookie.
protected  java.lang.String rememberMePassphrase
          The passphrase used to encrypt the username:password when stored in a cookie.
protected  org.sandev.ui.util.SandTransformer sandTransformer
          The instance we use for transformation rendering.
protected  org.sandev.ui.sandmessages.SandUI sandUI
          The SandUI instance we are working with.
protected  java.lang.String sandUIFileName
          This is the name of the file holding the XML serialized form of the SandUI definition.
protected  java.lang.String sandUIXML
          The serialized SandUI definition.
protected  org.sandev.ui.util.UIScreenAdaptor screenAdaptor
          The instance we use for rendering/reconstruction.
protected  boolean setup
          Flag indicating whether we are set up to do work yet.
protected  org.sandev.basics.nodecommon.SingletonAccessor singletonAccessor
          The SingletonAccessor we will use to bridge from here to the application processing.
static java.lang.String TITLE
          The text we use for the title where needed.
protected  java.lang.String uiFormAdaptorClassName
          This is the fully qualified name of the UIFormAdaptor we should use for input and output.
 
Constructor Summary
XHTMLSandUIServlet()
          Default ctor does nothing, the SandUI XML and processing node instance name must be set separately.
 
Method Summary
protected  org.sandev.basics.util.AuthUser authenticate(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, java.util.Locale locale)
          Find out who this user is and return an instance for processing.
protected  org.sandev.basics.util.AuthUser authLogin(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, java.util.Locale locale)
          Display and process a login form.
protected  org.sandev.basics.util.AuthUser authLogout(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Clear the user login info so the default unauthenticated page processing is ready to go.
protected  org.sandev.basics.util.AuthUser authWelcome(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, java.util.Locale locale)
          Display the default unauthenticated user welcome page.
protected  org.sandev.basics.util.AuthUser confirmUser(org.sandev.basics.util.AuthUser user, org.sandev.ui.sandmessages.Screen screen, javax.servlet.http.HttpServletRequest req)
          Confirm that the given user is still the current user.
protected  void convertAndDisplay(java.lang.String formXHTML, javax.servlet.http.HttpServletResponse res, java.lang.String helpfile, org.sandev.ui.sandmessages.Screen screen, java.util.Locale locale)
          Take the output that was returned by XHTMLFormAdaptor and convert it according to the specified templates.
protected  void debugout(java.lang.String text)
          Shorthand debug output
 void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Pass HTTP 'GET' request over to handleRequest method.
 void doPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Pass HTTP 'POST' request over to handleRequest method.
protected  void doRequest(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, java.util.Locale locale)
          Workhorse for handleRequest.
protected  void dumpLoginForm(java.io.PrintWriter out)
          Helper method to dump the login form.
protected  void dumpOverviewInfo(java.io.PrintWriter out, java.util.Locale locale)
          Dump the header information like the deployment prefix and locale.
protected  void dumpStackTrace(java.io.PrintWriter out, java.lang.Throwable err, java.lang.String title)
          Dump a stack trace as HTML for the given throwable.
protected  void dumpUserLoginInfo(org.sandev.basics.util.UIRenderOutputString uiros, org.sandev.basics.util.AuthUser user, org.sandev.basics.util.AuthFilter filter, javax.servlet.http.HttpServletRequest req)
          Dump out information for the logged in user along with a logout link.
protected  void errorout(java.lang.Throwable err, javax.servlet.http.HttpServletResponse res, java.util.Locale locale)
          Display the exception using the standard output processing and the errorTemplate in the SandUI.
protected  void failout(java.lang.Throwable err, javax.servlet.http.HttpServletResponse res)
          Die nicely.
protected  org.sandev.basics.nodecommon.SandRoot findSandRoot()
          Locate the SandRoot or throw if it can't be found.
protected  org.sandev.basics.util.AuthUser forgotPassword(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, java.util.Locale locale)
          Display and process a forgot password request.
 java.lang.String getCharSerializerClassName()
          accessor for charSerializerClassName
 javax.servlet.http.HttpServlet getControlServlet()
          accessor for controlServlet
static java.lang.String getCoreError(java.lang.String errortext)
          This is a heuristic method that identifies some of the more common root error causes from the extensive error message that usually comes back from processing.
 org.sandev.basics.util.SandEncryptor getEncryptor()
          accessor for encryptor
 java.lang.String getForgotPasswordPrimary()
          accessor for forgotPasswordPrimary
 java.lang.String getForgotPasswordSecondary()
          accessor for forgotPasswordSecondary
 org.sandev.basics.util.UIFormManager getFormManager()
          accessor for formManager
 org.sandev.basics.util.UIFormOwner getFormOwner()
          accessor for formOwner
protected  org.sandev.basics.util.UIFormOwner getFormOwnerNode()
          Retrieve a reference to the specified node instance to serve as a UIFormOwner.
 java.lang.String getLocaleOverrideCountry()
          accessor for localeOverrideCountry
 java.lang.String getLocaleOverrideLanguage()
          accessor for localeOverrideLanguage
 java.lang.String getLocaleOverrideVariant()
          accessor for localeOverrideVariant
 java.lang.String getNodeInstanceFactoryClassName()
          accessor for nodeInstanceFactoryClassName
protected  java.lang.String getOutfileLinkURL(javax.servlet.http.HttpServletRequest req)
          Given a request, return the URL where we expect to find generated output files.
 java.lang.String getOwnerNodeName()
          accessor for ownerNodeName
 java.lang.String getRememberMeCookieName()
          accessor for rememberMeCookieName
 java.lang.String getRememberMePassphrase()
          accessor for rememberMePassphrase
 org.sandev.ui.util.SandTransformer getSandTransformer()
          accessor for sandTransformer
 org.sandev.ui.sandmessages.SandUI getSandUI()
          accessor for sandUI
 java.lang.String getSandUIFileName()
          accessor for sandUIFileName
 java.lang.String getSandUIXML()
          accessor for sandUIXML
 org.sandev.ui.util.UIScreenAdaptor getScreenAdaptor()
          accessor for screenAdaptor
 org.sandev.basics.nodecommon.SingletonAccessor getSingletonAccessor()
          accessor for singletonAccessor
 java.lang.String getUIFormAdaptorClassName()
          accessor for UIFormAdaptorClassName
protected  java.lang.String getUploadLinkURL(javax.servlet.http.HttpServletRequest req)
          Given a reqest, return the URL where we expect to find uploaded files.
protected  void handleRequest(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Use our SandUIProcessor to process the request.
 boolean inFixedMode()
          accessor for fixedMode
 void initEncryptor()
          initializer for encryptor
 void initFormManager()
          initializer for formManager
 void initSandTransformer()
          initializer for sandTransformer
 void initScreenAdaptor()
          Initialize our screenAdaptor
protected  java.lang.String insertPopUp(java.lang.String formXHTML, java.lang.String helpfile)
          Given some XHTML, modify it to create a pop up containing the given helpfile text.
 boolean isLocalLaunch()
          accessor for launchNodesFromServlet
protected  boolean isScreenSecured(org.sandev.ui.sandmessages.SandUI sandui, org.sandev.ui.sandmessages.Screen screen)
          Return true if this screen is secure, false otherwise.
 boolean isSetup()
          accessor for setup
 java.lang.String loadResource(java.lang.String rsrcname)
          Utility to load the contents of a servlet resource.
 boolean modeOk(javax.servlet.http.HttpServletRequest req, boolean secureMode)
          Return true if we are in the required mode, false otherwise.
protected  java.util.Locale negotiateLocale(java.util.Enumeration locales)
          Return a Locale taking into account any overrides, the SandUI constraints, the user's preferances, and the server environment.
protected  java.lang.String newURLSpecified(javax.servlet.http.HttpServletRequest req, org.sandev.ui.sandmessages.Screen screen)
          Walk the elements of the given screen to see if any of the contained UIFormContexts specify a new URL.
protected  org.sandev.ui.sandmessages.SandUI parseSandUI()
          Get the UI definition from the XML we were set up with.
protected  void processScreen(org.sandev.ui.sandmessages.Screen screen, javax.servlet.http.HttpServletRequest req, org.sandev.basics.util.UserWorkLog uwl)
          Process the screen.
 long readAuthParameters(long defaultAuthID, javax.servlet.http.HttpServletRequest req)
          Read the URL parameters for username password information and return the associated AuthUser uniqueID if found.
 long readRememberMeCookie(long defaultAuthID, javax.servlet.http.HttpServletRequest req)
          Read the cookie where we stored the authentication information and return the associated AuthUser uniqueID.
 java.lang.String readTemplate(java.lang.String templateName)
          Given a template name, return the contents.
 boolean rememberMeSupported()
          Returns true if "remember me" processing can be supported, false otherwise.
 java.lang.String rewriteURL(javax.servlet.http.HttpServletRequest req, boolean secureMode, java.lang.String params)
          Rewrite the current URL for the specified mode with the specified parameters.
 void setCharSerializerClassName(java.lang.String val)
          mutator for charSerializerClassName
 void setControlServlet(javax.servlet.http.HttpServlet val)
          mutator for controlServlet
 void setEncryptor(org.sandev.basics.util.SandEncryptor se)
          mutator for encryptor
 void setFixedMode(boolean val)
          mutator for fixedMode
 void setForgotPasswordPrimary(java.lang.String val)
          mutator for forgotPasswordPrimary
 void setForgotPasswordSecondary(java.lang.String val)
          mutator for forgotPasswordSecondary
 void setFormManager(org.sandev.basics.util.UIFormManager uifm)
          mutator for formManager
 void setFormOwner(org.sandev.basics.util.UIFormOwner owner)
          mutator for formOwner
 void setLocaleOverrideCountry(java.lang.String val)
          mutator for localeOverrideCountry
 void setLocaleOverrideLanguage(java.lang.String val)
          mutator for localeOverrideLanguage
 void setLocaleOverrideVariant(java.lang.String val)
          mutator for localeOverrideVariant
 void setLocalLaunch(boolean val)
          mutator for launchNodesFromServlet
 void setNodeInstanceFactoryClassName(java.lang.String val)
          mutator for nodeInstanceFactoryClassName
 void setOwnerNodeName(java.lang.String val)
          mutator for ownerNodeName
 void setRememberMeCookieName(java.lang.String val)
          mutator for rememberMeCookieName
 void setRememberMePassphrase(java.lang.String val)
          mutator for rememberMePassphrase
 void setSandTransformer(org.sandev.ui.util.SandTransformer trans)
          mutator for sandTransformer
 void setSandUI(org.sandev.ui.sandmessages.SandUI val)
          mutator for sandUI
 void setSandUIFileName(java.lang.String name)
          mutator for sandUIFileName
 void setSandUIXML(java.lang.String val)
          mutator for sandUIXML
 void setScreenAdaptor(org.sandev.ui.util.UIScreenAdaptor uisc)
          mutator for screenAdaptor
 void setSingletonAccessor(org.sandev.basics.nodecommon.SingletonAccessor val)
          mutator for singletonAccessor
 void setUIFormAdaptorClassName(java.lang.String val)
          mutator for UIFormAdaptorClassName
protected  void setupForWork(javax.servlet.http.HttpServletRequest req)
          Set up for work.
protected  javax.servlet.ServletOutputStream wrappedGetOutputStream(javax.servlet.http.HttpServletResponse res)
          Wrapper for HttpServletResponse getOutputStream that throws a SandException rather than an IOException.
protected  java.io.PrintWriter wrappedGetOutputWriter(org.sandev.basics.util.UIRenderOutputStream uiros)
          Wrapper for UIRenderOutputStream getOutputWriter that throws a SandException rather than an IOException.
protected  void wrappedRedirect(javax.servlet.http.HttpServletResponse res, java.lang.String url)
          Wrapper for HttpServletResponse sendRedirect that throws a SandException if anything goes wrong.
 void writeRememberMeCookie(org.sandev.basics.util.AuthUser user, javax.servlet.http.HttpServletResponse res)
          Write the cookie that stores the authentication information.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AUTHPARAM

public static final java.lang.String AUTHPARAM
The name of the session variable that holds the uniqueID of the user after they have logged in.

See Also:
Constant Field Values

LOGINFAIL

public static final java.lang.String LOGINFAIL
The text for an invalid login message.

See Also:
Constant Field Values

TITLE

public static final java.lang.String TITLE
The text we use for the title where needed. This is replaced during transformation processing.

See Also:
Constant Field Values

sandUIFileName

protected java.lang.String sandUIFileName
This is the name of the file holding the XML serialized form of the SandUI definition.


charSerializerClassName

protected java.lang.String charSerializerClassName
This is the fully qualified class name of the CharSerializer we should use to read from sandUIFileName.


uiFormAdaptorClassName

protected java.lang.String uiFormAdaptorClassName
This is the fully qualified name of the UIFormAdaptor we should use for input and output.


nodeInstanceFactoryClassName

protected java.lang.String nodeInstanceFactoryClassName
This is the fully qualified class name of the NodeInstanceFactory we use if we are launching the SandRoot directly.


sandUIXML

protected java.lang.String sandUIXML
The serialized SandUI definition. This is retrieved from the sandUIFileName if not set explicitely.


sandUI

protected org.sandev.ui.sandmessages.SandUI sandUI
The SandUI instance we are working with. This is set from the sandUIXML value if not set explicitely.


ownerNodeName

protected java.lang.String ownerNodeName
The name of the local node instance implementing UIFormOwner.


formOwner

protected org.sandev.basics.util.UIFormOwner formOwner
The UIFormOwner instance we use for processing.


singletonAccessor

protected org.sandev.basics.nodecommon.SingletonAccessor singletonAccessor
The SingletonAccessor we will use to bridge from here to the application processing.


localLaunch

protected boolean localLaunch
Flag directing whether the servlet should launch the application nodes itself. If this is handled outside the servlet container then this should be left as false. If set to true, then the application nodes are instantiated when the servlet initializes.


localeOverrideLanguage

protected java.lang.String localeOverrideLanguage
Override setting to hardcode the language this servlet will use regardless of incoming request Locale settings. This must be a valid language value as defined by the Locale class. Leave this as null or "" to determine the language dynamically.


localeOverrideCountry

protected java.lang.String localeOverrideCountry
Override setting to hardcode the country this servlet will use regardless of incoming request Locale settings. This must be a valid country value as defined by the Locale class. Leave this as null or "" to determine the country dynamically.


localeOverrideVariant

protected java.lang.String localeOverrideVariant
Override setting to hardcode the variant this servlet will use regardless of incoming request Locale settings. Leave this as null or "" to determine the variant dynamically.


controlServlet

protected javax.servlet.http.HttpServlet controlServlet
The original servlet for this request. This is used to retrieve the servlet context for content retrieval and must be set by the controlling servlet.


screenAdaptor

protected org.sandev.ui.util.UIScreenAdaptor screenAdaptor
The instance we use for rendering/reconstruction. The initializer is called during setupForWork and sets this value if it is null.


sandTransformer

protected org.sandev.ui.util.SandTransformer sandTransformer
The instance we use for transformation rendering. The initializer is called during setupForWork and sets this value if it is null.


formManager

protected org.sandev.basics.util.UIFormManager formManager
Our manager handles basic form context actions. The initializer is called during setupForWork and sets this value if it is null.


fixedMode

protected boolean fixedMode
If true, the security settings declared in the SandUI are ignored. So if you start out in http, then you will stay in http regardless of the defaultSecurity in the SandUI, or the security in any screen. This is appropriate for use in low security applications where the additional overhead of https isn't worth it.

Fixed mode can also be used in high security installations where https is used throughout. If you start in https then you won't get switched out regardless of the security setting in the SandUI declarations.

The default is false (the mode changes according to the SandUI declarations).


rememberMeCookieName

protected java.lang.String rememberMeCookieName
The name of the "remember me" login cookie. If this is null or "" then "remember me" is disabled.

If the user chooses the "remember me" option at login, then their username:password is stored in a cookie and retrieved for subsequent login processing.


rememberMePassphrase

protected java.lang.String rememberMePassphrase
The passphrase used to encrypt the username:password when stored in a cookie. If this is null or "" then "remember me" is disabled.


encryptor

protected org.sandev.basics.util.SandEncryptor encryptor
Our encryptor is used for securing the values of the remember me cookie. The initializer is called during setupForWork and sets this value if it is null and a rememberMePassphrase exists.


forgotPasswordPrimary

protected java.lang.String forgotPasswordPrimary
The first field to prompt with if the user forgot their password. If this is null or the empty string then forgot password processing is disabled.


forgotPasswordSecondary

protected java.lang.String forgotPasswordSecondary
the second field to prompt with if the user forgot their password. If this is null or the empty string then no secondary prompt will be generated.


setup

protected boolean setup
Flag indicating whether we are set up to do work yet. This flag is set during initialization processing, which is synchronized to avoid any threads getting half initialized stuff. Access is not synchronized, to avoid synchronization overhead once we are up and running.

Constructor Detail

XHTMLSandUIServlet

public XHTMLSandUIServlet()
Default ctor does nothing, the SandUI XML and processing node instance name must be set separately.

Method Detail

getSandUIFileName

public java.lang.String getSandUIFileName()
accessor for sandUIFileName


setSandUIFileName

public void setSandUIFileName(java.lang.String name)
mutator for sandUIFileName

Specified by:
setSandUIFileName in interface GeneratedServletInterface

getCharSerializerClassName

public java.lang.String getCharSerializerClassName()
accessor for charSerializerClassName


setCharSerializerClassName

public void setCharSerializerClassName(java.lang.String val)
mutator for charSerializerClassName

Specified by:
setCharSerializerClassName in interface GeneratedServletInterface

getUIFormAdaptorClassName

public java.lang.String getUIFormAdaptorClassName()
accessor for UIFormAdaptorClassName


setUIFormAdaptorClassName

public void setUIFormAdaptorClassName(java.lang.String val)
mutator for UIFormAdaptorClassName

Specified by:
setUIFormAdaptorClassName in interface GeneratedServletInterface

getNodeInstanceFactoryClassName

public java.lang.String getNodeInstanceFactoryClassName()
accessor for nodeInstanceFactoryClassName


setNodeInstanceFactoryClassName

public void setNodeInstanceFactoryClassName(java.lang.String val)
mutator for nodeInstanceFactoryClassName


getSandUIXML

public java.lang.String getSandUIXML()
accessor for sandUIXML


setSandUIXML

public void setSandUIXML(java.lang.String val)
mutator for sandUIXML


getSandUI

public org.sandev.ui.sandmessages.SandUI getSandUI()
accessor for sandUI


setSandUI

public void setSandUI(org.sandev.ui.sandmessages.SandUI val)
mutator for sandUI


getOwnerNodeName

public java.lang.String getOwnerNodeName()
accessor for ownerNodeName


setOwnerNodeName

public void setOwnerNodeName(java.lang.String val)
mutator for ownerNodeName

Specified by:
setOwnerNodeName in interface GeneratedServletInterface

getFormOwner

public org.sandev.basics.util.UIFormOwner getFormOwner()
accessor for formOwner


setFormOwner

public void setFormOwner(org.sandev.basics.util.UIFormOwner owner)
mutator for formOwner


getSingletonAccessor

public org.sandev.basics.nodecommon.SingletonAccessor getSingletonAccessor()
accessor for singletonAccessor


setSingletonAccessor

public void setSingletonAccessor(org.sandev.basics.nodecommon.SingletonAccessor val)
mutator for singletonAccessor

Specified by:
setSingletonAccessor in interface GeneratedServletInterface

isLocalLaunch

public boolean isLocalLaunch()
accessor for launchNodesFromServlet


setLocalLaunch

public void setLocalLaunch(boolean val)
mutator for launchNodesFromServlet

Specified by:
setLocalLaunch in interface GeneratedServletInterface

getLocaleOverrideLanguage

public java.lang.String getLocaleOverrideLanguage()
accessor for localeOverrideLanguage


setLocaleOverrideLanguage

public void setLocaleOverrideLanguage(java.lang.String val)
mutator for localeOverrideLanguage


getLocaleOverrideCountry

public java.lang.String getLocaleOverrideCountry()
accessor for localeOverrideCountry


setLocaleOverrideCountry

public void setLocaleOverrideCountry(java.lang.String val)
mutator for localeOverrideCountry


getLocaleOverrideVariant

public java.lang.String getLocaleOverrideVariant()
accessor for localeOverrideVariant


setLocaleOverrideVariant

public void setLocaleOverrideVariant(java.lang.String val)
mutator for localeOverrideVariant


getControlServlet

public javax.servlet.http.HttpServlet getControlServlet()
accessor for controlServlet


setControlServlet

public void setControlServlet(javax.servlet.http.HttpServlet val)
mutator for controlServlet

Specified by:
setControlServlet in interface GeneratedServletInterface

getScreenAdaptor

public org.sandev.ui.util.UIScreenAdaptor getScreenAdaptor()
accessor for screenAdaptor


setScreenAdaptor

public void setScreenAdaptor(org.sandev.ui.util.UIScreenAdaptor uisc)
mutator for screenAdaptor


getSandTransformer

public org.sandev.ui.util.SandTransformer getSandTransformer()
accessor for sandTransformer


setSandTransformer

public void setSandTransformer(org.sandev.ui.util.SandTransformer trans)
mutator for sandTransformer


initSandTransformer

public void initSandTransformer()
initializer for sandTransformer


getFormManager

public org.sandev.basics.util.UIFormManager getFormManager()
accessor for formManager


setFormManager

public void setFormManager(org.sandev.basics.util.UIFormManager uifm)
mutator for formManager


initFormManager

public void initFormManager()
initializer for formManager


inFixedMode

public boolean inFixedMode()
accessor for fixedMode


setFixedMode

public void setFixedMode(boolean val)
mutator for fixedMode

Specified by:
setFixedMode in interface GeneratedServletInterface

getRememberMeCookieName

public java.lang.String getRememberMeCookieName()
accessor for rememberMeCookieName


setRememberMeCookieName

public void setRememberMeCookieName(java.lang.String val)
mutator for rememberMeCookieName


getRememberMePassphrase

public java.lang.String getRememberMePassphrase()
accessor for rememberMePassphrase


setRememberMePassphrase

public void setRememberMePassphrase(java.lang.String val)
mutator for rememberMePassphrase


getEncryptor

public org.sandev.basics.util.SandEncryptor getEncryptor()
accessor for encryptor


setEncryptor

public void setEncryptor(org.sandev.basics.util.SandEncryptor se)
mutator for encryptor


initEncryptor

public void initEncryptor()
                   throws org.sandev.basics.util.SandEncryptorException
initializer for encryptor

Throws:
org.sandev.basics.util.SandEncryptorException

rememberMeSupported

public boolean rememberMeSupported()
Returns true if "remember me" processing can be supported, false otherwise. This returns true if we have a cookie name and we have an encryptor. The passphrase is not checked since somebody might supply their own encryptor which doesn't use that.


readRememberMeCookie

public long readRememberMeCookie(long defaultAuthID,
                                 javax.servlet.http.HttpServletRequest req)
                          throws org.sandev.basics.structs.SandException
Read the cookie where we stored the authentication information and return the associated AuthUser uniqueID. Return the defaultAuthID if not found.

Throws:
org.sandev.basics.structs.SandException

writeRememberMeCookie

public void writeRememberMeCookie(org.sandev.basics.util.AuthUser user,
                                  javax.servlet.http.HttpServletResponse res)
                           throws org.sandev.basics.structs.SandException
Write the cookie that stores the authentication information.

Throws:
org.sandev.basics.structs.SandException

getForgotPasswordPrimary

public java.lang.String getForgotPasswordPrimary()
accessor for forgotPasswordPrimary


setForgotPasswordPrimary

public void setForgotPasswordPrimary(java.lang.String val)
mutator for forgotPasswordPrimary


getForgotPasswordSecondary

public java.lang.String getForgotPasswordSecondary()
accessor for forgotPasswordSecondary


setForgotPasswordSecondary

public void setForgotPasswordSecondary(java.lang.String val)
mutator for forgotPasswordSecondary


readTemplate

public java.lang.String readTemplate(java.lang.String templateName)
                              throws org.sandev.ui.util.SandTransformerException
Given a template name, return the contents. This method retrieves the contents using the ServletContext of the originating servlet.

Specified by:
readTemplate in interface org.sandev.ui.util.TemplateReader
Throws:
org.sandev.ui.util.SandTransformerException

loadResource

public java.lang.String loadResource(java.lang.String rsrcname)
                              throws org.sandev.ui.util.SandTransformerException
Utility to load the contents of a servlet resource. The resource specification looks like "/subdirOffWebappDir/filename.ext".

Throws:
org.sandev.ui.util.SandTransformerException

doGet

public void doGet(javax.servlet.http.HttpServletRequest req,
                  javax.servlet.http.HttpServletResponse res)
Pass HTTP 'GET' request over to handleRequest method.


doPost

public void doPost(javax.servlet.http.HttpServletRequest req,
                   javax.servlet.http.HttpServletResponse res)
Pass HTTP 'POST' request over to handleRequest method.


handleRequest

protected void handleRequest(javax.servlet.http.HttpServletRequest req,
                             javax.servlet.http.HttpServletResponse res)
Use our SandUIProcessor to process the request.


doRequest

protected void doRequest(javax.servlet.http.HttpServletRequest req,
                         javax.servlet.http.HttpServletResponse res,
                         java.util.Locale locale)
                  throws java.lang.Exception
Workhorse for handleRequest. It's easier to read the core code logic with the error handling factored.

Throws:
java.lang.Exception

processScreen

protected void processScreen(org.sandev.ui.sandmessages.Screen screen,
                             javax.servlet.http.HttpServletRequest req,
                             org.sandev.basics.util.UserWorkLog uwl)
                      throws org.sandev.basics.util.UIFormManagerException
Process the screen. When a Screen is rebuilt from the UI display, a UIFormContext is created for any Link with associated actions. This method picks up on any requested actions and calls the UIFormManager or UIFormOwner for processing.

The UIFormContext action is set to ACTION_INIT when the action is UNDEFINED and the form appears to be uninitialized. Action processing occurs in the following order:

  1. If a custom action was requested, process that action.
  2. If a standard form manager action was requested, then call to handle it.
  3. If initialization was requested, then call form initialization processing if defined.

Either a custom action or standard form processing action can trigger initialization processing by setting the UIFormContext.action to ACTION_INIT explicitely.

Throws:
org.sandev.basics.util.UIFormManagerException

authenticate

protected org.sandev.basics.util.AuthUser authenticate(javax.servlet.http.HttpServletRequest req,
                                                       javax.servlet.http.HttpServletResponse res,
                                                       java.util.Locale locale)
                                                throws org.sandev.basics.structs.SandException
Find out who this user is and return an instance for processing. If this method throws, then an error is reported. If this method returns null, then no further processing is attempted (the request is considered done). In effect, authentication is a sub-servlet which in given control unless it returns an AuthUser instance.

By default, this method handles login through a secure form, storing the user information in the session.

Throws:
org.sandev.basics.structs.SandException

authLogin

protected org.sandev.basics.util.AuthUser authLogin(javax.servlet.http.HttpServletRequest req,
                                                    javax.servlet.http.HttpServletResponse res,
                                                    java.util.Locale locale)
                                             throws org.sandev.basics.structs.SandException
Display and process a login form. If the username/password info matches an AuthUser, then the AUTHPARAM in the session is set to the uniqueID and the request is redirected to the default URL. If username/password info is found but does not match an AuthUser, then the form is redisplayed with the LOGINFAIL error message. If no username/password info is found, then the form is displayed. This method always returns null.

Login processing verifies and requires https. Technically secure comms are only required on form submission, but it seems like most users prefer the form to be displayed securly as well.

Throws:
org.sandev.basics.structs.SandException

dumpLoginForm

protected void dumpLoginForm(java.io.PrintWriter out)
Helper method to dump the login form. Factored out here for clarity.


authLogout

protected org.sandev.basics.util.AuthUser authLogout(javax.servlet.http.HttpServletRequest req,
                                                     javax.servlet.http.HttpServletResponse res)
                                              throws org.sandev.basics.structs.SandException
Clear the user login info so the default unauthenticated page processing is ready to go. The AUTHPARAM in the session is cleared or set to the public AuthUser ID as specified. The request is redirected to the default URL using unsecured http. This method always returns null.

Throws:
org.sandev.basics.structs.SandException

forgotPassword

protected org.sandev.basics.util.AuthUser forgotPassword(javax.servlet.http.HttpServletRequest req,
                                                         javax.servlet.http.HttpServletResponse res,
                                                         java.util.Locale locale)
                                                  throws org.sandev.basics.structs.SandException
Display and process a forgot password request. This has a primary field prompt, and an optional second field prompt. The user fills out the value(s) and we call the owner for processing.

Throws:
org.sandev.basics.structs.SandException

authWelcome

protected org.sandev.basics.util.AuthUser authWelcome(javax.servlet.http.HttpServletRequest req,
                                                      javax.servlet.http.HttpServletResponse res,
                                                      java.util.Locale locale)
                                               throws org.sandev.basics.structs.SandException
Display the default unauthenticated user welcome page. This is a fixed content page with two paragraphs. The first contains a message such as "Login required" and the second contains the link to the login page. This default content is run through the SandUI welcomeTemplate if specified, and the defaultTemplate if not.

The welcome page will only be displayed for applications that require login. If a public AuthUser ID is specified, then this method is never called.

Throws:
org.sandev.basics.structs.SandException

dumpOverviewInfo

protected void dumpOverviewInfo(java.io.PrintWriter out,
                                java.util.Locale locale)
                         throws org.sandev.basics.structs.SandException
Dump the header information like the deployment prefix and locale.

Throws:
org.sandev.basics.structs.SandException

rewriteURL

public java.lang.String rewriteURL(javax.servlet.http.HttpServletRequest req,
                                   boolean secureMode,
                                   java.lang.String params)
                            throws org.sandev.basics.structs.SandException
Rewrite the current URL for the specified mode with the specified parameters.

Throws:
org.sandev.basics.structs.SandException

modeOk

public boolean modeOk(javax.servlet.http.HttpServletRequest req,
                      boolean secureMode)
Return true if we are in the required mode, false otherwise. So for example the login method will call this method with secureMode true and this method will return true if login can go ahead.


dumpUserLoginInfo

protected void dumpUserLoginInfo(org.sandev.basics.util.UIRenderOutputString uiros,
                                 org.sandev.basics.util.AuthUser user,
                                 org.sandev.basics.util.AuthFilter filter,
                                 javax.servlet.http.HttpServletRequest req)
                          throws org.sandev.basics.structs.SandException
Dump out information for the logged in user along with a logout link. If the current AuthUser has the publicAuthUserID, then we display a login link, otherwise we display a logout link.

Transformation requires the full summary information for the user, although it will typically hide or move most of it.

Throws:
org.sandev.basics.structs.SandException

confirmUser

protected org.sandev.basics.util.AuthUser confirmUser(org.sandev.basics.util.AuthUser user,
                                                      org.sandev.ui.sandmessages.Screen screen,
                                                      javax.servlet.http.HttpServletRequest req)
Confirm that the given user is still the current user. If not, then the application has allowed the existing user to switch to a different user and we need to update the session to reflect who we are now. If nothing has changed, or if anything goes wrong during processing, then return the given AuthUser.


readAuthParameters

public long readAuthParameters(long defaultAuthID,
                               javax.servlet.http.HttpServletRequest req)
                        throws org.sandev.basics.structs.SandException
Read the URL parameters for username password information and return the associated AuthUser uniqueID if found. Return the defaultAuthID if not found. Specifying the username and password as URL parameters is generally bad practice since this can be observed in transit and gets recorded in firewall logs and everywhere. However there are times when this can be a useful mechanism.

One example is access to our demo heap. The demo heap provides access as requested, and all passwords are "demo" so it doesn't matter if we send that info as a URL parameter. By specifying the username/password info, we can automatically set up a user account if the requestor doesn't already have one.

Throws:
org.sandev.basics.structs.SandException

errorout

protected void errorout(java.lang.Throwable err,
                        javax.servlet.http.HttpServletResponse res,
                        java.util.Locale locale)
                 throws org.sandev.basics.structs.SandException
Display the exception using the standard output processing and the errorTemplate in the SandUI. If no errorTemplate is specified then the defaultTemplate is used.

Throws:
org.sandev.basics.structs.SandException

dumpStackTrace

protected void dumpStackTrace(java.io.PrintWriter out,
                              java.lang.Throwable err,
                              java.lang.String title)
Dump a stack trace as HTML for the given throwable. Note that a generic class name may show up with bad XHTML characters in it (for example "org.hsqldb.Result.") so we XML escape each line to avoid blowing up formatting transformation.


failout

protected void failout(java.lang.Throwable err,
                       javax.servlet.http.HttpServletResponse res)
Die nicely. This method provides all its own page contents so it doesn't depend on having to load any external resources. It also does no transformation processing since that might also cause processing errors. Override this method with your own or modify the code if you want to change what a full crash looks like. You should never see this.


getCoreError

public static java.lang.String getCoreError(java.lang.String errortext)
This is a heuristic method that identifies some of the more common root error causes from the extensive error message that usually comes back from processing. Useful for presenting a less intimidating message for things that are not serious.

This method only handles common framework problems. Application errors trigger exceptions to be thrown by the UIFormOwner, and the display template for the error page picks up on those.


isSetup

public boolean isSetup()
accessor for setup


setupForWork

protected void setupForWork(javax.servlet.http.HttpServletRequest req)
                     throws org.sandev.basics.structs.SandException
Set up for work. Since several threads may try to init at the same time and queue up, each thread needs to check if a previous thread has already initialized things.

Throws:
org.sandev.basics.structs.SandException

initScreenAdaptor

public void initScreenAdaptor()
                       throws org.sandev.basics.structs.SandException
Initialize our screenAdaptor

Throws:
org.sandev.basics.structs.SandException

getUploadLinkURL

protected java.lang.String getUploadLinkURL(javax.servlet.http.HttpServletRequest req)
Given a reqest, return the URL where we expect to find uploaded files.


getOutfileLinkURL

protected java.lang.String getOutfileLinkURL(javax.servlet.http.HttpServletRequest req)
Given a request, return the URL where we expect to find generated output files.


isScreenSecured

protected boolean isScreenSecured(org.sandev.ui.sandmessages.SandUI sandui,
                                  org.sandev.ui.sandmessages.Screen screen)
Return true if this screen is secure, false otherwise.


newURLSpecified

protected java.lang.String newURLSpecified(javax.servlet.http.HttpServletRequest req,
                                           org.sandev.ui.sandmessages.Screen screen)
Walk the elements of the given screen to see if any of the contained UIFormContexts specify a new URL. Return the new URL if found, null otherwise.


wrappedRedirect

protected void wrappedRedirect(javax.servlet.http.HttpServletResponse res,
                               java.lang.String url)
                        throws org.sandev.basics.structs.SandException
Wrapper for HttpServletResponse sendRedirect that throws a SandException if anything goes wrong. Avoids lots of try-block clutter.

Throws:
org.sandev.basics.structs.SandException

wrappedGetOutputWriter

protected java.io.PrintWriter wrappedGetOutputWriter(org.sandev.basics.util.UIRenderOutputStream uiros)
                                              throws org.sandev.basics.structs.SandException
Wrapper for UIRenderOutputStream getOutputWriter that throws a SandException rather than an IOException. Avoids try-block clutter.

Throws:
org.sandev.basics.structs.SandException

wrappedGetOutputStream

protected javax.servlet.ServletOutputStream wrappedGetOutputStream(javax.servlet.http.HttpServletResponse res)
                                                            throws org.sandev.basics.structs.SandException
Wrapper for HttpServletResponse getOutputStream that throws a SandException rather than an IOException. Avoids try-block clutter.

Throws:
org.sandev.basics.structs.SandException

parseSandUI

protected org.sandev.ui.sandmessages.SandUI parseSandUI()
                                                 throws org.sandev.basics.structs.SandException
Get the UI definition from the XML we were set up with.

Throws:
org.sandev.basics.structs.SandException

getFormOwnerNode

protected org.sandev.basics.util.UIFormOwner getFormOwnerNode()
                                                       throws org.sandev.basics.structs.SandException
Retrieve a reference to the specified node instance to serve as a UIFormOwner.

Throws:
org.sandev.basics.structs.SandException

findSandRoot

protected org.sandev.basics.nodecommon.SandRoot findSandRoot()
                                                      throws org.sandev.basics.structs.SandException
Locate the SandRoot or throw if it can't be found. Check the configured SingletonAccessor first, then the default, then die. This method assumes that the root has been set up and all we have to do is return it.

Throws:
org.sandev.basics.structs.SandException

negotiateLocale

protected java.util.Locale negotiateLocale(java.util.Enumeration locales)
Return a Locale taking into account any overrides, the SandUI constraints, the user's preferances, and the server environment. The enumeration of locales is from ServletRequest.getLocales() which always contains at least one element (the default server environment).


debugout

protected void debugout(java.lang.String text)
Shorthand debug output


convertAndDisplay

protected void convertAndDisplay(java.lang.String formXHTML,
                                 javax.servlet.http.HttpServletResponse res,
                                 java.lang.String helpfile,
                                 org.sandev.ui.sandmessages.Screen screen,
                                 java.util.Locale locale)
                          throws java.io.IOException,
                                 org.sandev.ui.util.SandTransformerException
Take the output that was returned by XHTMLFormAdaptor and convert it according to the specified templates.

It's possible to organize different look and feel templates via multiple deployments, or multiple webapps within a single deployment. To create a dynamic "skinnable" app, our recommendation is to subclass this servlet and override this method to find a prefix or directory parameter which determines the template set to apply.

Throws:
java.io.IOException
org.sandev.ui.util.SandTransformerException

insertPopUp

protected java.lang.String insertPopUp(java.lang.String formXHTML,
                                       java.lang.String helpfile)
Given some XHTML, modify it to create a pop up containing the given helpfile text. The result may not be XHTML compatible, and we are assuming that it's ok to overwrite the body tag.