*/
package mir.core.ui.action.admin;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import mir.core.service.storage.UserService;
import mir.core.ui.action.DispatchAction;
import mir.core.ui.servlet.ServletConstants;
-import mir.util.StringRoutines;
-import mircoders.global.MirGlobal;
import multex.Failure;
import net.sf.hibernate.SessionFactory;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.DynaActionForm;
import org.apache.struts.action.RedirectingActionForward;
-import org.apache.struts.util.MessageResources;
/**
* AuthenticationAction
* @author idefix
- * @version $Id: AuthenticationAction.java,v 1.2 2003/09/10 20:58:27 idfx Exp $
+ * @version $Id: AuthenticationAction.java,v 1.3 2003/09/18 21:42:16 idfx Exp $
*/
public class AuthenticationAction extends DispatchAction {
private MirPropertiesConfiguration _configuration;
UserService userService =
new UserService((SessionFactory)context
.getAttribute(ServletConstants.SESSION_FACTORY));
- setLoginLanguages(context);
+
//try to retrieve user for the given values
MirUser mirUser = userService.loadUser(login, password);
//check if we have to redirect the user
String requestUri =
(String) session.getAttribute(ServletConstants.REDIRECT_ACTION);
-
+ System.out.println(requestUri);
if(requestUri != null && requestUri.indexOf("index") == -1
&& requestUri.indexOf("logon") == -1){
//construct a redirect
RedirectingActionForward actionForward =
new RedirectingActionForward(requestUri);
-
+ System.out.println("redirect");
//return the redirect
return actionForward;
}
//normal redirect to the startpage
+ System.out.println("success");
return actionMapping.findForward("success");
}
session.invalidate();
//return to the logon form
- return actionMapping.findForward("index");
- }
-
- private void setLoginLanguages(ServletContext context) throws ServletException {
- List loginLanguages =
- (List) context.getAttribute(ServletConstants.LOGIN_LANGUAGES);
- try {
- if (loginLanguages == null) {
- MessageResources messageResources =
- MessageResources.getMessageResources("bundles.adminlocal");
- MessageResources messageResources2 =
- MessageResources.getMessageResources("bundles.admin");
-
- List languages =
- StringRoutines.splitString(
- MirGlobal.config().getString("Mir.Login.Languages", "en"), ";");
-
- loginLanguages = new ArrayList();
- Iterator i = languages.iterator();
- while (i.hasNext()) {
- String code = (String) i.next();
- Locale locale = new Locale(code, "");
- String name = messageResources.getMessage(locale, "languagename");
-
- if (name == null) {
- name = messageResources2.getMessage(locale, "languagename");
- }
-
- if (name == null) {
- name = code;
- }
-
- Map record = new HashMap();
- record.put("name", name);
- record.put("code", code);
- loginLanguages.add(record);
- }
- context.setAttribute(ServletConstants.LOGIN_LANGUAGES,
- loginLanguages);
- context.setAttribute(ServletConstants.DEFAULT_LANGUAGE,
- _configuration.getString("Mir.Login.DefaultLanguage"));
- }
- } catch (Throwable t) {
- throw new ServletException(t.getMessage());
- }
+ return actionMapping.findForward("logon");
}
}