Update the web configuration to add the TokenFactory.

main
KKlochko 1 year ago
parent f7d81a2fb8
commit c6ff965796

@ -14,7 +14,9 @@ import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import space.kklochko.spring_rest_example.db.factories.EntityManagerConnection; import space.kklochko.spring_rest_example.db.factories.EntityManagerConnection;
import space.kklochko.spring_rest_example.db.repositories.IndicatorRepository; import space.kklochko.spring_rest_example.db.repositories.IndicatorRepository;
import space.kklochko.spring_rest_example.models.Indicator; import space.kklochko.spring_rest_example.models.factories.TokenFactory;
import space.kklochko.spring_rest_example.security.tokens.SimpleRandomToken;
import space.kklochko.spring_rest_example.security.tokens.StringTokenFactory;
@EnableWebMvc @EnableWebMvc
@Configuration @Configuration
@ -34,4 +36,10 @@ public class WebConfig implements WebMvcConfigurer {
public IndicatorRepository indicatorRepository(EntityManager manager) { public IndicatorRepository indicatorRepository(EntityManager manager) {
return new IndicatorRepository(manager); return new IndicatorRepository(manager);
} }
@Bean
public TokenFactory tokenFactory() {
StringTokenFactory stringTokenFactory = new SimpleRandomToken();
return new TokenFactory(stringTokenFactory);
}
} }

@ -2,14 +2,13 @@ package space.kklochko.spring_rest_example.models.factories;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import org.springframework.beans.factory.annotation.Autowired;
import space.kklochko.spring_rest_example.models.Token; import space.kklochko.spring_rest_example.models.Token;
import space.kklochko.spring_rest_example.security.tokens.StringTokenFactory; import space.kklochko.spring_rest_example.security.tokens.StringTokenFactory;
@AllArgsConstructor @AllArgsConstructor
@Getter @Getter
public class TokenFactory { public class TokenFactory {
public StringTokenFactory factory; private StringTokenFactory factory;
public TokenFactory() { public TokenFactory() {
setFactory(null); setFactory(null);
@ -25,7 +24,6 @@ public class TokenFactory {
return token; return token;
} }
@Autowired
public void setFactory(StringTokenFactory factory) { public void setFactory(StringTokenFactory factory) {
this.factory = factory; this.factory = factory;
} }

Loading…
Cancel
Save