| | |
| | | import org.springframework.ui.Model; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | import org.springframework.web.servlet.mvc.support.RedirectAttributes; |
| | | import org.springframework.web.servlet.view.RedirectView; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.ServletException; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.servlet.http.HttpSession; |
| | | |
| | | import java.io.IOException; |
| | | |
| | |
| | | * @throws Exception |
| | | */ |
| | | @GetMapping("/ssoLogin") |
| | | public String oaSsoLogin(HttpServletRequest request) throws IOException { |
| | | public String oaSsoLogin(HttpServletRequest request,HttpServletResponse response, RedirectAttributes redirectAttributes) throws IOException, ServletException { |
| | | String token; |
| | | try { |
| | | token = passwordFreeLoginService.ssoFreeLogin(request); |
| | | }catch (Exception e){ |
| | | throw new ServiceException("单点登录获取token失败:"+e.getMessage()); |
| | | } |
| | | // response.setHeader("tokenInfo",token); |
| | | // response.setCharacterEncoding("utf-8"); |
| | | // response.setContentType("application/json"); |
| | | request.setAttribute("tokenInfo",token); |
| | | //response.sendRedirect(ssoRedirectAddr); |
| | | return "forward:/sso"; |
| | | redirectAttributes.addFlashAttribute("tokenInfo",token); |
| | | return "redirect:"+ssoRedirectAddr; |
| | | } |
| | | |
| | | } |