|
|
@@ -43,6 +43,7 @@ public class SecurityUserUtils { |
|
|
|
|
|
|
|
public static String token() { |
|
|
|
// header中获取用户token |
|
|
|
check(); |
|
|
|
String token = ServletUtils.getRequest().getHeader("th-token"); |
|
|
|
if (StringUtils.isEmpty(token)) { |
|
|
|
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "token不能为空"); |
|
|
@@ -57,6 +58,7 @@ public class SecurityUserUtils { |
|
|
|
*/ |
|
|
|
public static String username() { |
|
|
|
// header中获取用户token |
|
|
|
check(); |
|
|
|
String oUserJson = ServletUtils.getRequest().getHeader("o-user-json"); |
|
|
|
if (StringUtils.isEmpty(oUserJson)) { |
|
|
|
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "oUserJson不能为空"); |
|
|
@@ -67,4 +69,20 @@ public class SecurityUserUtils { |
|
|
|
return username; |
|
|
|
} |
|
|
|
|
|
|
|
public static void check() { |
|
|
|
String oUserJson = ServletUtils.getRequest().getHeader("o-user-json"); |
|
|
|
String json = EncryptUtil.decodeUTF8StringBase64(oUserJson); |
|
|
|
JSONObject jsonObject = JSON.parseObject(json); |
|
|
|
Integer isAble = jsonObject.getInteger("isAble"); |
|
|
|
Integer isExpire = jsonObject.getInteger("isExpire"); |
|
|
|
if (StringUtils.isNotNull(isAble) && StringUtils.isNotNull(isExpire)) { |
|
|
|
if (0 == isAble) { |
|
|
|
throw new ServiceException(JsonResult.OIDC_ERROR, "该账号已被禁用,请联系系统管理员"); |
|
|
|
} |
|
|
|
if (0 == isExpire) { |
|
|
|
throw new ServiceException(JsonResult.OIDC_ERROR, "系统有效期已过,请联系系统管理员"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |