Class SecurityContext
java.lang.Object
com.elitesland.ystdms.sys.security.SecurityContext
Security 上下文工具类
提供从 JWT Token 中获取用户信息的能力,以及通过 Feign 获取扩展信息
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidclear()getAllOu()获取所有公司信息static <T> Tstatic SysEmployeeDTO获取当前登录用户的员工信息static SysOrgRespRpcDTO获取当前用户所属的组织信息获取当前用户所属的公司信息static StringgetDept()获取部门static SysEmployeeDTOgetEmployee(String username) 获取指定用户的员工信息static SysEmployeeDTOgetEmployeeByUserId(UUID userId) 根据 userId 获取员工信息static org.springframework.security.oauth2.jwt.JwtgetJwt()static SysOrgRespRpcDTO获取指定ID的组织信息getRoles()获取角色列表static Stringstatic String获取Token类型static String获取用户ID(从JWT的subject中获取)static String获取用户名static boolean判断当前是否已认证(有有效的JWT)static voidsetJwt(org.springframework.security.oauth2.jwt.Jwt jwt) static void设置 SecurityContextService 实例 通过配置类手动调用
-
Constructor Details
-
SecurityContext
public SecurityContext()
-
-
Method Details
-
setSecurityContextService
设置 SecurityContextService 实例 通过配置类手动调用 -
setJwt
public static void setJwt(org.springframework.security.oauth2.jwt.Jwt jwt) -
getJwt
public static org.springframework.security.oauth2.jwt.Jwt getJwt() -
clear
public static void clear() -
getSubject
-
getUserId
获取用户ID(从JWT的subject中获取) -
getUsername
获取用户名 -
getDept
获取部门 -
getRoles
获取角色列表 -
getTokenType
获取Token类型 -
isAuthenticated
public static boolean isAuthenticated()判断当前是否已认证(有有效的JWT) -
getClaim
-
getCurrentEmployee
获取当前登录用户的员工信息- Returns:
- 员工信息,如果未登录或查询失败则返回 null
-
getEmployee
获取指定用户的员工信息- Parameters:
username- 用户名- Returns:
- 员工信息,如果查询失败则返回 null
-
getEmployeeByUserId
根据 userId 获取员工信息 -
getCurrentOrg
获取当前用户所属的组织信息- Returns:
- 组织信息,如果未登录或查询失败则返回 null
-
getOrg
获取指定ID的组织信息- Parameters:
orgId- 组织ID- Returns:
- 组织信息,如果查询失败则返回 null
-
getCurrentOu
获取当前用户所属的公司信息- Returns:
- 公司信息列表,如果未登录或查询失败则返回 null
-
getAllOu
获取所有公司信息- Returns:
- 公司信息列表,如果查询失败则返回 null
-