|
|
|
@ -18,16 +18,7 @@
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
package com.arsdigita.ui.login;
|
|
|
|
package com.arsdigita.ui.login;
|
|
|
|
|
|
|
|
|
|
|
|
import com.arsdigita.bebop.BoxPanel;
|
|
|
|
import com.arsdigita.bebop.*;
|
|
|
|
import com.arsdigita.bebop.ColumnPanel;
|
|
|
|
|
|
|
|
import com.arsdigita.bebop.Container;
|
|
|
|
|
|
|
|
import com.arsdigita.bebop.ElementComponent;
|
|
|
|
|
|
|
|
import com.arsdigita.bebop.Form;
|
|
|
|
|
|
|
|
import com.arsdigita.bebop.FormData;
|
|
|
|
|
|
|
|
import com.arsdigita.bebop.FormProcessException;
|
|
|
|
|
|
|
|
import com.arsdigita.bebop.Label;
|
|
|
|
|
|
|
|
import com.arsdigita.bebop.PageState;
|
|
|
|
|
|
|
|
import com.arsdigita.bebop.SimpleContainer;
|
|
|
|
|
|
|
|
import com.arsdigita.bebop.event.FormInitListener;
|
|
|
|
import com.arsdigita.bebop.event.FormInitListener;
|
|
|
|
import com.arsdigita.bebop.event.FormProcessListener;
|
|
|
|
import com.arsdigita.bebop.event.FormProcessListener;
|
|
|
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
|
|
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
|
|
|
@ -36,10 +27,8 @@ import com.arsdigita.bebop.form.CheckboxGroup;
|
|
|
|
import com.arsdigita.bebop.form.Hidden;
|
|
|
|
import com.arsdigita.bebop.form.Hidden;
|
|
|
|
import com.arsdigita.bebop.form.Option;
|
|
|
|
import com.arsdigita.bebop.form.Option;
|
|
|
|
import com.arsdigita.bebop.form.Password;
|
|
|
|
import com.arsdigita.bebop.form.Password;
|
|
|
|
import com.arsdigita.bebop.form.Submit;
|
|
|
|
|
|
|
|
import com.arsdigita.bebop.form.TextField;
|
|
|
|
import com.arsdigita.bebop.form.TextField;
|
|
|
|
import com.arsdigita.bebop.parameters.EmailParameter;
|
|
|
|
import com.arsdigita.bebop.parameters.EmailParameter;
|
|
|
|
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
|
|
|
|
|
|
|
import com.arsdigita.bebop.parameters.StringParameter;
|
|
|
|
import com.arsdigita.bebop.parameters.StringParameter;
|
|
|
|
import com.arsdigita.bebop.parameters.URLParameter;
|
|
|
|
import com.arsdigita.bebop.parameters.URLParameter;
|
|
|
|
import com.arsdigita.kernel.Kernel;
|
|
|
|
import com.arsdigita.kernel.Kernel;
|
|
|
|
@ -60,24 +49,25 @@ import javax.security.auth.login.LoginException;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import org.apache.log4j.Logger;
|
|
|
|
import org.apache.log4j.Logger;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.net.URI;
|
|
|
|
|
|
|
|
import java.net.URISyntaxException;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* A Bebop form that accepts login and password from the user and attempts
|
|
|
|
* A Bebop form that accepts login and password from the user and attempts to
|
|
|
|
* to authenticate and then log in the user.
|
|
|
|
* authenticate and then log in the user.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Depending on security configuration it may generate a link to a NewUser
|
|
|
|
* Depending on security configuration it may generate a link to a NewUser
|
|
|
|
* registration form, where a new user may register itself. LoginServlet has
|
|
|
|
* registration form, where a new user may register itself. LoginServlet has to
|
|
|
|
* to ensure that this page is created appropriately and is available.
|
|
|
|
* ensure that this page is created appropriately and is available.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* According to documentation in r1230
|
|
|
|
* According to documentation in r1230 Simple SSO implementation: /ccm/register
|
|
|
|
* Simple SSO implementation: /ccm/register first tries to do SSO login,
|
|
|
|
* first tries to do SSO login, falling back to normal form-based login. Set
|
|
|
|
* falling back to normal form-based login.
|
|
|
|
* waf.sso_login=true only after you make sure webapp can *only* be accessed
|
|
|
|
* Set waf.sso_login=true only after you make sure webapp can *only* be accessed
|
|
|
|
|
|
|
|
* through the frontend webserver doing the authentication.
|
|
|
|
* through the frontend webserver doing the authentication.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* To make this work with Tomcat/mod_jk/Apache HTTPD:
|
|
|
|
* To make this work with Tomcat/mod_jk/Apache HTTPD: - use latest mod_jk
|
|
|
|
* - use latest mod_jk (tested with 1.2.15)
|
|
|
|
* (tested with 1.2.15) - add attribute Connector@tomcatAuthentication="false"
|
|
|
|
* - add attribute Connector@tomcatAuthentication="false" to JK definition
|
|
|
|
* to JK definition in server.xml
|
|
|
|
* in server.xml
|
|
|
|
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @author Roger Hsueh
|
|
|
|
* @author Roger Hsueh
|
|
|
|
* @author Michael Bryzek
|
|
|
|
* @author Michael Bryzek
|
|
|
|
@ -89,13 +79,14 @@ public class UserLoginForm extends Form
|
|
|
|
implements LoginConstants, FormInitListener,
|
|
|
|
implements LoginConstants, FormInitListener,
|
|
|
|
FormValidationListener, FormProcessListener {
|
|
|
|
FormValidationListener, FormProcessListener {
|
|
|
|
|
|
|
|
|
|
|
|
private static final Logger s_log =
|
|
|
|
private static final Logger s_log
|
|
|
|
Logger.getLogger(UserLoginForm.class);
|
|
|
|
= Logger.getLogger(UserLoginForm.class);
|
|
|
|
|
|
|
|
|
|
|
|
// package friendly static form name makes writing HttpUnitTest easier
|
|
|
|
// package friendly static form name makes writing HttpUnitTest easier
|
|
|
|
final static String FORM_NAME = "user-login";
|
|
|
|
final static String FORM_NAME = "user-login";
|
|
|
|
private CheckboxGroup m_isPersistent;
|
|
|
|
private CheckboxGroup m_isPersistent;
|
|
|
|
private Hidden m_timestamp;
|
|
|
|
private Hidden m_timestamp;
|
|
|
|
|
|
|
|
private SaveCancelSection m_saveCancelSection;
|
|
|
|
private Hidden m_returnURL;
|
|
|
|
private Hidden m_returnURL;
|
|
|
|
private TextField m_loginName;
|
|
|
|
private TextField m_loginName;
|
|
|
|
private Password m_password;
|
|
|
|
private Password m_password;
|
|
|
|
@ -167,7 +158,10 @@ public class UserLoginForm extends Form
|
|
|
|
LoginServlet.getCookiesExplainPageURL()));
|
|
|
|
LoginServlet.getCookiesExplainPageURL()));
|
|
|
|
add(cookiePanel);
|
|
|
|
add(cookiePanel);
|
|
|
|
|
|
|
|
|
|
|
|
add(new Submit(SUBMIT), ColumnPanel.CENTER | ColumnPanel.FULL_WIDTH);
|
|
|
|
//add(new Submit(SUBMIT), ColumnPanel.CENTER | ColumnPanel.FULL_WIDTH);
|
|
|
|
|
|
|
|
m_saveCancelSection = new SaveCancelSection(new SimpleContainer());
|
|
|
|
|
|
|
|
m_saveCancelSection.getSaveButton().setButtonLabel(LOGIN);
|
|
|
|
|
|
|
|
add(m_saveCancelSection);
|
|
|
|
|
|
|
|
|
|
|
|
if (securityConfig.getEnableQuestion()) {
|
|
|
|
if (securityConfig.getEnableQuestion()) {
|
|
|
|
add(new DynamicLink("login.userRegistrationForm.forgotPasswordLink",
|
|
|
|
add(new DynamicLink("login.userRegistrationForm.forgotPasswordLink",
|
|
|
|
@ -187,11 +181,10 @@ public class UserLoginForm extends Form
|
|
|
|
* Sets up the login form parameters
|
|
|
|
* Sets up the login form parameters
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private void setupLogin() {
|
|
|
|
private void setupLogin() {
|
|
|
|
SimpleContainer loginMessage =
|
|
|
|
SimpleContainer loginMessage
|
|
|
|
new SimpleContainer("subsite:loginPromptMsg",
|
|
|
|
= new SimpleContainer("subsite:loginPromptMsg",
|
|
|
|
LoginServlet.SUBSITE_NS_URI);
|
|
|
|
LoginServlet.SUBSITE_NS_URI);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Kernel.getConfig().emailIsPrimaryIdentifier()) {
|
|
|
|
if (Kernel.getConfig().emailIsPrimaryIdentifier()) {
|
|
|
|
loginMessage.setClassAttr("email");
|
|
|
|
loginMessage.setClassAttr("email");
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
@ -213,7 +206,7 @@ public class UserLoginForm extends Form
|
|
|
|
addInitListener(new ScreenNameInitListener((StringParameter) m_loginName.
|
|
|
|
addInitListener(new ScreenNameInitListener((StringParameter) m_loginName.
|
|
|
|
getParameterModel()));
|
|
|
|
getParameterModel()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_loginName.addValidationListener(new NotNullValidationListener());
|
|
|
|
//m_loginName.addValidationListener(new NotNullValidationListener());
|
|
|
|
add(m_loginName);
|
|
|
|
add(m_loginName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -265,6 +258,14 @@ public class UserLoginForm extends Form
|
|
|
|
|
|
|
|
|
|
|
|
FormData data = event.getFormData();
|
|
|
|
FormData data = event.getFormData();
|
|
|
|
PageState state = event.getPageState();
|
|
|
|
PageState state = event.getPageState();
|
|
|
|
|
|
|
|
if (m_saveCancelSection.getSaveButton().isSelected(state)) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//check if an email adress has been entered at all
|
|
|
|
|
|
|
|
final Object loginname = m_loginName.getValue(state);
|
|
|
|
|
|
|
|
if (loginname == null) {
|
|
|
|
|
|
|
|
data.addError(ERROR_NO_EMAIL);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
// check timestamp
|
|
|
|
// check timestamp
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
@ -289,6 +290,7 @@ public class UserLoginForm extends Form
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*
|
|
|
|
@ -301,6 +303,9 @@ public class UserLoginForm extends Form
|
|
|
|
final PageState state = event.getPageState();
|
|
|
|
final PageState state = event.getPageState();
|
|
|
|
final HttpServletRequest req = state.getRequest();
|
|
|
|
final HttpServletRequest req = state.getRequest();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Login:
|
|
|
|
|
|
|
|
if (m_saveCancelSection.getSaveButton().isSelected(state)) {
|
|
|
|
|
|
|
|
|
|
|
|
// Redirect to workspace or return URL, if specified.
|
|
|
|
// Redirect to workspace or return URL, if specified.
|
|
|
|
final String path = UI.getUserRedirectURL(req);
|
|
|
|
final String path = UI.getUserRedirectURL(req);
|
|
|
|
|
|
|
|
|
|
|
|
@ -308,16 +313,37 @@ public class UserLoginForm extends Form
|
|
|
|
|
|
|
|
|
|
|
|
throw new ReturnSignal(req, url);
|
|
|
|
throw new ReturnSignal(req, url);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//Cancel:
|
|
|
|
|
|
|
|
if (m_saveCancelSection.getCancelButton().isSelected(state)) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//redirect the user to the place they came from.
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
String refererURI = new URI(req.getHeader("referer")).getPath();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (refererURI.equals("/ccm/register/")) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final String path = UI.getRootPageURL(req);
|
|
|
|
|
|
|
|
throw new RedirectSignal(com.arsdigita.web.URL.there(req, path), true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new ReturnSignal(req, refererURI);
|
|
|
|
|
|
|
|
} catch (URISyntaxException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Logs in the user using the username, password, and "Remember this
|
|
|
|
* Logs in the user using the username, password, and "Remember this login?"
|
|
|
|
* login?" request stored in the given form event. Subclasses can
|
|
|
|
* request stored in the given form event. Subclasses can override this
|
|
|
|
* override this method or just one of the specific case handlers
|
|
|
|
* method or just one of the specific case handlers (onLoginSuccess,
|
|
|
|
* (onLoginSuccess, onBadPassword, onAccountNotFound, onLoginException).
|
|
|
|
* onBadPassword, onAccountNotFound, onLoginException).
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param event
|
|
|
|
* @param event
|
|
|
|
* @throws FormProcessException if there is an unexpected login error
|
|
|
|
* @throws FormProcessException if there is an unexpected login error
|
|
|
|
**/
|
|
|
|
*
|
|
|
|
|
|
|
|
*/
|
|
|
|
protected void loginUser(FormSectionEvent event)
|
|
|
|
protected void loginUser(FormSectionEvent event)
|
|
|
|
throws FormProcessException {
|
|
|
|
throws FormProcessException {
|
|
|
|
PageState state = event.getPageState();
|
|
|
|
PageState state = event.getPageState();
|
|
|
|
@ -354,9 +380,11 @@ public class UserLoginForm extends Form
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Executed when login succeeds. Default implementation does nothing.
|
|
|
|
* Executed when login succeeds. Default implementation does nothing.
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param event
|
|
|
|
* @param event
|
|
|
|
* @throws com.arsdigita.bebop.FormProcessException
|
|
|
|
* @throws com.arsdigita.bebop.FormProcessException
|
|
|
|
**/
|
|
|
|
*
|
|
|
|
|
|
|
|
*/
|
|
|
|
protected void onLoginSuccess(FormSectionEvent event)
|
|
|
|
protected void onLoginSuccess(FormSectionEvent event)
|
|
|
|
throws FormProcessException {
|
|
|
|
throws FormProcessException {
|
|
|
|
// do nothing
|
|
|
|
// do nothing
|
|
|
|
@ -375,14 +403,15 @@ public class UserLoginForm extends Form
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Executed when login fails with a bad password or when
|
|
|
|
* Executed when login fails with a bad password or when autoLoginOn is set
|
|
|
|
* autoLoginOn is set to false and the user doesn't exist.
|
|
|
|
* to false and the user doesn't exist. Default implementation marks
|
|
|
|
* Default implementation marks password parameter with an error
|
|
|
|
* password parameter with an error message.
|
|
|
|
* message.
|
|
|
|
*
|
|
|
|
* @param event
|
|
|
|
* @param event
|
|
|
|
* @param e
|
|
|
|
* @param e
|
|
|
|
* @throws com.arsdigita.bebop.FormProcessException
|
|
|
|
* @throws com.arsdigita.bebop.FormProcessException
|
|
|
|
**/
|
|
|
|
*
|
|
|
|
|
|
|
|
*/
|
|
|
|
protected void onLoginFail(FormSectionEvent event,
|
|
|
|
protected void onLoginFail(FormSectionEvent event,
|
|
|
|
LoginException e)
|
|
|
|
LoginException e)
|
|
|
|
throws FormProcessException {
|
|
|
|
throws FormProcessException {
|
|
|
|
@ -393,9 +422,10 @@ public class UserLoginForm extends Form
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Executed when login fails for an unrecognized user. Default
|
|
|
|
* Executed when login fails for an unrecognized user. Default
|
|
|
|
* implementation sets a flag so that the client is redirected to the
|
|
|
|
* implementation sets a flag so that the client is redirected to the new
|
|
|
|
* new user page (see the process() method code).
|
|
|
|
* user page (see the process() method code).
|
|
|
|
**/
|
|
|
|
*
|
|
|
|
|
|
|
|
*/
|
|
|
|
protected void onAccountNotFound(FormSectionEvent event,
|
|
|
|
protected void onAccountNotFound(FormSectionEvent event,
|
|
|
|
AccountNotFoundException e)
|
|
|
|
AccountNotFoundException e)
|
|
|
|
throws FormProcessException {
|
|
|
|
throws FormProcessException {
|
|
|
|
@ -416,7 +446,8 @@ public class UserLoginForm extends Form
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Executed when login fails for an unrecognized problem. Default
|
|
|
|
* Executed when login fails for an unrecognized problem. Default
|
|
|
|
* implementation logs the error and throws FormProcessException.
|
|
|
|
* implementation logs the error and throws FormProcessException.
|
|
|
|
**/
|
|
|
|
*
|
|
|
|
|
|
|
|
*/
|
|
|
|
protected void onLoginException(FormSectionEvent event,
|
|
|
|
protected void onLoginException(FormSectionEvent event,
|
|
|
|
LoginException e)
|
|
|
|
LoginException e)
|
|
|
|
throws FormProcessException {
|
|
|
|
throws FormProcessException {
|
|
|
|
@ -426,14 +457,13 @@ public class UserLoginForm extends Form
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Determines whether a persistent cookie is requested in the given
|
|
|
|
* Determines whether a persistent cookie is requested in the given form.
|
|
|
|
* form.
|
|
|
|
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return true if the specified formdata has a field named
|
|
|
|
* @return true if the specified formdata has a field named
|
|
|
|
* FORM_PERSISTENT_LOGIN_P whose value is equal to "1". If there
|
|
|
|
* FORM_PERSISTENT_LOGIN_P whose value is equal to "1". If there is no such
|
|
|
|
* is no such field in the form data, returns the specified default
|
|
|
|
* field in the form data, returns the specified default value.
|
|
|
|
* value.
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
*/
|
|
|
|
protected boolean getPersistentLoginValue(PageState state,
|
|
|
|
protected boolean getPersistentLoginValue(PageState state,
|
|
|
|
boolean defaultValue) {
|
|
|
|
boolean defaultValue) {
|
|
|
|
// Problem:
|
|
|
|
// Problem:
|
|
|
|
@ -453,11 +483,9 @@ public class UserLoginForm extends Form
|
|
|
|
|
|
|
|
|
|
|
|
if (persistentLoginValue instanceof String[]) {
|
|
|
|
if (persistentLoginValue instanceof String[]) {
|
|
|
|
value = ((String[]) persistentLoginValue)[0];
|
|
|
|
value = ((String[]) persistentLoginValue)[0];
|
|
|
|
}
|
|
|
|
} else if (persistentLoginValue instanceof String) {
|
|
|
|
else if (persistentLoginValue instanceof String) {
|
|
|
|
|
|
|
|
value = (String) persistentLoginValue;
|
|
|
|
value = (String) persistentLoginValue;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else {
|
|
|
|
|
|
|
|
value = "0";
|
|
|
|
value = "0";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|