@Test public void submitCommandNotAuthenticated() throws XMPPException { ModelAndView mav = controller.submitCommand("foo", request, session); Assert.assertEquals("index", mav.getViewName()); Assert.assertNull(mav.getModel().get("authenticated")); }
@RequestMapping(value = "/{command}", method = RequestMethod.POST) public ModelAndView submitCommand(@PathVariable("command") String command, HttpServletRequest request, HttpSession session) throws XMPPException { ExtendedXMPPConnection client = (ExtendedXMPPConnection) session.getAttribute(SESSION_ATTRIBUTE); if (client == null) { return login(); } else if (!client.isConnected()) { return login("Disconnected from XMPP server, please log in again"); } else { @SuppressWarnings("unchecked") AdHocCommandData requestCommand = adHocCommandDataBuilder.build(request.getParameterMap()); requestCommand.setType(Type.set); requestCommand.setFrom(client.getUser()); requestCommand.setTo(client.getXMPPServiceDomain()); requestCommand.setNode("http: return sendRequestAndGenerateForm(command, client, requestCommand); } }
AdminConsoleController { @RequestMapping(value = "/{command}", method = RequestMethod.POST) public ModelAndView submitCommand(@PathVariable("command") String command, HttpServletRequest request, HttpSession session) throws XMPPException { ExtendedXMPPConnection client = (ExtendedXMPPConnection) session.getAttribute(SESSION_ATTRIBUTE); if (client == null) { return login(); } else if (!client.isConnected()) { return login("Disconnected from XMPP server, please log in again"); } else { @SuppressWarnings("unchecked") AdHocCommandData requestCommand = adHocCommandDataBuilder.build(request.getParameterMap()); requestCommand.setType(Type.set); requestCommand.setFrom(client.getUser()); requestCommand.setTo(client.getXMPPServiceDomain()); requestCommand.setNode("http: return sendRequestAndGenerateForm(command, client, requestCommand); } } }
AdminConsoleController { @RequestMapping(value = "/{command}", method = RequestMethod.POST) public ModelAndView submitCommand(@PathVariable("command") String command, HttpServletRequest request, HttpSession session) throws XMPPException { ExtendedXMPPConnection client = (ExtendedXMPPConnection) session.getAttribute(SESSION_ATTRIBUTE); if (client == null) { return login(); } else if (!client.isConnected()) { return login("Disconnected from XMPP server, please log in again"); } else { @SuppressWarnings("unchecked") AdHocCommandData requestCommand = adHocCommandDataBuilder.build(request.getParameterMap()); requestCommand.setType(Type.set); requestCommand.setFrom(client.getUser()); requestCommand.setTo(client.getXMPPServiceDomain()); requestCommand.setNode("http: return sendRequestAndGenerateForm(command, client, requestCommand); } } @Autowired  AdminConsoleController(XMPPTCPConnectionConfiguration connectionConfiguration); }
AdminConsoleController { @RequestMapping(value = "/{command}", method = RequestMethod.POST) public ModelAndView submitCommand(@PathVariable("command") String command, HttpServletRequest request, HttpSession session) throws XMPPException { ExtendedXMPPConnection client = (ExtendedXMPPConnection) session.getAttribute(SESSION_ATTRIBUTE); if (client == null) { return login(); } else if (!client.isConnected()) { return login("Disconnected from XMPP server, please log in again"); } else { @SuppressWarnings("unchecked") AdHocCommandData requestCommand = adHocCommandDataBuilder.build(request.getParameterMap()); requestCommand.setType(Type.set); requestCommand.setFrom(client.getUser()); requestCommand.setTo(client.getXMPPServiceDomain()); requestCommand.setNode("http: return sendRequestAndGenerateForm(command, client, requestCommand); } } @Autowired  AdminConsoleController(XMPPTCPConnectionConfiguration connectionConfiguration); @RequestMapping("/") ModelAndView index(HttpSession session); @RequestMapping(value = "/{command}", method = RequestMethod.GET) ModelAndView command(@PathVariable("command") String command, HttpSession session); @RequestMapping(value = "/{command}", method = RequestMethod.POST) ModelAndView submitCommand(@PathVariable("command") String command, HttpServletRequest request,
            HttpSession session); @RequestMapping(value = "/login", method = RequestMethod.POST) ModelAndView login(@RequestParam("username") String username, @RequestParam("password") String password,
            HttpSession session); @RequestMapping(value = "/logout") ModelAndView logout(HttpSession session); }
AdminConsoleController { @RequestMapping(value = "/{command}", method = RequestMethod.POST) public ModelAndView submitCommand(@PathVariable("command") String command, HttpServletRequest request, HttpSession session) throws XMPPException { ExtendedXMPPConnection client = (ExtendedXMPPConnection) session.getAttribute(SESSION_ATTRIBUTE); if (client == null) { return login(); } else if (!client.isConnected()) { return login("Disconnected from XMPP server, please log in again"); } else { @SuppressWarnings("unchecked") AdHocCommandData requestCommand = adHocCommandDataBuilder.build(request.getParameterMap()); requestCommand.setType(Type.set); requestCommand.setFrom(client.getUser()); requestCommand.setTo(client.getXMPPServiceDomain()); requestCommand.setNode("http: return sendRequestAndGenerateForm(command, client, requestCommand); } } @Autowired  AdminConsoleController(XMPPTCPConnectionConfiguration connectionConfiguration); @RequestMapping("/") ModelAndView index(HttpSession session); @RequestMapping(value = "/{command}", method = RequestMethod.GET) ModelAndView command(@PathVariable("command") String command, HttpSession session); @RequestMapping(value = "/{command}", method = RequestMethod.POST) ModelAndView submitCommand(@PathVariable("command") String command, HttpServletRequest request,
            HttpSession session); @RequestMapping(value = "/login", method = RequestMethod.POST) ModelAndView login(@RequestParam("username") String username, @RequestParam("password") String password,
            HttpSession session); @RequestMapping(value = "/logout") ModelAndView logout(HttpSession session); static final String SESSION_ATTRIBUTE; static final String SESSION_FIELD; static final Map<String, String> COMMANDS; }