fixed circular dependency

This commit is contained in:
YevhenBondarenko 2024-05-03 21:19:08 +02:00
parent 510e4b14fe
commit 3cd8c60518
3 changed files with 4 additions and 3 deletions

View File

@ -17,6 +17,7 @@ package org.thingsboard.server.service.security.auth.jwt.settings;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.thingsboard.common.util.JacksonUtil;
@ -42,7 +43,6 @@ public class DefaultJwtSettingsService implements JwtSettingsService {
private final AdminSettingsService adminSettingsService;
private final Optional<TbClusterService> tbClusterService;
private final JwtSettingsValidator jwtSettingsValidator;
@Lazy
private final Optional<JwtTokenFactory> jwtTokenFactory;
private volatile JwtSettings jwtSettings = null; //lazy init

View File

@ -28,6 +28,7 @@ import io.jsonwebtoken.UnsupportedJwtException;
import io.jsonwebtoken.security.Keys;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Lazy;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.stereotype.Component;
@ -70,6 +71,7 @@ public class JwtTokenFactory {
private static final String CUSTOMER_ID = "customerId";
private static final String SESSION_ID = "sessionId";
@Lazy
private final JwtSettingsService jwtSettingsService;
private volatile JwtParser jwtParser;

View File

@ -53,7 +53,6 @@ public class JwtTokenFactoryTest {
private JwtTokenFactory tokenFactory;
private AdminSettingsService adminSettingsService;
private JwtSettingsService jwtSettingsService;
private JwtTokenFactory jwtTokenFactory;
private JwtSettings jwtSettings;
@ -171,7 +170,7 @@ public class JwtTokenFactoryTest {
}
private DefaultJwtSettingsService mockJwtSettingsService() {
return new DefaultJwtSettingsService(adminSettingsService, Optional.empty(), new DefaultJwtSettingsValidator(), jwtTokenFactory);
return new DefaultJwtSettingsService(adminSettingsService, Optional.empty(), new DefaultJwtSettingsValidator(), Optional.empty());
}
private void checkExpirationTime(JwtToken jwtToken, int tokenLifetime) {