Commit 3a508867 authored by Quxl's avatar Quxl

x

parent eae7c1d2
......@@ -24,6 +24,50 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
/**
* Example:
* <pre>
* @Controller
* @RequestMapping
* public class LoginController {
*
* @Autowired
* OAuthApi oAuthApi;
*
* @GetMapping
* private ModelAndView index() {
* OAuthConfig config = oAuthApi.getOAuthConfig();
* ModelAndView mav = new ModelAndView();
* mav.addObject("loginUrl", oAuthApi.getAuthorizationUrl()); //设置登陆授权URL, 用户可以在页面点击此URL,进入OAuth系统授权
* mav.addObject("config", config);
* mav.setViewName("index.html");
* return mav;
* }
*
* @GetMapping("toLogin")
* private void toLogin() {
* oAuthApi.doRedirectOAuthLogin(); //直接转到OAuth系统授权,和用户主动在页面点击授权URL效果一样,都是跳转到一样的地址
* }
*
* @RequestMapping(value="callback", method= {RequestMethod.GET, RequestMethod.POST})
* private ModelAndView doLogin() {
* oAuthApi.callback(); //授权成功后,授权系统通过重定向的方式回调业务系统,并附带授权参数信息,此代码用于解析授权系统的回调参数
* OAuthToken token = oAuthApi.getOAuthToken();
* ModelAndView mav = new ModelAndView();
* mav.addObject("token", token);
* mav.setViewName("system.html");
* return mav;
* }
*
* @RequestMapping(value="doLogout", method= {RequestMethod.GET, RequestMethod.POST})
* private ModelAndView doLogout(HttpServletResponse response) throws IOException {
* oAuthApi.removeOAuthToken();
* ModelAndView mav = new ModelAndView();
* mav.setViewName("redirect:/");
* return mav;
* }
*
* }
* </pre>
*
* SSO 权限校验接口, 权限获取和业务接口调用已经全部封装在接口默认方法中, 使用者只需实现此接口并实现接口中的抽象方法即可.
* 需要实现的抽象方法如下:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment