#I844NY 消除Session与Authentication来回嵌套

This commit is contained in:
MaxKey
2023-09-26 14:17:45 +08:00
parent b111a52ccc
commit ef4bfb86f0
16 changed files with 28 additions and 28 deletions

View File

@@ -32,7 +32,7 @@ public class SignPrincipal implements UserDetails {
UserDetails userDetails;
Session session;
String sessionId;
ArrayList<GrantedAuthority> grantedAuthority;
ArrayList<GrantedAuthority> grantedAuthorityApps;
boolean authenticated;
@@ -71,7 +71,7 @@ public class SignPrincipal implements UserDetails {
this.accountNonLocked = true;
this.credentialsNonExpired =true;
this.enabled = true;
this.session = session;
this.sessionId = session.getId();
this.userInfo.setSessionId(session.getId());
}
@@ -120,13 +120,6 @@ public class SignPrincipal implements UserDetails {
this.grantedAuthority = grantedAuthority;
}
public Session getSession() {
return session;
}
public void setSession(Session session) {
this.session = session;
}
public boolean isRoleAdministrators() {
return roleAdministrators;
@@ -152,7 +145,16 @@ public class SignPrincipal implements UserDetails {
return this.credentialsNonExpired;
}
@Override
public String getSessionId() {
return sessionId;
}
public void setSessionId(String sessionId) {
this.sessionId = sessionId;
}
@Override
public boolean isEnabled() {
return this.enabled;
}
@@ -192,8 +194,6 @@ public class SignPrincipal implements UserDetails {
builder.append(userInfo);
builder.append(", userDetails=");
builder.append(userDetails);
builder.append(", session=");
builder.append(session);
builder.append(", grantedAuthority=");
builder.append(grantedAuthority);
builder.append(", grantedAuthorityApps=");

View File

@@ -89,7 +89,7 @@ public class AuthJwt implements Serializable {
this.expiresIn = expiresIn;
this.refreshToken = refreshToken;
this.ticket = principal.getSession().getId();
this.ticket = principal.getSessionId();
this.id = principal.getUserInfo().getId();
this.username = principal.getUserInfo().getUsername();
this.name = this.username;

View File

@@ -56,7 +56,7 @@ public class AuthJwtService {
JWTClaimsSet jwtClaims =new JWTClaimsSet.Builder()
.issuer(issuer)
.subject(subject)
.jwtID(principal.getSession().getId())
.jwtID(principal.getSessionId())
.issueTime(currentDateTime.toDate())
.expirationTime(expirationTime)
.claim("locale", userInfo.getLocale())

View File

@@ -65,7 +65,7 @@ public class HttpSessionListenerAdapter implements HttpSessionListener {
session.getId(),
signPrincipal.getUserInfo().getId(),
signPrincipal.getUserInfo().getUsername(),
signPrincipal.getSession().getId());
signPrincipal.getSessionId());
}else if(principal instanceof User) {
User user = (User)principal;
_logger.trace("{} HttpSession Id {} for username {} password {} Destroyed" ,