提交 1c179f68 authored 作者: husishuai's avatar husishuai

新增注释

上级 54fa72fc
......@@ -47,12 +47,13 @@ import java.util.*;
public class SSOSeraphAuthenticator extends DefaultAuthenticator {
// jira服务中的rest请求地址前缀
private static final String BASE_URL = "http://192.168.1.113:8080/rest/api/2";
// 管理员的用户密码拼接后生成的base64加密串。格式: base64(账号:密码)
private static final String AUTHORIZATION_HEADER = "Basic cm9vdDpBZG1pbkAxMjM="; // Replace with your base64 encoded auth header
// 本地缓存(客户要求需要加缓存),过期时间为一天
// 本地缓存,过期时间为一天
private static final TimedCache<Object, Object> GROUP_NAME_CACHE = CacheUtil.newTimedCache((60 * 60 * 24 * 1000L));
// 日志
private static final Logger log = LoggerFactory.getLogger(SSOSeraphAuthenticator.class);
private EventPublisher eventPublisher;
......@@ -61,8 +62,39 @@ public class SSOSeraphAuthenticator extends DefaultAuthenticator {
public SSOSeraphAuthenticator() {
}
/**
* 登出
* @param httpServletRequest
* @param httpServletResponse
* @return
* @throws AuthenticatorException
*/
@Override
public boolean logout(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws AuthenticatorException {
System.out.println("logout....");
return super.logout(httpServletRequest, httpServletResponse);
}
/**
* 登录
* @param httpServletRequest
* @param httpServletResponse
* @param username
* @param password
* @param setRememberMeCookie
* @return
* @throws AuthenticatorException
*/
@Override
public boolean login(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, String username, String password, boolean setRememberMeCookie) throws AuthenticatorException {
// 登出时请求的地址 http://ip:port/login.html?isLogout=true
String isLogout = httpServletRequest.getParameter("isLogout");
System.out.println("isLogout = " + isLogout);
if (isLogout.equals("true")) {
System.out.println("开始退出...");
this.logout(httpServletRequest, httpServletResponse);
}else {
System.out.println("开始登录...");
// jira请求标识
httpServletRequest.setAttribute("com.atlassian.confluence.login.direct", true);
......@@ -155,6 +187,8 @@ public class SSOSeraphAuthenticator extends DefaultAuthenticator {
// 用户名及密码登录校验
return this.doLogin(httpServletRequest, httpServletResponse, username, password, setRememberMeCookie,false);
}
}
return false;
}
......@@ -397,7 +431,7 @@ public class SSOSeraphAuthenticator extends DefaultAuthenticator {
* 给组添加应用权限
*/
private void addGroupApplicationRole(String groupName) {
// 获取应用程序授权信息
// 获取应用程序授权信息(包含原本已授权的信息)
HashMap<String, List<String>> applicationRole = getApplicationRole();
System.out.println("addGroupApplicationRole - applicationRole: " + applicationRole);
List<String> groups = applicationRole.get("groups");
......@@ -405,7 +439,7 @@ public class SSOSeraphAuthenticator extends DefaultAuthenticator {
if (!groups.contains(groupName)) {
groups.add(groupName);
}
// 原本默认的组信息
List<String> defaultGroups = applicationRole.get("defaultGroups");
// 创建请求对象
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论