package org.ros.chatto; import java.security.SecureRandom; import org.modelmapper.ModelMapper; import org.ros.chatto.security.AuthenticationSuccessHandlerImpl; import org.springframework.context.MessageSource; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.support.ReloadableResourceBundleMessageSource; import org.springframework.security.core.token.KeyBasedPersistenceTokenService; import org.springframework.security.core.token.TokenService; import org.springframework.security.web.authentication.AuthenticationSuccessHandler; @Configuration public class BeanConfigurations { @Bean public AuthenticationSuccessHandler authenticationSuccessHandler() { return new AuthenticationSuccessHandlerImpl(); } @Bean public ModelMapper modelMapper() { ModelMapper modelMapper = new ModelMapper(); return modelMapper; } @Bean public MessageSource messageSource() { final ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource(); messageSource.setBasenames("classpath:/messages,file:./config/messages"); messageSource.setUseCodeAsDefaultMessage(true); messageSource.setDefaultEncoding("UTF-8"); messageSource.setCacheSeconds(5); return messageSource; } @Bean public TokenService tokenService() { KeyBasedPersistenceTokenService keyBasedPersistenceTokenService = new KeyBasedPersistenceTokenService(); keyBasedPersistenceTokenService.setPseudoRandomNumberBytes(10); keyBasedPersistenceTokenService.setSecureRandom(new SecureRandom()); keyBasedPersistenceTokenService.setServerInteger(1); keyBasedPersistenceTokenService.setServerSecret(":"); return keyBasedPersistenceTokenService; } // @Bean // public Connection connection() throws SQLException // { // return DriverManager.getConnection(url, userName, password); // } }