Class MainApplicationController

  • All Implemented Interfaces:
    org.springframework.beans.factory.InitializingBean

    @RestController
    public class MainApplicationController
    extends java.lang.Object
    implements org.springframework.beans.factory.InitializingBean
    • Field Detail

      • httpSession

        @Autowired
        private javax.servlet.http.HttpSession httpSession
      • passwordEncoder

        @Autowired
        private org.springframework.security.crypto.password.PasswordEncoder passwordEncoder
      • rememberMeServices

        @Qualifier("userRememberMeServices")
        @Autowired
        private org.springframework.security.web.authentication.rememberme.PersistentTokenBasedRememberMeServices rememberMeServices
    • Constructor Detail

      • MainApplicationController

        public MainApplicationController()
    • Method Detail

      • loginHandler

        @PostMapping(value="/api/v1/authenticate",
                     consumes="application/x-www-form-urlencoded")
        @ResponseBody
        public org.springframework.http.ResponseEntity<?> loginHandler​(@RequestParam
                                                                       java.lang.String username,
                                                                       @RequestParam
                                                                       java.lang.String password,
                                                                       @RequestParam(value="remember-me-user",required=false)
                                                                       boolean rememberMe,
                                                                       javax.servlet.http.HttpServletRequest request,
                                                                       javax.servlet.http.HttpServletResponse response)
        Handles the login request.

        This method handles the login request and authenticates the user using the provided username and password. It also provides an option to remember the user by setting the rememberMe flag to true. The request and response objects are used to retrieve and set the necessary information for the authentication process.

        Parameters:
        username - The username of the user.
        password - The password of the user.
        rememberMe - A boolean flag indicating whether to remember the user or not (optional).
        request - The HttpServletRequest object containing the request information.
        response - The HttpServletResponse object used to set the response information.
        Returns:
        A ResponseEntity object representing the HTTP response.
      • logoutHandler

        @PostMapping("/api/v1/logout")
        @ResponseBody
        public org.springframework.http.ResponseEntity<?> logoutHandler​(javax.servlet.http.HttpServletRequest request,
                                                                        javax.servlet.http.HttpServletResponse response)
        This is the entry point for user logout
        Parameters:
        request - http servlet request
        response - http servlet response
        Returns:
        HTTP response
      • templateHandler

        @RequestMapping("/{site:^(?!sock).+$}/**/*.html")
        @ResponseBody
        public org.springframework.http.ResponseEntity<?> templateHandler​(@PathVariable("site")
                                                                          java.lang.String site,
                                                                          java.security.Principal principal,
                                                                          @CookieValue(name="i18next",required=false)
                                                                          java.lang.String lang,
                                                                          javax.servlet.http.HttpServletRequest request)
        This is entrypoint for HTTP-requests from the clients, where it loads a HTML-template from filesystem.
        Parameters:
        site - this is identification for a folder in /MSM2/www/{site}, except for "sock" as this was used for WebSockets
        principal - this is keep authorization data for the request
        lang - this is cookie value for a language code
        request - http servlet request
        Returns:
        response as valid HTML
      • afterPropertiesSet

        public void afterPropertiesSet()
        Specified by:
        afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean