IndexEndpoint.java 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package org.maxkey.web.endpoint;
  2. import org.maxkey.config.ApplicationConfig;
  3. import org.maxkey.constants.PASSWORDSETTYPE;
  4. import org.maxkey.domain.UserInfo;
  5. import org.maxkey.web.WebConstants;
  6. import org.maxkey.web.WebContext;
  7. import org.slf4j.Logger;
  8. import org.slf4j.LoggerFactory;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.beans.factory.annotation.Qualifier;
  11. import org.springframework.stereotype.Controller;
  12. import org.springframework.web.bind.annotation.RequestMapping;
  13. import org.springframework.web.servlet.ModelAndView;
  14. /**
  15. * Index
  16. * @author Crystal.Sea
  17. *
  18. */
  19. @Controller
  20. public class IndexEndpoint {
  21. private static Logger _logger = LoggerFactory.getLogger(IndexEndpoint.class);
  22. @Autowired
  23. @Qualifier("applicationConfig")
  24. ApplicationConfig applicationConfig;
  25. @RequestMapping(value={"/forwardindex"})
  26. public ModelAndView forwardindex() {
  27. _logger.debug("IndexEndpoint /forwardindex.");
  28. ModelAndView modelAndView=new ModelAndView();
  29. Integer passwordSetType=(Integer)WebContext.getSession().getAttribute(WebConstants.CURRENT_LOGIN_USER_PASSWORD_SET_TYPE);
  30. if(passwordSetType==PASSWORDSETTYPE.PASSWORD_NORMAL){
  31. if(applicationConfig.getLoginConfig().getDefaultUri()!=null&&
  32. !applicationConfig.getLoginConfig().getDefaultUri().equals("")){
  33. if(applicationConfig.getLoginConfig().getDefaultUri().startsWith("http")){
  34. return WebContext.redirect(applicationConfig.getLoginConfig().getDefaultUri());
  35. }
  36. return WebContext.forward(applicationConfig.getLoginConfig().getDefaultUri());
  37. }
  38. modelAndView.setViewName("index");
  39. return modelAndView;
  40. }
  41. UserInfo userInfo=WebContext.getUserInfo();
  42. modelAndView.addObject("model", userInfo);
  43. if(passwordSetType==PASSWORDSETTYPE.PASSWORD_EXPIRED){
  44. modelAndView.setViewName("passwordExpired");
  45. return modelAndView;
  46. }else if(passwordSetType==PASSWORDSETTYPE.INITIAL_PASSWORD||
  47. passwordSetType==PASSWORDSETTYPE.MANAGER_CHANGED_PASSWORD){
  48. modelAndView.setViewName("passwordInitial");
  49. return modelAndView;
  50. }
  51. return new ModelAndView("index");
  52. }
  53. @RequestMapping(value={"/index"})
  54. public ModelAndView home() {
  55. _logger.debug("IndexEndpoint /index.");
  56. if(applicationConfig.getLoginConfig().getDefaultUri()!=null&&
  57. !applicationConfig.getLoginConfig().getDefaultUri().equals("") ){
  58. return WebContext.redirect(applicationConfig.getLoginConfig().getDefaultUri());
  59. }
  60. return new ModelAndView("index");
  61. }
  62. @RequestMapping(value={"/"})
  63. public ModelAndView index() {
  64. _logger.debug("IndexEndpoint /.");
  65. return new ModelAndView("index");
  66. }
  67. }