CAS Logout 通知所有登录客户端销毁Session


具体通知由org.jasig.cas.authentication.principal.AbstractWebApplicationService发出。logOutOfService方法生成发送消息,然后由org.jasig.cas.util.HttpClient的sendMessageToEndPoint方法发出。
public boolean sendMessageToEndPoint(final String url, final String message) {
HttpURLConnection connection = null;
BufferedReader in = null;
try {
if (log.isDebugEnabled()) {
log.debug("Attempting to access " + url);
}
final URL logoutUrl = new URL(url);
final String output = "logoutRequest=" + URLEncoder.encode(message, "UTF-8");

connection = (HttpURLConnection) logoutUrl.openConnection();
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setReadTimeout(this.readTimeout);
connection.setConnectTimeout(this.connectionTimeout);
connection.setRequestProperty("Content-Length", ""
+ Integer.toString(output.getBytes().length));
connection.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");
final DataOutputStream printout = new DataOutputStream(connection
.getOutputStream());
printout.writeBytes(output);
printout.flush();
printout.close();

in = new BufferedReader(new InputStreamReader(connection
.getInputStream()));

while (in.readLine() != null) {
// nothing to do
}

if (log.isDebugEnabled()) {
log.debug("Finished sending message to" + url);
}
return true;
} catch (final Exception e) {
log.error(e,e);
return false;
} finally {
if (in != null) {
try {
in.close();
} catch (final IOException e) {
// can't do anything
}
}
if (connection != null) {
connection.disconnect();
}
}
}

 

 

http://blog.csdn.net/redstarofsleep/article/details/51190407

http://blog.csdn.net/lovesummerforever/article/details/36386207

http://zhenkm0507.iteye.com/blog/546785

http://www.cnblogs.com/wangyang108/p/5842275.html

http://dinguangx.iteye.com/blog/1845119

http://libinchinabj.iteye.com/blog/2178155

CAS4.2单点登录如何配置多个系统登录一次和退出到登录页问题 200

1、我用CAS4.2搭建了cas服务端,客户端是3.4.1版本2、现在服务端配置好了,也可以通过我配置的客户端系统访问和查询数据库登录3、问题:我配置了两个cas系统castest1和castest2,两个系统serverName分别配置为hhaip-cas1.com和hhaip-cas2.com,现在我访问castest1且登录成功,然后同一浏览器访问castest2还是跳转到登录页面,预期应该直接跳转到我访问的页面才是4、问题2:我想退出到登录页,但是我每次都退出到我设置的那个链接,且打开浏览器新标签访问我这个系统竟然不会跳转到登录页而是直接跳转到我的系统页面,即:我可能没有退出成功,下图是我的退出URL和客户端web.xml配置。5、注意我的cas-server是4.2版本和老版本差别很大,请大家不要复制其他的代码回答问题。

最佳答案
 
对于cas4.0在cas-server.xml中搜索logoutAction,将${cas.logout.followServiceRedirects:false}中的false改成true,如下:
<bean id="logoutAction" class="org.jasig.cas.web.flow.LogoutAction"
p:servicesManager-ref="servicesManager"
p:followServiceRedirects="${cas.logout.followServiceRedirects:true}"/>
至于cas4.2,cas-server.xml中少了很多东西,把这三行放到最后试试
posted @ 2017-10-25 23:35  采姑娘的蘑菇  阅读(7749)  评论(0编辑  收藏  举报