com.sun.webui.jsf.component
Class Login

java.lang.Object
  extended by javax.faces.component.UIComponent
      extended by javax.faces.component.UIComponentBase
          extended by javax.faces.component.UIOutput
              extended by javax.faces.component.UIInput
                  extended by com.sun.webui.jsf.component.WebuiInput
                      extended by com.sun.webui.jsf.component.Login
All Implemented Interfaces:
javax.faces.component.EditableValueHolder, javax.faces.component.NamingContainer, javax.faces.component.StateHolder, javax.faces.component.ValueHolder

public class Login
extends WebuiInput
implements javax.faces.component.NamingContainer

The Login component provides an authentication presentation layer that can plug in different authentication technologies at the backend. The component currently supports JAAS based authentication. This component is an EditableValueHolder. There are essentially two threads in play here - the presentation layer's thread and a controller thread that performs the actual authentication. Interaction between the two threads happens during the validation phase of the JSF lifecycle. The interaction happens via a callback object that originates from the underlying authentication implementation class. This callback object contains a list of input fields that need to be displayed on the client side for user data entry. During validation the component can be in one of three states based on the state of the client and the underlying authentication mechanism:

An application can specify a URL to redirect to after successful authentication.


Field Summary
 
Fields inherited from class javax.faces.component.UIInput
COMPONENT_FAMILY, COMPONENT_TYPE, CONVERSION_MESSAGE_ID, REQUIRED_MESSAGE_ID, UPDATE_MESSAGE_ID
 
Fields inherited from interface javax.faces.component.NamingContainer
SEPARATOR_CHAR
 
Constructor Summary
Login()
          Construct a new Login.
 
Method Summary
 java.util.Map getAuthenticationKeys()
           Returns a map containing a mapping between the IDs of the callback data objects as supplied by the underlying authentication infrastructure and their corresponding clientIDs for the corresponding JSF components.
 com.sun.webui.jsf.model.login.LoginCallback getCallbackObject()
           Get the LoginCallback object.
 java.lang.String getFamily()
          Return the family for this component.
 java.lang.String getHtmlTemplate()
          Get alternative HTML template to be used by this component.
 java.lang.String getLoginClass()
          Return the name of the login module implementation class where the request came from.
 java.lang.String getLoginController()
          Get the login controller implementation class name.
 com.sun.webui.jsf.model.login.LoginConstants.LOGINSTATE getLoginState()
          Defines the state of the authentication process.
 java.lang.String getRedirectURL()
          Get the URL to which the user should be redirected upon successful authentication.
 java.lang.String getRendererType()
          Return the renderer type for this component.
 java.lang.String getServiceName()
          Get the name of the JAAS login service from configuration file.
 java.lang.String getStyle()
          Get the CSS style(s) to be applied to the outermost HTML element when the component is rendered.
 java.lang.String getStyleClass()
           Get the CSS style class(es) to be applied to the outermost HTML element when this component is rendered.
 int getTabIndex()
          Position of this element in the tabbing order of the current document.
 boolean isAutoStart()
           A boolean attribute indicating if the login component should initiate the authentication process on its own without any client side intervention or wait for some other client side entity to start the authentication process.
 boolean isImmediate()
          Flag indicating that event handling for this component should be handled immediately (in Apply Request Values phase) rather than waiting until Invoke Application phase.
 void processDecodes(javax.faces.context.FacesContext context)
          Override the default UIComponent.processDecodes(javax.faces.context.FacesContext) processing to perform the following steps.
 void processValidators(javax.faces.context.FacesContext context)
          Validation of user entered data is done by posting them as key value pairs to callback object.
 void restoreState(javax.faces.context.FacesContext _context, java.lang.Object _state)
          Restore the state of this component.
 java.lang.Object saveState(javax.faces.context.FacesContext _context)
          Save the state of this component.
 void setAuthenticationKeys(java.util.Map keys)
           Sets a map containing a mapping between the IDs of the callback data objects as supplied by the underlying authentication infrastructure and their corresponding clientIDs for the corresponding JSF components.
 void setAutoStart(boolean autoStart)
          Set autoStart to false to control the time when authentication should start.
 void setCallbackObject(com.sun.webui.jsf.model.login.LoginCallback callbackObject)
          Sets the LoginCallback object for use during the Render Response phase.
 void setHtmlTemplate(java.lang.String htmlTemplate)
          Set alternative HTML template to be used by this component.
 void setImmediate(boolean immediate)
          Flag indicating that event handling for this component should be handled immediately (in Apply Request Values phase) rather than waiting until Invoke Application phase.
 void setLoginClass(java.lang.String loginClass)
          Set the name of the login module implementation class where the request came from.
 void setLoginController(java.lang.String loginController)
          Set the Login controller implementation class.
 void setLoginState(com.sun.webui.jsf.model.login.LoginConstants.LOGINSTATE loginState)
          Sets the current state of the authentication process.
 void setRedirectURL(java.lang.String redirectURL)
          Set the URL to which the user should be redirected upon successful authentication.
 void setServiceName(java.lang.String serviceName)
          Set the name of the JAAS login service from configuration file.
 void setStyle(java.lang.String style)
          Set the CSS style(s) to be applied to the outermost HTML element when the component is rendered.
 void setStyleClass(java.lang.String styleClass)
           Set the CSS style class(es) to be applied to the outermost HTML element when this component is rendered.
 void setTabIndex(int tabIndex)
          Position of this element in the tabbing order of the current document.
 void updateModel(javax.faces.context.FacesContext context)
          Perform the following algorithm to update the model data associated with this UIInput, if any, as appropriate.
 void validate(javax.faces.context.FacesContext context)
          Interaction with the underlying authentication infrastructure takes place in this method.
 
Methods inherited from class com.sun.webui.jsf.component.WebuiInput
broadcast, getValidator, getValidatorExpression, getValueChangeListener, getValueChangeListenerExpression, processUpdates, setConverter, setId, setRendered, setRequired, setValidatorExpression, setValueChangeListenerExpression
 
Methods inherited from class javax.faces.component.UIInput
addValidator, addValueChangeListener, decode, getConverterMessage, getRequiredMessage, getSubmittedValue, getValidatorMessage, getValidators, getValueChangeListeners, isLocalValueSet, isRequired, isValid, removeValidator, removeValueChangeListener, resetValue, setConverterMessage, setLocalValueSet, setRequiredMessage, setSubmittedValue, setValid, setValidator, setValidatorMessage, setValue, setValueChangeListener
 
Methods inherited from class javax.faces.component.UIOutput
getConverter, getLocalValue, getValue
 
Methods inherited from class javax.faces.component.UIComponentBase
encodeBegin, encodeChildren, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientId, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getParent, getRendersChildren, getValueBinding, getValueExpression, invokeOnComponent, isRendered, isTransient, processRestoreState, processSaveState, queueEvent, restoreAttachedState, saveAttachedState, setParent, setRendererType, setTransient, setValueBinding, setValueExpression
 
Methods inherited from class javax.faces.component.UIComponent
encodeAll, getContainerClientId
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.faces.component.ValueHolder
getConverter, getLocalValue, getValue
 

Constructor Detail

Login

public Login()

Construct a new Login.

Method Detail

getFamily

public java.lang.String getFamily()

Return the family for this component.

Overrides:
getFamily in class javax.faces.component.UIInput

getRendererType

public java.lang.String getRendererType()

Return the renderer type for this component.

Overrides:
getRendererType in class javax.faces.component.UIComponentBase

getHtmlTemplate

public java.lang.String getHtmlTemplate()
Get alternative HTML template to be used by this component.


setHtmlTemplate

public void setHtmlTemplate(java.lang.String htmlTemplate)
Set alternative HTML template to be used by this component.


getLoginState

public com.sun.webui.jsf.model.login.LoginConstants.LOGINSTATE getLoginState()

Defines the state of the authentication process. The states should be one of the following: INIT - initialization of authentication process CONTINUE - authentication process currently in progress, and SUCCESS - authentication process completed successfully. FAILURE - authentication process has ended in failure.


setLoginState

public void setLoginState(com.sun.webui.jsf.model.login.LoginConstants.LOGINSTATE loginState)
Sets the current state of the authentication process.

See Also:
getLoginState()

setAuthenticationKeys

public void setAuthenticationKeys(java.util.Map keys)

Sets a map containing a mapping between the IDs of the callback data objects as supplied by the underlying authentication infrastructure and their corresponding clientIDs for the corresponding JSF components. This information is required to extract the data entered by the user from the request header map.


getAuthenticationKeys

public java.util.Map getAuthenticationKeys()

Returns a map containing a mapping between the IDs of the callback data objects as supplied by the underlying authentication infrastructure and their corresponding clientIDs for the corresponding JSF components. This information is required to extract the data entered by the user from the request header map.


isAutoStart

public boolean isAutoStart()

A boolean attribute indicating if the login component should initiate the authentication process on its own without any client side intervention or wait for some other client side entity to start the authentication process. By default this attribute is set to true. In situations where the authentication process needs to start based on other events happening on the client side this attribute should be set to false and the appropriate client side API used to fire up the process.


setAutoStart

public void setAutoStart(boolean autoStart)

Set autoStart to false to control the time when authentication should start.

See Also:
isAutoStart()

getLoginClass

public java.lang.String getLoginClass()

Return the name of the login module implementation class where the request came from. This information is needed by the callback handler to prompt users for data or figure out error conditions.


setLoginClass

public void setLoginClass(java.lang.String loginClass)

Set the name of the login module implementation class where the request came from. This information is needed by the callback handler to prompt users for data or figure out error conditions.


getRedirectURL

public java.lang.String getRedirectURL()

Get the URL to which the user should be redirected upon successful authentication.


setRedirectURL

public void setRedirectURL(java.lang.String redirectURL)

Set the URL to which the user should be redirected upon successful authentication.

See Also:
getRedirectURL()

getServiceName

public java.lang.String getServiceName()

Get the name of the JAAS login service from configuration file. The name of an entry in the JAAS login configuration file. This is the name for the LoginContext to use to look up an entry for this application in the JAAS login configuration file, described here. Such an entry specifies the class(es) that implement the desired underlying authentication technology(ies).


setServiceName

public void setServiceName(java.lang.String serviceName)

Set the name of the JAAS login service from configuration file.

See Also:
getServiceName()

getLoginController

public java.lang.String getLoginController()

Get the login controller implementation class name. If this attribute is not supplied the default JAAS controller will be used. This attribute provides the application developer to use a non JAAS based authentication implementation with the same presentation layer.


setLoginController

public void setLoginController(java.lang.String loginController)

Set the Login controller implementation class.

* @see #getLoginController()


getStyle

public java.lang.String getStyle()

Get the CSS style(s) to be applied to the outermost HTML element when the component is rendered.


setStyle

public void setStyle(java.lang.String style)

Set the CSS style(s) to be applied to the outermost HTML element when the component is rendered.


getStyleClass

public java.lang.String getStyleClass()

Get the CSS style class(es) to be applied to the outermost HTML element when this component is rendered.


setStyleClass

public void setStyleClass(java.lang.String styleClass)

Set the CSS style class(es) to be applied to the outermost HTML element when this component is rendered.


isImmediate

public boolean isImmediate()

Flag indicating that event handling for this component should be handled immediately (in Apply Request Values phase) rather than waiting until Invoke Application phase. May be desired for this component when required is true (although most likely not).

Specified by:
isImmediate in interface javax.faces.component.EditableValueHolder
Overrides:
isImmediate in class javax.faces.component.UIInput

setImmediate

public void setImmediate(boolean immediate)

Flag indicating that event handling for this component should be handled immediately (in Apply Request Values phase) rather than waiting until Invoke Application phase. May be desired for this component when required is true (although most likely not).

Specified by:
setImmediate in interface javax.faces.component.EditableValueHolder
Overrides:
setImmediate in class WebuiInput
See Also:
isImmediate()

getTabIndex

public int getTabIndex()

Position of this element in the tabbing order of the current document. Tabbing order determines the sequence in which elements receive focus when the tab key is pressed. The value must be an integer between 0 and 32767.


setTabIndex

public void setTabIndex(int tabIndex)

Position of this element in the tabbing order of the current document. Tabbing order determines the sequence in which elements receive focus when the tab key is pressed. The value must be an integer between 0 and 32767.

See Also:
getTabIndex()

getCallbackObject

public com.sun.webui.jsf.model.login.LoginCallback getCallbackObject()

Get the LoginCallback object. The callback object that contains information sent by the underlying authentication layer to be used for generating presentation data that is transmitted to the client side. The callback object is made available during the validation phase of the component and contains entries that correspond to input elements that need to be displayed at the client for users to enter authentication data.


setCallbackObject

public void setCallbackObject(com.sun.webui.jsf.model.login.LoginCallback callbackObject)
Sets the LoginCallback object for use during the Render Response phase.

See Also:
getCallbackObject()

processDecodes

public void processDecodes(javax.faces.context.FacesContext context)

Override the default UIComponent.processDecodes(javax.faces.context.FacesContext) processing to perform the following steps.

Overrides:
processDecodes in class WebuiInput
Parameters:
context - FacesContext for the current request
Throws:
java.lang.NullPointerException - if context is null

processValidators

public void processValidators(javax.faces.context.FacesContext context)

Validation of user entered data is done by posting them as key value pairs to callback object. The callback object is read by the underlying authentication implementation classes in order to authenticate the user.

Overrides:
processValidators in class WebuiInput
Parameters:
context - FacesContext for the current request
Throws:
java.lang.NullPointerException - if context is null

validate

public void validate(javax.faces.context.FacesContext context)

Interaction with the underlying authentication infrastructure takes place in this method. By default the JAAS implementation of the controller is instantiated and used for interacting with the underlying the JAAS infrastructure. If the application has supplied a different implementation that would be used. Once the controller is instantiated the authentication process is initiated and its result rendered. The object is the stored in the session. Subsequent invocations of this method would cause the object to be retrieved and based on the status of the callback object act accordingly. If an exception is encountered the controller invokes abort thereby stopping all activities in the backend. Failure sets the component state to invalid and success sets the valid state to true, sets the local value of the component.

Overrides:
validate in class javax.faces.component.UIInput
Parameters:
context - FacesContext for the current request
Throws:
java.lang.NullPointerException - if context is null

updateModel

public void updateModel(javax.faces.context.FacesContext context)
Perform the following algorithm to update the model data associated with this UIInput, if any, as appropriate. By default the Subject object generated after a successful authentication would be used to update the model data. If the valid property of the Login component is false, take no further action. If the localValueSet property of this component is false, take no further action. If no ValueBinding for value exists, take no further action. Call setValue() method of the ValueBinding to update the value that the ValueBinding points at. If the setValue() method returns successfully: o Clear the local value of this UIInput. o Set the localValueSet property of this UIInput to false. If the setValue() method call fails: o Enqueue an error message by calling addMessage() on the specified FacesContext instance. o Set the valid property of this UIInput to false.

Overrides:
updateModel in class javax.faces.component.UIInput

restoreState

public void restoreState(javax.faces.context.FacesContext _context,
                         java.lang.Object _state)

Restore the state of this component.

Specified by:
restoreState in interface javax.faces.component.StateHolder
Overrides:
restoreState in class WebuiInput

saveState

public java.lang.Object saveState(javax.faces.context.FacesContext _context)

Save the state of this component.

Specified by:
saveState in interface javax.faces.component.StateHolder
Overrides:
saveState in class WebuiInput


Copyright © 2008 Sun Microsystems, Inc. All Rights Reserved.