|
|
@@ -42,6 +42,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不能为空"); |
|
|
@@ -56,6 +57,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不能为空"); |
|
|
@@ -66,4 +68,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, "系统有效期已过,请联系系统管理员"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |