| | |
| | | import org.springblade.core.launch.constant.TokenConstant; |
| | | import org.springblade.core.tenant.BladeTenantProperties; |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | | import org.springblade.core.tool.jackson.JsonUtil; |
| | | import org.springblade.core.tool.utils.*; |
| | | import org.springblade.system.entity.Tenant; |
| | | import org.springframework.security.authentication.BadCredentialsException; |
| | |
| | | |
| | | import java.util.Base64; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 认证工具类 |
| | |
| | | public final static String DETAIL = TokenConstant.DETAIL; |
| | | 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 DEPT_HEADER_KEY = "Dept-Id"; |
| | | public final static String ROLE_HEADER_KEY = "Role-Id"; |
| | |
| | | public final static String USER_HAS_NO_TENANT = "未获得用户的租户信息"; |
| | | public final static String USER_HAS_NO_TENANT_PERMISSION = "租户授权已过期,请联系管理员"; |
| | | public final static String USER_HAS_TOO_MANY_FAILS = "登录错误次数过多,请稍后再试"; |
| | | public final static String IP_NOT_FOND = "该IP地址无访问权限,请配置IP白名单"; |
| | | public final static String HEADER_KEY = "Authorization"; |
| | | public final static String HEADER_PREFIX = "Basic "; |
| | | public final static String DEFAULT_AVATAR = ""; |
| | |
| | | if (StringUtil.equalsIgnoreCase(tenant.getTenantId(), BladeConstant.ADMIN_TENANT_ID)) { |
| | | return false; |
| | | } |
| | | Date expireTime = tenant.getExpireTime(); |
| | | if (getTenantProperties().getLicense()) { |
| | | String licenseKey = tenant.getLicenseKey(); |
| | | String decrypt = DesUtil.decryptFormHex(licenseKey, TenantConstant.DES_KEY); |
| | | expireTime = JsonUtil.parse(decrypt, Tenant.class).getExpireTime(); |
| | | } |
| | | if (expireTime != null && expireTime.before(DateUtil.now())) { |
| | | throw new UserDeniedAuthorizationException(TokenUtil.USER_HAS_NO_TENANT_PERMISSION); |
| | | } |
| | | return false; |
| | | } |