Quellcode durchsuchen

更新oidc对接租户状态信息相关

tags/v1.0.2
xiaoying vor 1 Jahr
Ursprung
Commit
98edcc9a6d
2 geänderte Dateien mit 22 neuen und 1 gelöschten Zeilen
  1. +4
    -1
      tuoheng-common/tuoheng-common-core/src/main/java/com/tuoheng/common/core/utils/JsonResult.java
  2. +18
    -0
      tuoheng-common/tuoheng-common-core/src/main/java/com/tuoheng/common/core/utils/SecurityUserUtils.java

+ 4
- 1
tuoheng-common/tuoheng-common-core/src/main/java/com/tuoheng/common/core/utils/JsonResult.java Datei anzeigen

@@ -16,7 +16,10 @@ public class JsonResult<T> implements Serializable {
* 成功
*/
public static final int SUCCESS = 0;

/**
* 专用
*/
public static final int OIDC_ERROR = -2;
/**
* 失败
*/

+ 18
- 0
tuoheng-common/tuoheng-common-core/src/main/java/com/tuoheng/common/core/utils/SecurityUserUtils.java Datei anzeigen

@@ -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, "系统有效期已过,请联系系统管理员");
}
}
}

}

Laden…
Abbrechen
Speichern