package com.gta.sso.demo.controller;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import com.alibaba.fastjson.JSONObject;
import com.gta.platform.cache.service.ICacheService;
import com.gta.platform.cas.client.sso.controller.PathUtils;
import com.gta.platform.cas.client.util.CasConfigurationConstants;
import com.gta.platform.configuration.util.ClientIsOutside;
import com.gta.platform.configuration.util.ConfigurationConstants;
import com.gta.platform.configuration.util.ConfigurationUtils;
import com.gta.platform.util.HttpClientUtils;
@RestController
public class HelloContorller {
private ICacheService cacheService;
// 1
@RequestMapping(value = "/index")
public String ok() {
//进入主页
return "index3";
}
@RequestMapping(value = "/nologin")
public String nologin(HttpServletRequest request, HttpServletResponse response) throws Exception {
return "nologin";
}
@RequestMapping(value = "/logout")
public @ResponseBody void logout(HttpServletRequest request, HttpServletResponse response) throws Exception {
// online user number-1
WebApplicationContext context = WebApplicationContextUtils
.getRequiredWebApplicationContext(request.getServletContext());
cacheService = (ICacheService) context.getBean(ICacheService.class);
if (cacheService.get("casUserNumbers") != null) {
Long un = Long.parseLong(cacheService.get("casUserNumbers")) - 1;
cacheService.setCastime("casUserNumbers", un + "");
}
String userId = "";
if (request.getSession().getAttribute("userId") != null) {
userId = request.getSession().getAttribute("userId").toString();
}
if (!StringUtils.isEmpty(userId)) {
cacheService.delExceed(userId + ClientIsOutside.get() +"expireTime");
cacheService.delExceed(userId + ClientIsOutside.get() + "logouturi");
}
String uri = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
+ request.getContextPath() + "/index";
StringBuilder str = new StringBuilder();
str.append(ConfigurationUtils.getMustExistsConfig(ConfigurationConstants.PLATFORM_CAS_SERVER_URL_PREFIX))
.append("/logout?service=").append(uri);
String logoutc = str.toString();
request.getSession().removeAttribute("userId");
request.getSession().invalidate();
response.sendRedirect(logoutc);
}
}
CAS集成手册(java版
需积分: 11 152 浏览量
2017-05-22
19:17:51
上传
评论
收藏 169KB RAR 举报
buddha17
- 粉丝: 37
- 资源: 56
最新资源
- SRS-CentOS7-x86-64-5.0-r1.zip
- 全文检索使用ElasticSearch实现全文检索的详细说明和实践探索
- 基于matlab主成分分析图像压缩重建系统代码14
- C语言《基于AT89C52单片机搭建的PID直流电机控制程序,主要用于Proteus电路仿真》+源代码
- C++《基于规划和汽车动力学的自动驾驶项目仿真(基于ROS的自动驾驶项目仿真,使用DWA路径规划算法和双PID控制器)》+源代码
- vos3000客户端2.1.7.03、2.1.8.05、2.1.9.07
- c++《用于船舶控制方法研究的3D船舶运动仿真软件》+源代码
- globalmapper24
- Python 小游戏 (贪吃蛇、五子棋、扫雷、俄罗斯方块)源码.zip
- Map data that can be used for 2D raster map path planning
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈