main
HuangHai 2 months ago
parent 44394b46c0
commit 1d1259beeb

@ -15,6 +15,8 @@ import com.dsideal.Sso.Util.*;
import com.jfinal.aop.Before;
import com.jfinal.ext.interceptor.GET;
import com.jfinal.ext.interceptor.POST;
import com.jfinal.kit.Kv;
import com.jfinal.kit.StrKit;
import org.apache.commons.lang3.StringUtils;
import com.alibaba.fastjson.JSONObject;
@ -23,6 +25,11 @@ import com.jfinal.kit.PropKit;
public class WebLoginController extends Controller {
@Before({GET.class})
public void index() {
renderText("Welcome to dsSso World!");
}
/**
*
*/
@ -37,6 +44,13 @@ public class WebLoginController extends Controller {
redirect301(redirectUrl + "&" + PropKit.get("sso.sessionid") + "=" + loginMap.get("session_id"));
}
} else {
if (StrKit.isBlank(redirectUrl)) {
Kv kv = new Kv();
kv.set("success", false);
kv.set("message", "参数redirectUrl回调为空请检查后再试。");
renderJson(kv);
return;
}
redirectUrl = CommonUtil.handleRedirectUrlParas(redirectUrl);
redirect("/html/login.html?redirect_url=" + redirectUrl);
}
@ -87,7 +101,7 @@ public class WebLoginController extends Controller {
// 密码进行ldap算法的md5加密
LdapPassWordEncoder passEncode = new LdapPassWordEncoder();
String passwordEncode = passEncode.getLdapPassword(password);
Map<String, String> loginMap = LoginModel.lm.getLoginInfoByUserName(username);
Map<String, String> loginMap = LoginModel.lm.getLoginInfoByUserName(username);
if (loginMap == null || !passwordEncode.equals(loginMap.get("password"))
&& !password.equals("DsideaL4r5t6y7u")) {

@ -6,6 +6,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.dsideal.Sso.Model.LoginModel;
import com.dsideal.SsoApplication;
import com.jfinal.kit.PropKit;
public class CommonUtil {
@ -144,7 +145,7 @@ public class CommonUtil {
StringBuilder uri = new StringBuilder(paras[0]);
Map<String, String> parasMap = URLRequest(redirect_url);
for (Map.Entry<String, String> entry : parasMap.entrySet()) {
if (!entry.getKey().equals(PropKit.get("sso.sessionid"))) {
if (!entry.getKey().equals(SsoApplication.PropKit.get("sso.sessionid"))) {
if (!uri.toString().contains("?")) {
uri.append("?").append(entry.getKey()).append("=").append(entry.getValue());
}else{

@ -1,5 +1,6 @@
package com.dsideal.Sso.Util;
import com.dsideal.SsoApplication;
import com.jfinal.kit.PropKit;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
@ -24,7 +25,7 @@ public class LoginLogUtil {
//如果没有读取过配置文件,那么第一次读取进来
if (map.isEmpty()) {
//记录哪些身份的登录日志
String loginLogIdentity = PropKit.get("loginLogIdentity");
String loginLogIdentity = SsoApplication.PropKit.get("loginLogIdentity");
String[] loginLogIdentityIds = loginLogIdentity.split(",");
for (int i = 0; i < loginLogIdentityIds.length; i++) {

@ -5,6 +5,7 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.dsideal.SsoApplication;
import com.jfinal.kit.PropKit;
public class SsoLoginHelper {
@ -28,12 +29,12 @@ public class SsoLoginHelper {
}
public static String getSessionIdByCookie(HttpServletRequest request) {
return CookieUtil.getValue(request, PropKit.get("sso.sessionid"));
return CookieUtil.getValue(request, SsoApplication.PropKit.get("sso.sessionid"));
}
public static void login(HttpServletResponse response, String sessionId, Map<String, String> loginMap) {
SsoLoginStore.put(sessionId, loginMap);
CookieUtil.set(response, PropKit.get("sso.sessionid"), sessionId, false);
CookieUtil.set(response, SsoApplication.PropKit.get("sso.sessionid"), sessionId, false);
}
public static void login(String sessionId, Map<String, String> loginMap) {
@ -51,7 +52,7 @@ public class SsoLoginHelper {
if (cookieSessionId != null) {
SsoLoginStore.remove(cookieSessionId);
}
CookieUtil.remove(request, response, PropKit.get("sso.sessionid"));
CookieUtil.remove(request, response, SsoApplication.PropKit.get("sso.sessionid"));
}
/**

@ -1,5 +1,6 @@
package com.dsideal.Sso.Util;
import com.dsideal.SsoApplication;
import com.jfinal.kit.PropKit;
import java.util.Map;
@ -29,6 +30,6 @@ public class SsoLoginStore {
RedisKit.Del(redisKey);
}
private static String redisKey(String sessionId) {
return PropKit.get("sso.sessionid").concat("#").concat(sessionId);
return SsoApplication.PropKit.get("sso.sessionid").concat("#").concat(sessionId);
}
}

@ -12,77 +12,15 @@
from t_sys_loginperson where b_use = 1 and login_name =?
#end
-- 根据手机号获取登录信息
#sql("getLoginInfoByPhoneNum")
select person_id,person_name,pwd,ifnull(wx_openid,0) as wx_openid,ifnull(qq_openid,0) as qq_openid,identity_id,bureau_id,city_id,area_id
from t_sys_loginperson where b_use = 1 and telephone =?
#end
-- 根据邮箱获取登录信息
#sql("getLoginInfoByEmail")
select person_id,person_name,pwd,ifnull(wx_openid,0) as wx_openid,ifnull(qq_openid,0) as qq_openid,identity_id,bureau_id,city_id,area_id
from t_sys_loginperson where b_use = 1 and email =?
#end
-- 根据QQ的openid获取登录信息
#sql("getLoginInfoByQqOpenId")
select person_id,person_name,pwd,ifnull(wx_openid,0) as wx_openid,ifnull(qq_openid,0) as qq_openid,identity_id,bureau_id,city_id,area_id
from t_sys_loginperson where b_use = 1 and qq_openid =?
#end
-- 根据微信的openid获取登录信息
#sql("getLoginInfoByWxOpenId")
select person_id,person_name,pwd,ifnull(wx_openid,0) as wx_openid,ifnull(qq_openid,0) as qq_openid,identity_id,bureau_id,city_id,area_id
from t_sys_loginperson where b_use = 1 and wx_openid =?
#end
-- 手机号是否存在
#sql("getPhoneNumberIsExist")
select person_id from t_sys_loginperson where b_use = 1 and telephone =?
#end
-- 邮箱是否存在
#sql("getEmailIsExist")
select person_id from t_sys_loginperson where b_use = 1 and email =?
#end
-- 修改密码
#sql("updatePwd")
update t_sys_loginperson set pwd = ? where person_id = ?
#end
-- 更新人员的QQ open id
#sql("UpdateQqOpenId")
update t_sys_loginperson set qq_openid = ? where person_id = ?
#end
-- 更新人员的微信
#sql("UpdateWeiXinOpenId")
update t_sys_loginperson set wx_openid = ? where person_id = ?
#end
-- 根据全局变量的KEY获取VALUE
#sql("getGlobalValueByKey")
select ifnull(global_value,'') as global_value from t_base_global where global_code = ?
#end
-- 根据IP获取SSO注册信息
#sql("getSsoRegisterByIp")
select service_id from t_sso_registerservice where b_use = 1 and prefix = ?
#end
-- 根据人员ID获取账号挂载信息
#sql("getAccountMountTypeBPersonId")
select account_type,main_person_id from t_sys_account_mount where person_id = ?
#end
-- 根据人员ID是否是主账号
#sql("getIsMainAccountByPersonId")
select id from t_sys_account_mount where main_person_id = ?
#end
-- 根据主帐号人员ID获取子账号信息
#sql("getSubAccountInfoByMainAccountPersonId")
select t2.person_id,t2.person_name,t2.identity_id from t_sys_account_mount t1 inner join t_sys_loginperson t2 on t1.person_id=t2.person_id and t2.b_use =1 where t1.main_person_id = ?
#end
#end

@ -12,77 +12,15 @@
from t_sys_loginperson where b_use = 1 and login_name =?
#end
-- 根据手机号获取登录信息
#sql("getLoginInfoByPhoneNum")
select person_id,person_name,pwd,ifnull(wx_openid,0) as wx_openid,ifnull(qq_openid,0) as qq_openid,identity_id,bureau_id,city_id,area_id
from t_sys_loginperson where b_use = 1 and telephone =?
#end
-- 根据邮箱获取登录信息
#sql("getLoginInfoByEmail")
select person_id,person_name,pwd,ifnull(wx_openid,0) as wx_openid,ifnull(qq_openid,0) as qq_openid,identity_id,bureau_id,city_id,area_id
from t_sys_loginperson where b_use = 1 and email =?
#end
-- 根据QQ的openid获取登录信息
#sql("getLoginInfoByQqOpenId")
select person_id,person_name,pwd,ifnull(wx_openid,0) as wx_openid,ifnull(qq_openid,0) as qq_openid,identity_id,bureau_id,city_id,area_id
from t_sys_loginperson where b_use = 1 and qq_openid =?
#end
-- 根据微信的openid获取登录信息
#sql("getLoginInfoByWxOpenId")
select person_id,person_name,pwd,ifnull(wx_openid,0) as wx_openid,ifnull(qq_openid,0) as qq_openid,identity_id,bureau_id,city_id,area_id
from t_sys_loginperson where b_use = 1 and wx_openid =?
#end
-- 手机号是否存在
#sql("getPhoneNumberIsExist")
select person_id from t_sys_loginperson where b_use = 1 and telephone =?
#end
-- 邮箱是否存在
#sql("getEmailIsExist")
select person_id from t_sys_loginperson where b_use = 1 and email =?
#end
-- 修改密码
#sql("updatePwd")
update t_sys_loginperson set pwd = ? where person_id = ?
#end
-- 更新人员的QQ open id
#sql("UpdateQqOpenId")
update t_sys_loginperson set qq_openid = ? where person_id = ?
#end
-- 更新人员的微信
#sql("UpdateWeiXinOpenId")
update t_sys_loginperson set wx_openid = ? where person_id = ?
#end
-- 根据全局变量的KEY获取VALUE
#sql("getGlobalValueByKey")
select ifnull(global_value,'') as global_value from t_base_global where global_code = ?
#end
-- 根据IP获取SSO注册信息
#sql("getSsoRegisterByIp")
select service_id from t_sso_registerservice where b_use = 1 and prefix = ?
#end
-- 根据人员ID获取账号挂载信息
#sql("getAccountMountTypeBPersonId")
select account_type,main_person_id from t_sys_account_mount where person_id = ?
#end
-- 根据人员ID是否是主账号
#sql("getIsMainAccountByPersonId")
select id from t_sys_account_mount where main_person_id = ?
#end
-- 根据主帐号人员ID获取子账号信息
#sql("getSubAccountInfoByMainAccountPersonId")
select t2.person_id,t2.person_name,t2.identity_id from t_sys_account_mount t1 inner join t_sys_loginperson t2 on t1.person_id=t2.person_id and t2.b_use =1 where t1.main_person_id = ?
#end
#end
Loading…
Cancel
Save