a new servletfilter, which controls the caching-values in the http-header.\ra new...
[mir.git] / source / mir / core / ui / action / admin / AuthenticationAction.java
index 214eca8..10a7f06 100755 (executable)
  */
 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;
@@ -50,8 +42,6 @@ import mir.core.model.MirUser;
 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;
 
@@ -60,12 +50,11 @@ import org.apache.struts.action.ActionForward;
 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;
@@ -98,7 +87,7 @@ public class AuthenticationAction extends DispatchAction {
                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);
@@ -114,7 +103,7 @@ public class AuthenticationAction extends DispatchAction {
                //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){
                        
@@ -131,12 +120,13 @@ public class AuthenticationAction extends DispatchAction {
                        //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");    
        }
        
@@ -150,50 +140,6 @@ public class AuthenticationAction extends DispatchAction {
                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");
        }
 }