|
@@ -7,7 +7,6 @@ import java.util.Set;
|
|
import com.chelvc.framework.base.context.ApplicationContextHolder;
|
|
import com.chelvc.framework.base.context.ApplicationContextHolder;
|
|
import com.chelvc.framework.base.context.SessionContextHolder;
|
|
import com.chelvc.framework.base.context.SessionContextHolder;
|
|
import com.chelvc.framework.base.context.Using;
|
|
import com.chelvc.framework.base.context.Using;
|
|
-import com.chelvc.framework.common.model.Platform;
|
|
|
|
import com.chelvc.framework.common.util.StringUtils;
|
|
import com.chelvc.framework.common.util.StringUtils;
|
|
import com.chelvc.framework.redis.context.RedisContextHolder;
|
|
import com.chelvc.framework.redis.context.RedisContextHolder;
|
|
import com.chelvc.framework.redis.context.RedisHashHolder;
|
|
import com.chelvc.framework.redis.context.RedisHashHolder;
|
|
@@ -19,7 +18,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
import org.springframework.security.oauth2.core.OAuth2AuthenticationException;
|
|
import org.springframework.security.oauth2.core.OAuth2AuthenticationException;
|
|
import org.springframework.security.oauth2.core.OAuth2Error;
|
|
import org.springframework.security.oauth2.core.OAuth2Error;
|
|
-import org.springframework.security.oauth2.core.OAuth2TokenValidatorResult;
|
|
|
|
import org.springframework.security.oauth2.jwt.Jwt;
|
|
import org.springframework.security.oauth2.jwt.Jwt;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
@@ -41,11 +39,7 @@ public class RedisSessionValidator extends DefaultSessionValidator {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public OAuth2TokenValidatorResult validate(Jwt jwt) {
|
|
|
|
- if (SecurityContextHolder.isClient(jwt)) {
|
|
|
|
- return OAuth2TokenValidatorResult.success();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ protected void initializeSessionPrincipal(Jwt jwt) {
|
|
// 校验令牌有效性
|
|
// 校验令牌有效性
|
|
Long id = this.getId(jwt);
|
|
Long id = this.getId(jwt);
|
|
RedisTemplate<String, Object> template = RedisContextHolder.getDefaultTemplate();
|
|
RedisTemplate<String, Object> template = RedisContextHolder.getDefaultTemplate();
|
|
@@ -72,14 +66,11 @@ public class RedisSessionValidator extends DefaultSessionValidator {
|
|
}
|
|
}
|
|
|
|
|
|
// 更新会话信息
|
|
// 更新会话信息
|
|
- String version = this.getVersion(jwt);
|
|
|
|
- Platform platform = this.getPlatform(jwt);
|
|
|
|
String mobile = (String) context.get(SecurityContextHolder.MOBILE);
|
|
String mobile = (String) context.get(SecurityContextHolder.MOBILE);
|
|
Long creating = (Long) context.get(SecurityContextHolder.CREATING);
|
|
Long creating = (Long) context.get(SecurityContextHolder.CREATING);
|
|
Long registering = (Long) context.get(SecurityContextHolder.REGISTERING);
|
|
Long registering = (Long) context.get(SecurityContextHolder.REGISTERING);
|
|
Using using = Using.from(RedisUserDailyHashHolder.using(template, id), creating, this.usingRefreshInterval);
|
|
Using using = Using.from(RedisUserDailyHashHolder.using(template, id), creating, this.usingRefreshInterval);
|
|
Set<String> authorities = SecurityContextHolder.getAuthorities(jwt);
|
|
Set<String> authorities = SecurityContextHolder.getAuthorities(jwt);
|
|
- SessionContextHolder.updateSession(id, using, scope, mobile, version, platform, registering, authorities);
|
|
|
|
- return OAuth2TokenValidatorResult.success();
|
|
|
|
|
|
+ SessionContextHolder.updateSession(id, using, scope, mobile, registering, authorities);
|
|
}
|
|
}
|
|
}
|
|
}
|