org.zkoss.spring.security.ui.webapp
Class ZkAuthenticationEntryPoint

java.lang.Object
  extended by org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint
      extended by org.zkoss.spring.security.ui.webapp.ZkAuthenticationEntryPoint
All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean, org.springframework.security.web.AuthenticationEntryPoint

public class ZkAuthenticationEntryPoint
extends org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint

Used by ZkExceptionTranslationListener to commence an authentication scheme.

This implementation pops up a login Window and show the login form page (see LoginUrlAuthenticationEntryPoint.setLoginFormUrl(java.lang.String)) you specified(or the default one if you did not specify) as the content of the window. When the user login OK, it then show the login OK page you specified(see setLoginOKUrl(java.lang.String)) or the default one if you did not specified) and close the pop up window automatically.

If you want to customize your pop up login window, you can choose one of following options per your requirements:

  1. Use the default login window template and change the template arguments to the default login window template (see setLoginTemplateArg(java.lang.String, java.lang.Object))
  2. Create and provide own login window template(see setLoginTemplate(java.lang.String)) and template arguments(see setLoginTemplateArg(java.lang.String, java.lang.Object)).

Since:
1.0
Author:
henrichen

Field Summary
static java.lang.String AUTH
          Spring Authentication object
static java.lang.String EVENTS
          ZK Events that have not been processed because of the Authentication exception
static java.lang.String FORCE_HTTPS
          Force desktop to use https after successful authentication
static java.lang.String LOGIN_FAIL_URL
          Provided login fail url (provided for ajax login)
static java.lang.String LOGIN_OK_DELAY
          Delay seconds to close the popup login window
static java.lang.String LOGIN_OK_TEMPLATE
          Provided login ok template url
static java.lang.String LOGIN_OK_URL
          Provided login ok url
static java.lang.String LOGIN_WIN
          The popup template window uuid, need this info to remove it when login ok
static java.lang.String SAVED_DESKTOP
          The desktop which enter the login
static java.lang.String SAVED_URL
          The URL which enter the login
static java.lang.String SPRING_SECURITY_SAVED_REQUEST_KEY
           
 
Constructor Summary
ZkAuthenticationEntryPoint()
           
 
Method Summary
 void commence(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.security.core.AuthenticationException authException)
           
protected  java.lang.String determineUrlToUseForThisRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.security.core.AuthenticationException exception)
           
 java.lang.String getLoginFailUrl()
          Returns the login Fail URL.
 int getLoginOKDelay()
          Returns the delay seconds to close the login window after login OK(successfully).
 java.lang.String getLoginOKTemplate()
          Returns the login OK Template URL.
 java.lang.String getLoginOKUrl()
          Returns the login OK URL.
 java.lang.String getLoginTemplate()
          Returns the login template URL.
 java.util.Map getLoginTemplateArgs()
          Return the login template window arguments Map.
 void removeLoginTemplateArg(java.lang.String param)
          Remove the specified login template parameter.
 void setLoginFailUrl(java.lang.String loginFailUrl)
          Sets the login Fail URL.
 void setLoginOKDelay(int seconds)
          Sets the delay seconds to close the login window after login OK(successfully).
 void setLoginOKTemplate(java.lang.String loginOKTemplate)
           Set the login OK URL.
 void setLoginOKUrl(java.lang.String loginOKUrl)
          Set the login OK URL.
 void setLoginTemplate(java.lang.String templateURL)
          Set the login template URL.
 void setLoginTemplateArg(java.lang.String param, java.lang.Object value)
          The argument to be passed into the login window template (see getLoginTemplate()).
 void setLoginTemplateArgs(java.util.Map map)
          Sets the login template window arguments Map.
 
Methods inherited from class org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint
afterPropertiesSet, buildHttpsRedirectUrlForRequest, buildRedirectUrlToLoginPage, getLoginFormUrl, getPortMapper, getPortResolver, isForceHttps, isUseForward, setForceHttps, setLoginFormUrl, setPortMapper, setPortResolver, setUseForward
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SPRING_SECURITY_SAVED_REQUEST_KEY

public static final java.lang.String SPRING_SECURITY_SAVED_REQUEST_KEY
See Also:
Constant Field Values

LOGIN_OK_URL

public static final java.lang.String LOGIN_OK_URL
Provided login ok url

See Also:
Constant Field Values

LOGIN_OK_TEMPLATE

public static final java.lang.String LOGIN_OK_TEMPLATE
Provided login ok template url

See Also:
Constant Field Values

LOGIN_FAIL_URL

public static final java.lang.String LOGIN_FAIL_URL
Provided login fail url (provided for ajax login)

See Also:
Constant Field Values

SAVED_URL

public static final java.lang.String SAVED_URL
The URL which enter the login

See Also:
Constant Field Values

SAVED_DESKTOP

public static final java.lang.String SAVED_DESKTOP
The desktop which enter the login

See Also:
Constant Field Values

LOGIN_WIN

public static final java.lang.String LOGIN_WIN
The popup template window uuid, need this info to remove it when login ok

See Also:
Constant Field Values

FORCE_HTTPS

public static final java.lang.String FORCE_HTTPS
Force desktop to use https after successful authentication

See Also:
Constant Field Values

LOGIN_OK_DELAY

public static final java.lang.String LOGIN_OK_DELAY
Delay seconds to close the popup login window

See Also:
Constant Field Values

EVENTS

public static final java.lang.String EVENTS
ZK Events that have not been processed because of the Authentication exception

See Also:
Constant Field Values

AUTH

public static final java.lang.String AUTH
Spring Authentication object

See Also:
Constant Field Values
Constructor Detail

ZkAuthenticationEntryPoint

public ZkAuthenticationEntryPoint()
Method Detail

commence

public void commence(javax.servlet.http.HttpServletRequest request,
                     javax.servlet.http.HttpServletResponse response,
                     org.springframework.security.core.AuthenticationException authException)
              throws java.io.IOException,
                     javax.servlet.ServletException
Specified by:
commence in interface org.springframework.security.web.AuthenticationEntryPoint
Overrides:
commence in class org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint
Throws:
java.io.IOException
javax.servlet.ServletException

setLoginTemplateArg

public void setLoginTemplateArg(java.lang.String param,
                                java.lang.Object value)

The argument to be passed into the login window template (see getLoginTemplate()). If you did not specify own login window template, the system use the default one.

In login window template, you can customize it by passing arguments into it via this method. And you refer the parameter by specifying in the template window in EL with ${arg.xxx} or in <zscript> with arg.xxx.

If you don't specify your own login window template, you can still customize the default login window template by assign values to following parameters.

Parameters:
param - the parameter key to be passed into login template.
value - the parameter value to be passed into login template.

removeLoginTemplateArg

public void removeLoginTemplateArg(java.lang.String param)
Remove the specified login template parameter.

Parameters:
param - the login template parameter to be removed.

setLoginTemplateArgs

public void setLoginTemplateArgs(java.util.Map map)
Sets the login template window arguments Map.

Parameters:
map - the login template window arguments Map.

getLoginTemplateArgs

public java.util.Map getLoginTemplateArgs()
Return the login template window arguments Map.

Returns:
the login template window arguments Map.

setLoginTemplate

public void setLoginTemplate(java.lang.String templateURL)

Set the login template URL. You don't generally need to call this method. If you don't use own login window template, the system will use the default login window template.

The default login window template will embed the login form and pop up as a highlighted window. You can use setLoginTemplateArg(String, Object) to customize the arguments in a limit way. Also you can define your own login form (see LoginUrlAuthenticationEntryPoint.setLoginFormUrl(String)) and login OK page (see setLoginOKUrl(String)) if you like. Note that, the default login window template will post "onLogin" event to all root components of the page that triggers this login when it pop up for user to login. And then it will post "onLoginOK" event to all root components of the page that triggers this login if user is authenticated successfully. You can get the org.springframework.security.Authentication by calling Event.getData() of the "onLoginOK" event

If you want to define your own login window template, note that this class simply call Executions.createComponents(getLoginTemplate(), null, getLoginTemplateArgs()) when it needs an authentication.

Parameters:
templateURL - the login window template URL
See Also:
setLoginTemplateArg(String, Object), LoginUrlAuthenticationEntryPoint.setLoginFormUrl(String), setLoginOKUrl(String), setLoginOKDelay(int)

getLoginTemplate

public java.lang.String getLoginTemplate()
Returns the login template URL.

Returns:
the login template URL.

getLoginOKTemplate

public java.lang.String getLoginOKTemplate()
Returns the login OK Template URL.

Returns:
the login OK template

setLoginOKTemplate

public void setLoginOKTemplate(java.lang.String loginOKTemplate)

Set the login OK URL. You don't generally need to call this method. If you don't use own login ok template, the system will use the default login ok template. Note that this page will be shown in the pop up login window when login OK.

Parameters:
loginOKTemplate - the login OK template URL to set

getLoginOKUrl

public java.lang.String getLoginOKUrl()
Returns the login OK URL.

Returns:
the loginOK

setLoginOKUrl

public void setLoginOKUrl(java.lang.String loginOKUrl)
Set the login OK URL. This page will be shown in the login ok template when login OK.

Parameters:
loginOKUrl - the loginOK URL to set

getLoginFailUrl

public java.lang.String getLoginFailUrl()
Returns the login Fail URL.

Returns:
the loginFail url.

setLoginFailUrl

public void setLoginFailUrl(java.lang.String loginFailUrl)
Sets the login Fail URL. This page will be shown in the login ok template when login fail.

Parameters:
loginFailUrl - the login Fail URL to set

getLoginOKDelay

public int getLoginOKDelay()
Returns the delay seconds to close the login window after login OK(successfully). Value that equal to 0 means close immediately; seconds that less than 0 means do not close automatically. Default to 0.

Returns:
the delay seconds after login successfully

setLoginOKDelay

public void setLoginOKDelay(int seconds)
Sets the delay seconds to close the login window after login OK(successfully). Seconds that equal to 0 means close immediately; seconds that less than 0 means do not close automatically. Default to 0.

Parameters:
seconds - the delay seconds after login successufuly.

determineUrlToUseForThisRequest

protected java.lang.String determineUrlToUseForThisRequest(javax.servlet.http.HttpServletRequest request,
                                                           javax.servlet.http.HttpServletResponse response,
                                                           org.springframework.security.core.AuthenticationException exception)
Overrides:
determineUrlToUseForThisRequest in class org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint

paramtypememo
titleStringLogin Window Title
widthStringwindow width
heightStringwindow height

Copyright © 2005-2007 Potix Corporation. All Rights Reserved.