1、主要解决获取当前用户信息等问题,使用AuthUtil来进行获取,对生成token等信息进行了修改增加。
| | |
| | | String roleName = Func.toStr(claims.get(AuthUtil.ROLE_NAME)); |
| | | String userName = Func.toStr(claims.get(AuthUtil.USER_NAME)); |
| | | String nickName = Func.toStr(claims.get(AuthUtil.NICK_NAME)); |
| | | String tenantName = Func.toStr(claims.get("tenantName")); |
| | | String email = Func.toStr(claims.get("email")); |
| | | String deptName = Func.toStr(claims.get("deptName")); |
| | | String secretGrade = Func.toStr(claims.get("secretGrade")); |
| | | Kv detail = Kv.create().setAll((Map<? extends String, ?>) claims.get(AuthUtil.DETAIL)); |
| | | BladeUser bladeUser = new BladeUser(); |
| | | bladeUser.setClientId(clientId); |
| | |
| | | bladeUser.setRoleName(roleName); |
| | | bladeUser.setUserName(userName); |
| | | bladeUser.setNickName(nickName); |
| | | detail.put("tenantName",tenantName); |
| | | detail.put("deptName",deptName); |
| | | detail.put("email",email); |
| | | detail.put("secretGrade",secretGrade); |
| | | bladeUser.setDetail(detail); |
| | | return bladeUser; |
| | | } |
| | |
| | | */ |
| | | private final String tenantId; |
| | | /** |
| | | * 租户名称 |
| | | */ |
| | | private String tenantName; |
| | | /** |
| | | * 第三方认证ID |
| | | */ |
| | | private final String oauthId; |
| | |
| | | * 部门id |
| | | */ |
| | | private final String deptId; |
| | | /** |
| | | * 部门名称 |
| | | */ |
| | | private String deptName; |
| | | /** |
| | | * 岗位id |
| | | */ |
| | |
| | | * 用户密级 |
| | | */ |
| | | private String secretGrade; |
| | | /** |
| | | * 邮件 |
| | | */ |
| | | private String email; |
| | | |
| | | /** |
| | | * 密码策略修改状态 |
| | |
| | | private Long strategyUpdateStatus; |
| | | |
| | | |
| | | public BladeUserDetails(Long userId, String tenantId, String oauthId, String name, String realName, String deptId, String postId, String roleId, String roleName, String avatar, String username, String password, Kv detail,String secretGrade, boolean enabled, boolean accountNonExpired, boolean credentialsNonExpired, boolean accountNonLocked, Collection<? extends GrantedAuthority> authorities,Long strategyUpdateStatus) { |
| | | public BladeUserDetails(Long userId, String tenantId, String oauthId, String name, String realName, String deptId, String postId, String roleId, String roleName, String avatar, String username, String password, Kv detail,String secretGrade, boolean enabled, boolean accountNonExpired, boolean credentialsNonExpired, boolean accountNonLocked, Collection<? extends GrantedAuthority> authorities,Long strategyUpdateStatus,String tenantName,String deptName,String email) { |
| | | super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities); |
| | | this.userId = userId; |
| | | this.tenantId = tenantId; |
| | |
| | | this.detail = detail; |
| | | this.secretGrade = secretGrade; |
| | | this.strategyUpdateStatus = strategyUpdateStatus; |
| | | this.tenantName = tenantName; |
| | | this.deptName = deptName; |
| | | this.email = email; |
| | | } |
| | | |
| | | public BladeUserDetails(Long userId, String tenantId, String oauthId, String name, String realName, String deptId, String postId, String roleId, String roleName, String avatar, String username, String password, Kv detail, boolean enabled, boolean accountNonExpired, boolean credentialsNonExpired, boolean accountNonLocked, Collection<? extends GrantedAuthority> authorities) { |
| | |
| | | BladeUserDetails bladeUserDetails = new BladeUserDetails(user.getId(), |
| | | user.getTenantId(), StringPool.EMPTY, user.getName(), user.getRealName(), user.getDeptId(), user.getPostId(), user.getRoleId(), Func.join(userInfo.getRoles()), Func.toStr(user.getAvatar(), TokenUtil.DEFAULT_AVATAR), |
| | | username, AuthConstant.ENCRYPT + user.getPassword(), userInfo.getDetail(),user.getSecretGrade(), true, true, true, true, |
| | | AuthorityUtils.commaSeparatedStringToAuthorityList(Func.join(result.getData().getRoles())),user.getStrategyUpdateStatus()); |
| | | AuthorityUtils.commaSeparatedStringToAuthorityList(Func.join(result.getData().getRoles())),user.getStrategyUpdateStatus(),tenant.getData().getTenantName(),user.getDeptName(),user.getEmail()); |
| | | return bladeUserDetails; |
| | | } else { |
| | | throw new UsernameNotFoundException(result.getMsg()); |
| | |
| | | info.put(TokenUtil.DETAIL, principal.getDetail()); |
| | | info.put(TokenUtil.LICENSE, TokenUtil.LICENSE_NAME); |
| | | info.put(TokenUtil.STRATEGYUPDATESTATUS, principal.getStrategyUpdateStatus()); |
| | | info.put(TokenUtil.TENANTNAME, principal.getTenantName()); |
| | | info.put(TokenUtil.DEPTNAME, principal.getDeptName()); |
| | | info.put(TokenUtil.EMAIL, principal.getEmail()); |
| | | info.put(TokenUtil.SECRETGRADE, principal.getSecretGrade()); |
| | | ((DefaultOAuth2AccessToken) accessToken).setAdditionalInformation(info); |
| | | |
| | | //token状态设置 |
| | |
| | | public final static String LICENSE = TokenConstant.LICENSE; |
| | | public final static String LICENSE_NAME = TokenConstant.LICENSE_NAME; |
| | | public final static String STRATEGYUPDATESTATUS = "strategyUpdateStatus"; |
| | | public final static String TENANTNAME = "tenantName"; |
| | | public final static String DEPTNAME = "deptName"; |
| | | public final static String EMAIL = "email"; |
| | | public final static String SECRETGRADE = "secretGrade"; |
| | | |
| | | public final static String DEPT_HEADER_KEY = "Dept-Id"; |
| | | public final static String ROLE_HEADER_KEY = "Role-Id"; |
| | |
| | | */ |
| | | private String deptId; |
| | | /** |
| | | * 部门名称 |
| | | */ |
| | | @TableField(exist = false) |
| | | private String deptName; |
| | | /** |
| | | * 密码策略 |
| | | */ |
| | | @TableField(exist = false) |
| | |
| | | import com.vci.ubcs.starter.web.pagemodel.SessionInfo; |
| | | import com.vci.ubcs.starter.web.util.VciBaseUtil; |
| | | import com.vci.ubcs.starter.web.util.VciDateUtil; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | |
| | | |
| | | public static Map<String, String> getSystemVarValueMap() { |
| | | Map<String, String> systemVarMap = new HashMap(); |
| | | SessionInfo sessionInfo = VciBaseUtil.getCurrentUserSessionInfo(); |
| | | if (sessionInfo != null) { |
| | | systemVarMap.put("#CURRENTUSER.OID#", sessionInfo.getUserOid()); |
| | | systemVarMap.put("#CURRENTUSER.ID#", sessionInfo.getUserId()); |
| | | systemVarMap.put("#CURRENTUSER_NAME#", sessionInfo.getUserName()); |
| | | // SessionInfo sessionInfo = VciBaseUtil.getCurrentUserSessionInfo(); |
| | | // if (sessionInfo != null) { |
| | | systemVarMap.put("#CURRENTUSER.OID#", String.valueOf(AuthUtil.getUser().getUserId())); |
| | | systemVarMap.put("#CURRENTUSER.ID#", AuthUtil.getUser().getAccount()); |
| | | systemVarMap.put("#CURRENTUSER_NAME#", AuthUtil.getUser().getUserName()); |
| | | systemVarMap.put("#CURRENTDATETIME#", VciDateUtil.getNowString()); |
| | | systemVarMap.put("#CURRENTDATE#", VciDateUtil.getNowString("yyyy-MM-dd")); |
| | | systemVarMap.put("#CURRENTTIME#", VciDateUtil.getNowString("HH:mm:ss")); |
| | | systemVarMap.put("#CURRENTUSER.SECRETGRADE#", sessionInfo.getUserSecret()); |
| | | systemVarMap.put("#CURRENTUSER.GROUPNAME#", sessionInfo.getDeptName()); |
| | | systemVarMap.put("#CURRENTUSER.GROUPOID#", sessionInfo.getDeptOid()); |
| | | systemVarMap.put("#CURRENTUSER.EMAIL#", sessionInfo.getEmail()); |
| | | systemVarMap.put("#CURRENTUSER.ROLENAME#", (String) ((Collection) Optional.ofNullable(sessionInfo.getRolesName().values()).orElseGet(() -> { |
| | | return new ArrayList(); |
| | | })).stream().collect(Collectors.joining(","))); |
| | | systemVarMap.put("#CURRENTUSER.IPSECRET#", sessionInfo.getIpSecret()); |
| | | systemVarMap.put("#CURRENTUSER.BUSINESSUNIT#", sessionInfo.getOrgsOid()); |
| | | systemVarMap.put("#CURRENTUSER.BUSINESSUNITNAME#", sessionInfo.getOrgsName()); |
| | | } |
| | | systemVarMap.put("#CURRENTUSER.SECRETGRADE#", (String) AuthUtil.getUser().getDetail().get("secretGrade")); |
| | | systemVarMap.put("#CURRENTUSER.GROUPNAME#", (String) AuthUtil.getUser().getDetail().get("deptName")); |
| | | systemVarMap.put("#CURRENTUSER.GROUPOID#", AuthUtil.getUser().getDeptId()); |
| | | systemVarMap.put("#CURRENTUSER.EMAIL#", (String) AuthUtil.getUser().getDetail().get("email")); |
| | | systemVarMap.put("#CURRENTUSER.ROLENAME#", AuthUtil.getUser().getRoleName()); |
| | | systemVarMap.put("#CURRENTUSER.IPSECRET#", ""); |
| | | systemVarMap.put("#CURRENTUSER.BUSINESSUNIT#", AuthUtil.getUser().getTenantId()); |
| | | systemVarMap.put("#CURRENTUSER.BUSINESSUNITNAME#", (String) AuthUtil.getUser().getDetail().get("tenantName")); |
| | | // } |
| | | |
| | | return systemVarMap; |
| | | } |
| | |
| | | import com.vci.ubcs.starter.util.UBCSSqlKeyword; |
| | | import com.vci.ubcs.starter.web.constant.QueryOptionConstant; |
| | | import com.vci.ubcs.starter.web.constant.RegExpConstant; |
| | | import com.vci.ubcs.starter.web.constant.VciSystemVarConstants; |
| | | import com.vci.ubcs.starter.web.enumpck.BooleanEnum; |
| | | import com.vci.ubcs.starter.web.enumpck.UserSecretEnum; |
| | | import com.vci.ubcs.starter.web.enumpck.VciFieldTypeEnum; |
| | |
| | | public String addSaveCode(CodeOrderDTO orderDTO) throws Exception { |
| | | VciBaseUtil.alertNotNull(orderDTO, "编码申请相关的属性和码段的内容都为空", orderDTO.getCodeClassifyOid(), "主题库分类的主键", |
| | | orderDTO.getTemplateOid(), "模板的主键", orderDTO.getCodeRuleOid(), "编码规则的主键"); |
| | | VciSystemVarConstants.getSystemVarValueMap(); |
| | | CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(orderDTO.getCodeClassifyOid()); |
| | | CodeClassifyTemplateVO templateVO = templateService.getObjectHasAttrByOid(orderDTO.getTemplateOid()); |
| | | CodeRuleVO ruleVO = ruleService.getObjectHasSecByOid(orderDTO.getCodeRuleOid()); |
| | |
| | | * @return 转换后的 |
| | | */ |
| | | private String getValueByFormulaForCBO(BaseModel cbo,String rule){ |
| | | Map<String, Object> dataMap = BeanUtils.beanToMap(cbo); |
| | | Map<String, Object> dataMap = null; |
| | | try{ |
| | | dataMap = VciBaseUtil.convertBean2Map(cbo); |
| | | }catch(Exception e){ |
| | | throw new VciBaseException("mapToBeanError:"+e); |
| | | } |
| | | Map<String, String> map = new HashMap<String, String>(); |
| | | for (String i : dataMap.keySet()) { |
| | | map.put(i, String.valueOf(dataMap.get(i))); |
| | |
| | | if (ObjectUtil.isEmpty(user)) { |
| | | return null; |
| | | } |
| | | user.setDeptName(Func.join(SysCache.getDeptNames(user.getDeptId()))); |
| | | UserInfo userInfo = new UserInfo(); |
| | | userInfo.setUser(user); |
| | | if (Func.isNotEmpty(user)) { |