registration project cleanup
This commit is contained in:
parent
82148bf6a6
commit
2b86a7869d
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.event;
|
package org.baeldung.registration;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package org.baeldung.event.listener;
|
package org.baeldung.registration.listener;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.baeldung.event.OnRegistrationCompleteEvent;
|
|
||||||
import org.baeldung.persistence.model.User;
|
import org.baeldung.persistence.model.User;
|
||||||
import org.baeldung.persistence.service.IUserService;
|
import org.baeldung.persistence.service.IUserService;
|
||||||
|
import org.baeldung.registration.OnRegistrationCompleteEvent;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.ApplicationListener;
|
import org.springframework.context.ApplicationListener;
|
||||||
import org.springframework.context.MessageSource;
|
import org.springframework.context.MessageSource;
|
|
@ -6,20 +6,21 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Import;
|
|
||||||
import org.springframework.context.annotation.PropertySource;
|
import org.springframework.context.annotation.PropertySource;
|
||||||
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
import org.springframework.mail.javamail.JavaMailSenderImpl;
|
import org.springframework.mail.javamail.JavaMailSenderImpl;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@ComponentScan(basePackages = { "org.baeldung.event.service", "org.baeldung.event", "org.baeldung.persistence.service", "org.baeldung.persistence.dao" })
|
@ComponentScan(basePackages = { "org.baeldung.registration" })
|
||||||
@Import({ MvcConfig.class, PersistenceJPAConfig.class, SecSecurityConfig.class })
|
@PropertySource("classpath:email.properties")
|
||||||
@PropertySource("classpath:application.properties")
|
|
||||||
public class AppConfig {
|
public class AppConfig {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private Environment env;
|
private Environment env;
|
||||||
|
|
||||||
|
// beans
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public static PropertySourcesPlaceholderConfigurer propertyPlaceHolderConfigurer() {
|
public static PropertySourcesPlaceholderConfigurer propertyPlaceHolderConfigurer() {
|
||||||
return new PropertySourcesPlaceholderConfigurer();
|
return new PropertySourcesPlaceholderConfigurer();
|
||||||
|
|
|
@ -23,7 +23,7 @@ import org.springframework.web.servlet.view.InternalResourceViewResolver;
|
||||||
import org.springframework.web.servlet.view.JstlView;
|
import org.springframework.web.servlet.view.JstlView;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@ComponentScan(basePackages = { "org.baeldung.web.controller", "org.baeldung.persistence.service", "org.baeldung.persistence.dao" })
|
@ComponentScan(basePackages = { "org.baeldung.web" })
|
||||||
@EnableWebMvc
|
@EnableWebMvc
|
||||||
public class MvcConfig extends WebMvcConfigurerAdapter {
|
public class MvcConfig extends WebMvcConfigurerAdapter {
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ public class MvcConfig extends WebMvcConfigurerAdapter {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
// API
|
//
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addViewControllers(final ViewControllerRegistry registry) {
|
public void addViewControllers(final ViewControllerRegistry registry) {
|
||||||
|
@ -51,15 +51,6 @@ public class MvcConfig extends WebMvcConfigurerAdapter {
|
||||||
registry.addViewController("/successRegister.html");
|
registry.addViewController("/successRegister.html");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
|
||||||
public ViewResolver viewResolver() {
|
|
||||||
final InternalResourceViewResolver bean = new InternalResourceViewResolver();
|
|
||||||
bean.setViewClass(JstlView.class);
|
|
||||||
bean.setPrefix("/WEB-INF/view/");
|
|
||||||
bean.setSuffix(".jsp");
|
|
||||||
return bean;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||||
registry.addResourceHandler("/resources/**").addResourceLocations("/", "/resources/");
|
registry.addResourceHandler("/resources/**").addResourceLocations("/", "/resources/");
|
||||||
|
@ -72,6 +63,17 @@ public class MvcConfig extends WebMvcConfigurerAdapter {
|
||||||
registry.addInterceptor(localeChangeInterceptor);
|
registry.addInterceptor(localeChangeInterceptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// beans
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ViewResolver viewResolver() {
|
||||||
|
final InternalResourceViewResolver bean = new InternalResourceViewResolver();
|
||||||
|
bean.setViewClass(JstlView.class);
|
||||||
|
bean.setPrefix("/WEB-INF/view/");
|
||||||
|
bean.setSuffix(".jsp");
|
||||||
|
return bean;
|
||||||
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public LocaleResolver localeResolver() {
|
public LocaleResolver localeResolver() {
|
||||||
CookieLocaleResolver cookieLocaleResolver = new CookieLocaleResolver();
|
CookieLocaleResolver cookieLocaleResolver = new CookieLocaleResolver();
|
||||||
|
@ -91,21 +93,17 @@ public class MvcConfig extends WebMvcConfigurerAdapter {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public EmailValidator usernameValidator() {
|
public EmailValidator usernameValidator() {
|
||||||
EmailValidator userNameValidator = new EmailValidator();
|
return new EmailValidator();
|
||||||
return userNameValidator;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public PasswordMatchesValidator passwordMatchesValidator() {
|
public PasswordMatchesValidator passwordMatchesValidator() {
|
||||||
PasswordMatchesValidator passwordMatchesValidator = new PasswordMatchesValidator();
|
return new PasswordMatchesValidator();
|
||||||
return passwordMatchesValidator;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DIC 7
|
|
||||||
@Bean
|
@Bean
|
||||||
public HashGenerator hashGenerator() {
|
public HashGenerator hashGenerator() {
|
||||||
HashGenerator hashGenerator = new HashGenerator();
|
return new HashGenerator();
|
||||||
return hashGenerator;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -18,8 +18,8 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableTransactionManagement
|
@EnableTransactionManagement
|
||||||
@PropertySource({ "classpath:application.properties" })
|
@PropertySource({ "classpath:persistence.properties" })
|
||||||
@ComponentScan({ "org.baeldung.persistence.model" })
|
@ComponentScan({ "org.baeldung.persistence" })
|
||||||
@EnableJpaRepositories(basePackages = "org.baeldung.persistence.dao")
|
@EnableJpaRepositories(basePackages = "org.baeldung.persistence.dao")
|
||||||
public class PersistenceJPAConfig {
|
public class PersistenceJPAConfig {
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import org.baeldung.persistence.model.User;
|
||||||
import org.baeldung.persistence.model.VerificationToken;
|
import org.baeldung.persistence.model.VerificationToken;
|
||||||
import org.baeldung.persistence.service.UserDto;
|
import org.baeldung.persistence.service.UserDto;
|
||||||
import org.baeldung.persistence.service.IUserService;
|
import org.baeldung.persistence.service.IUserService;
|
||||||
import org.baeldung.event.OnRegistrationCompleteEvent;
|
import org.baeldung.registration.OnRegistrationCompleteEvent;
|
||||||
import org.baeldung.validation.service.EmailExistsException;
|
import org.baeldung.validation.service.EmailExistsException;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
|
@ -8,10 +8,3 @@ init-db=false
|
||||||
hibernate.dialect=org.hibernate.dialect.MySQLDialect
|
hibernate.dialect=org.hibernate.dialect.MySQLDialect
|
||||||
hibernate.show_sql=false
|
hibernate.show_sql=false
|
||||||
hibernate.hbm2ddl.auto=create-drop
|
hibernate.hbm2ddl.auto=create-drop
|
||||||
################### JavaMail Configuration ##########################
|
|
||||||
smtp.host=smtp.gmail.com
|
|
||||||
smtp.port=465
|
|
||||||
smtp.protocol=smtps
|
|
||||||
smtp.username=xxx777@gmail.com
|
|
||||||
smtp.password=
|
|
||||||
support.email=xxx777@gmail.com
|
|
|
@ -5,6 +5,7 @@
|
||||||
xsi:schemaLocation="
|
xsi:schemaLocation="
|
||||||
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd
|
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd
|
||||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd">
|
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd">
|
||||||
|
|
||||||
<http use-expressions="true">
|
<http use-expressions="true">
|
||||||
<intercept-url pattern="/login*" access="permitAll" />
|
<intercept-url pattern="/login*" access="permitAll" />
|
||||||
<intercept-url pattern="/logout*" access="permitAll" />
|
<intercept-url pattern="/logout*" access="permitAll" />
|
||||||
|
@ -19,7 +20,7 @@
|
||||||
<intercept-url pattern="/emailError*" access="permitAll" />
|
<intercept-url pattern="/emailError*" access="permitAll" />
|
||||||
<intercept-url pattern="/resources/**" access="permitAll" />
|
<intercept-url pattern="/resources/**" access="permitAll" />
|
||||||
<intercept-url pattern="/invalidSession*" access="isAnonymous()" />
|
<intercept-url pattern="/invalidSession*" access="isAnonymous()" />
|
||||||
<intercept-url pattern="/**" access="isAuthenticated()" />
|
<intercept-url pattern="/**" access="isAuthenticated()" />
|
||||||
<form-login login-page='/login.html'
|
<form-login login-page='/login.html'
|
||||||
authentication-failure-url="/login.html?error=true"
|
authentication-failure-url="/login.html?error=true"
|
||||||
authentication-success-handler-ref="myAuthenticationSuccessHandler"
|
authentication-success-handler-ref="myAuthenticationSuccessHandler"
|
||||||
|
@ -29,7 +30,9 @@
|
||||||
<logout invalidate-session="false" logout-success-url="/logout.html?logSucc=true"
|
<logout invalidate-session="false" logout-success-url="/logout.html?logSucc=true"
|
||||||
logout-url="/j_spring_security_logout" delete-cookies="JSESSIONID" />
|
logout-url="/j_spring_security_logout" delete-cookies="JSESSIONID" />
|
||||||
</http>
|
</http>
|
||||||
|
|
||||||
<authentication-manager>
|
<authentication-manager>
|
||||||
<authentication-provider ref="authProvider"/>
|
<authentication-provider ref="authProvider" />
|
||||||
</authentication-manager>
|
</authentication-manager>
|
||||||
|
|
||||||
</beans:beans>
|
</beans:beans>
|
Loading…
Reference in New Issue