JwtFactory reload
This commit is contained in:
parent
4df0a41178
commit
d25f271d89
@ -17,6 +17,7 @@ package org.thingsboard.server.service.security.auth.jwt.settings;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.thingsboard.common.util.JacksonUtil;
|
||||
import org.thingsboard.server.cluster.TbClusterService;
|
||||
@ -25,6 +26,7 @@ import org.thingsboard.server.common.data.id.TenantId;
|
||||
import org.thingsboard.server.common.data.plugin.ComponentLifecycleEvent;
|
||||
import org.thingsboard.server.common.data.security.model.JwtSettings;
|
||||
import org.thingsboard.server.dao.settings.AdminSettingsService;
|
||||
import org.thingsboard.server.service.security.model.token.JwtTokenFactory;
|
||||
|
||||
import java.util.Base64;
|
||||
import java.util.Objects;
|
||||
@ -40,6 +42,8 @@ public class DefaultJwtSettingsService implements JwtSettingsService {
|
||||
private final AdminSettingsService adminSettingsService;
|
||||
private final Optional<TbClusterService> tbClusterService;
|
||||
private final JwtSettingsValidator jwtSettingsValidator;
|
||||
@Lazy
|
||||
private final JwtTokenFactory jwtTokenFactory;
|
||||
|
||||
private volatile JwtSettings jwtSettings = null; //lazy init
|
||||
|
||||
@ -62,7 +66,9 @@ public class DefaultJwtSettingsService implements JwtSettingsService {
|
||||
@Override
|
||||
public JwtSettings reloadJwtSettings() {
|
||||
log.trace("Executing reloadJwtSettings");
|
||||
return getJwtSettings(true);
|
||||
var settings = getJwtSettings(true);
|
||||
jwtTokenFactory.reload();
|
||||
return settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -53,6 +53,7 @@ public class JwtTokenFactoryTest {
|
||||
private JwtTokenFactory tokenFactory;
|
||||
private AdminSettingsService adminSettingsService;
|
||||
private JwtSettingsService jwtSettingsService;
|
||||
private JwtTokenFactory jwtTokenFactory;
|
||||
|
||||
private JwtSettings jwtSettings;
|
||||
|
||||
@ -170,7 +171,7 @@ public class JwtTokenFactoryTest {
|
||||
}
|
||||
|
||||
private DefaultJwtSettingsService mockJwtSettingsService() {
|
||||
return new DefaultJwtSettingsService(adminSettingsService, Optional.empty(), new DefaultJwtSettingsValidator());
|
||||
return new DefaultJwtSettingsService(adminSettingsService, Optional.empty(), new DefaultJwtSettingsValidator(), jwtTokenFactory);
|
||||
}
|
||||
|
||||
private void checkExpirationTime(JwtToken jwtToken, int tokenLifetime) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user