📄 contextmanager.java
字号:
package com.neusoft.sso;
import java.util.Set;
import javax.servlet.ServletContext;
/**************************************************
* NAME : ContextManager.java
* HISTORY
* 2007-08-15 shanc 创建文件
* 注意:这个类是个包访问权限的类,使用Sso组件的程序员,不建议了解该类的具体结构
*************************************************/
class ContextManager {
static boolean hasUser(ServletContext context,String paraName){
//获取其他所有平台的context,并遍历其中的Set
String[] otherNames = Global.getOthersNames();
for(int i = 0;i<otherNames.length;i++){
String otherName = otherNames[i];
ServletContext otherC = context.getContext("/"+otherName);
Set ssoUserSet = (Set)otherC.getAttribute(Global.SET_NAME);
if(ssoUserSet.contains(paraName))//已在别的应用中登录
return true;
}
return false;
}
static void clearContext(ServletContext context,String paraName){
//获取自身平台的Set,并清除Set中的paraName
Set selfUserSet = (Set)context.getAttribute(Global.SET_NAME);
selfUserSet.remove(paraName);
//获取其他所有平台的context,并清除Set中的paraName
String[] otherNames = Global.getOthersNames();
for(int i = 0;i<otherNames.length;i++){
String otherName = otherNames[i];
ServletContext otherC = context.getContext("/"+otherName);
Set ssoUserSet = (Set)otherC.getAttribute(Global.SET_NAME);
ssoUserSet.remove(paraName);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -