| | |
| | | protected static final long MILLIS_MINUTE = 60 * MILLIS_SECOND; |
| | | |
| | | private final static long expireTime = CacheConstants.EXPIRATION; |
| | | private final static long expireAppletTime = CacheConstants.EXPIRATION_APPLET; |
| | | |
| | | private final static String ACCESS_TOKEN = CacheConstants.LOGIN_TOKEN_KEY; |
| | | |
| | |
| | | Map<String, Object> claimsMap = new HashMap<String, Object>(); |
| | | claimsMap.put(SecurityConstants.USER_KEY, token); |
| | | claimsMap.put(SecurityConstants.DETAILS_USER_ID, userId); |
| | | claimsMap.put(SecurityConstants.USER_TYPE, "system"); |
| | | claimsMap.put(SecurityConstants.DETAILS_USERNAME, userName); |
| | | |
| | | // 接口返回信息 |
| | |
| | | */ |
| | | public Map<String, Object> createTokenApplet(LoginUserApplet loginUser) { |
| | | String token = IdUtils.fastUUID(); |
| | | Integer userId = loginUser.getUserid(); |
| | | Long userId = loginUser.getUserId(); |
| | | String name = loginUser.getName(); |
| | | loginUser.setToken(token); |
| | | loginUser.setIpaddr(IpUtils.getIpAddr()); |
| | |
| | | Map<String, Object> claimsMap = new HashMap<String, Object>(); |
| | | claimsMap.put(SecurityConstants.USER_APPLET_KEY, token); |
| | | claimsMap.put(SecurityConstants.DETAILS_USER_ID, userId); |
| | | claimsMap.put(SecurityConstants.USER_TYPE, "applet"); |
| | | claimsMap.put(SecurityConstants.DETAILS_USERNAME, name); |
| | | // 接口返回信息 |
| | | Map<String, Object> rspMap = new HashMap<String, Object>(); |
| | | rspMap.put("access_token", JwtUtils.createToken(claimsMap)); |
| | | rspMap.put("expires_in", expireTime); |
| | | rspMap.put("expires_in", expireAppletTime); |
| | | return rspMap; |
| | | } |
| | | public LoginUserApplet getLoginUserApplet() { |
| | |
| | | LoginUserApplet user = null; |
| | | try { |
| | | if (StringUtils.isNotEmpty(token)) { |
| | | String userkey = JwtUtils.getUserKeyApplet(token); |
| | | user = redisService.getCacheObject(getTokenKey(userkey)); |
| | | String userKey = JwtUtils.getUserKeyApplet(token); |
| | | user = redisService.getCacheObject(getTokenKey(userKey)); |
| | | return user; |
| | | } |
| | | } catch (Exception e) { |