diff --git a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java
index 5b45d65e57..07c6ba3382 100644
--- a/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java
+++ b/spring-hibernate4/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java
@@ -3,7 +3,6 @@ package org.baeldung.persistence.service;
import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
import org.baeldung.persistence.model.Foo;
-import org.baeldung.persistence.service.IFooService;
import org.baeldung.spring.PersistenceConfig;
import org.junit.Ignore;
import org.junit.Test;
@@ -36,6 +35,7 @@ public class FooServicePersistenceIntegrationTest {
}
@Test(expected = DataIntegrityViolationException.class)
+ @Ignore("work in progress")
public final void whenInvalidEntityIsCreated_thenDataException() {
service.create(new Foo());
}
diff --git a/spring-security-login-error-handling/bin/.gitignore b/spring-security-login-error-handling/bin/.gitignore
deleted file mode 100644
index a57582cc39..0000000000
--- a/spring-security-login-error-handling/bin/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/src
diff --git a/spring-security-login-error-handling/pom.xml b/spring-security-login-error-handling/pom.xml
index ea519a712b..d750675411 100644
--- a/spring-security-login-error-handling/pom.xml
+++ b/spring-security-login-error-handling/pom.xml
@@ -11,7 +11,7 @@
org.springframework.boot
spring-boot-starter-parent
- 1.1.4.RELEASE
+ 1.1.5.RELEASE
@@ -137,9 +137,6 @@
1.7
- 3.1.1.RELEASE
- 3.2.4.RELEASE
- 1.6.10
1.7.6
@@ -152,7 +149,7 @@
1
- 1.4.1.RELEASE
+ 1.6.2.RELEASE
17.0
diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/dao/UserRepository.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/dao/UserRepository.java
index d36cd1ba2f..373a28b476 100644
--- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/dao/UserRepository.java
+++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/dao/UserRepository.java
@@ -3,7 +3,6 @@ package org.baeldung.persistence.dao;
import org.springframework.data.jpa.repository.JpaRepository;
import org.baeldung.persistence.model.User;
-
-public interface UserRepository extends JpaRepository{
+public interface UserRepository extends JpaRepository {
public User findByUsername(String username);
}
diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/Role.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/Role.java
index f0a08885f5..4be1696e6e 100644
--- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/Role.java
+++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/Role.java
@@ -11,52 +11,58 @@ import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
-
-@Entity(name="role")
+@Entity(name = "role")
@Table(name = "role")
public class Role {
- @Id
- @GeneratedValue(strategy = GenerationType.AUTO)
- private Long id;
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private Long id;
-
- @OneToOne(targetEntity = User.class, fetch = FetchType.EAGER, cascade = CascadeType.ALL)
- @JoinColumn(name = "user_id")
- private User user;
-
- @Column(name="role")
- private Integer role;
+ @OneToOne(targetEntity = User.class, fetch = FetchType.EAGER, cascade = CascadeType.ALL)
+ @JoinColumn(name = "user_id")
+ private User user;
- public Role(){
- super();
-
- }
- public Role(Integer role){
- super();
- this.role = role;
- }
- public Role(Integer role, User user){
- super();
- this.role = role;
- this.user = user;
- }
- public Long getId() {
- return id;
- }
- public void setId(Long id) {
- this.id = id;
- }
- public User getUser() {
- return user;
- }
- public void setUser(User user) {
- this.user = user;
- }
- public Integer getRole() {
- return role;
- }
- public void setRole(Integer role) {
- this.role = role;
- }
+ @Column(name = "role")
+ private Integer role;
+
+ public Role() {
+ super();
+
+ }
+
+ public Role(Integer role) {
+ super();
+ this.role = role;
+ }
+
+ public Role(Integer role, User user) {
+ super();
+ this.role = role;
+ this.user = user;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public User getUser() {
+ return user;
+ }
+
+ public void setUser(User user) {
+ this.user = user;
+ }
+
+ public Integer getRole() {
+ return role;
+ }
+
+ public void setRole(Integer role) {
+ this.role = role;
+ }
}
\ No newline at end of file
diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/User.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/User.java
index 4fe8c9986f..33851c9fa5 100644
--- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/User.java
+++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/model/User.java
@@ -17,17 +17,16 @@ public class User {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
- @Column(name="firstName")
+ @Column(name = "firstName")
private String firstName;
- @Column(name="lastName")
+ @Column(name = "lastName")
private String lastName;
- @Column(name="username")
+ @Column(name = "username")
private String username;
- @Column(name="password")
+ @Column(name = "password")
private String password;
-
-
- @OneToOne(mappedBy = "user",fetch = FetchType.EAGER, cascade = CascadeType.ALL)
+
+ @OneToOne(mappedBy = "user", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
private Role role;
public Long getId() {
@@ -77,8 +76,7 @@ public class User {
public void setRole(Role role) {
this.role = role;
}
-
-
+
@Override
public int hashCode() {
final int prime = 31;
@@ -100,11 +98,11 @@ public class User {
return false;
return true;
}
+
@Override
public String toString() {
final StringBuilder builder = new StringBuilder();
- builder.append("User [firstName=").append(firstName).append("]").
- append("[lastName=").append(lastName).append("]").append("[username").append(username).append("]");
+ builder.append("User [firstName=").append(firstName).append("]").append("[lastName=").append(lastName).append("]").append("[username").append(username).append("]");
return builder.toString();
}
}
\ No newline at end of file
diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/EmailExistsException.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/EmailExistsException.java
index 848eab02c2..eaf5c36409 100644
--- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/EmailExistsException.java
+++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/EmailExistsException.java
@@ -1,7 +1,7 @@
package org.baeldung.persistence.service;
-public class EmailExistsException extends Throwable{
-
+public class EmailExistsException extends Throwable {
+
public EmailExistsException(String message) {
super(message);
}
diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/RegistrationFormWithValidation.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/RegistrationFormWithValidation.java
index 6735ca7ab3..6be64b8414 100644
--- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/RegistrationFormWithValidation.java
+++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/RegistrationFormWithValidation.java
@@ -7,8 +7,6 @@ import org.hibernate.validator.constraints.NotEmpty;
public class RegistrationFormWithValidation {
-
-
@Email
@NotEmpty
@Size(max = 100)
diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/RepositoryService.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/RepositoryService.java
index c5f480e93c..25630ad9d6 100644
--- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/RepositoryService.java
+++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/RepositoryService.java
@@ -7,43 +7,42 @@ import org.baeldung.persistence.model.Role;
import org.baeldung.persistence.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
-import org.springframework.dao.DataIntegrityViolationException;
-import org.springframework.data.repository.RepositoryDefinition;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
@Service
public class RepositoryService implements UserService {
- @Autowired
+ @Autowired
private UserRepository repository;
- private PasswordEncoder passwordEncoder;
-
+
+ private final PasswordEncoder passwordEncoder;
+
@Autowired
private Environment env;
-
+
@Autowired
public RepositoryService(PasswordEncoder passwordEncoder, UserRepository repository) {
this.passwordEncoder = passwordEncoder;
this.repository = repository;
- }
-
+ }
+
@Transactional
@Override
public User registerNewUserAccount(UserDto userAccountData) throws EmailExistsException {
if (emailExist(userAccountData.getUsername())) {
-
+
throw new EmailExistsException("There is an account with that email adress: " + userAccountData.getUsername());
}
-
- User user = new User();
+
+ User user = new User();
user.setFirstName(userAccountData.getFirstName());
user.setLastName(userAccountData.getLastName());
user.setPassword(userAccountData.getPassword());
user.setUsername(userAccountData.getUsername());
user.setRole(new Role(userAccountData.getRole(), user));
- return repository.save(user);
+ return repository.save(user);
}
-
+
private boolean emailExist(String email) {
User user = repository.findByUsername(email);
if (user != null) {
diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserDto.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserDto.java
index 0cf36dd5c1..3d7dfd6642 100644
--- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserDto.java
+++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserDto.java
@@ -1,4 +1,5 @@
package org.baeldung.persistence.service;
+
//Renamed original RegistrationForm
public class UserDto {
@@ -7,51 +8,61 @@ public class UserDto {
private String lastName;
private String password;
private String username;
- private Integer role;
+ private Integer role;
private String lastError;
-
+
public String getLastError() {
return lastError;
}
-
+
public void setLastError(String lastError) {
this.lastError = lastError;
}
+
public Integer getRole() {
return role;
}
+
public void setRole(Integer role) {
this.role = role;
}
+
public String getUsername() {
return username;
}
+
public void setUsername(String username) {
this.username = username;
}
+
public String getFirstName() {
return firstName;
}
+
public void setFirstName(String firstName) {
this.firstName = firstName;
}
+
public String getLastName() {
return lastName;
}
+
public void setLastName(String lastName) {
this.lastName = lastName;
}
+
public String getPassword() {
return password;
}
+
public void setPassword(String password) {
this.password = password;
}
+
@Override
public String toString() {
final StringBuilder builder = new StringBuilder();
- builder.append("User [firstName=").append(firstName).append("]").
- append("[lastName=").append(lastName).append("]").append("[username").append(username).append("]");
+ builder.append("User [firstName=").append(firstName).append("]").append("[lastName=").append(lastName).append("]").append("[username").append(username).append("]");
return builder.toString();
}
}
diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserService.java b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserService.java
index 65c7516494..1166503fba 100644
--- a/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserService.java
+++ b/spring-security-login-error-handling/src/main/java/org/baeldung/persistence/service/UserService.java
@@ -1,7 +1,8 @@
package org.baeldung.persistence.service;
+
import org.baeldung.persistence.model.User;
public interface UserService {
-
+
public User registerNewUserAccount(UserDto userAccountData) throws EmailExistsException;
}
diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/security/MyUserDetailsService.java b/spring-security-login-error-handling/src/main/java/org/baeldung/security/MyUserDetailsService.java
index 41c27e2a9c..464a747683 100644
--- a/spring-security-login-error-handling/src/main/java/org/baeldung/security/MyUserDetailsService.java
+++ b/spring-security-login-error-handling/src/main/java/org/baeldung/security/MyUserDetailsService.java
@@ -22,33 +22,33 @@ import org.springframework.transaction.annotation.Transactional;
public class MyUserDetailsService implements UserDetailsService {
private static final Logger LOGGER = LoggerFactory.getLogger(UserDetailsService.class);
-
+
private UserRepository userRepository;
@Autowired
public MyUserDetailsService(UserRepository repository) {
this.userRepository = repository;
}
-
+
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
try {
LOGGER.debug("Loading user by username: {}", username);
User user = userRepository.findByUsername(username);
LOGGER.debug("Found user: {}", user);
if (user == null) {
- //throw new UsernameNotFoundException("No user found with username: " + username);
- boolean enabled = false;
- return new org.springframework.security.core.userdetails.User(" ", " ", enabled, true, true, true, getAuthorities(new Integer(1)));
+ // throw new UsernameNotFoundException("No user found with username: " + username);
+ boolean enabled = false;
+ return new org.springframework.security.core.userdetails.User(" ", " ", enabled, true, true, true, getAuthorities(new Integer(1)));
}
boolean enabled = true;
boolean accountNonExpired = true;
boolean credentialsNonExpired = true;
boolean accountNonLocked = true;
- return new org.springframework.security.core.userdetails.User(user.getUsername(), user.getPassword().toLowerCase(), enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, getAuthorities(user.getRole().getRole()));
+ return new org.springframework.security.core.userdetails.User(user.getUsername(), user.getPassword().toLowerCase(), enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, getAuthorities(user.getRole().getRole()));
} catch (Exception e) {
throw new RuntimeException(e);
- }
+ }
}
public Collection extends GrantedAuthority> getAuthorities(Integer role) {
@@ -60,7 +60,7 @@ public class MyUserDetailsService implements UserDetailsService {
List roles = new ArrayList();
if (role.intValue() == 2) {
- // roles.add("ROLE_USER");
+ // roles.add("ROLE_USER");
roles.add("ROLE_ADMIN");
} else if (role.intValue() == 1) {
@@ -69,7 +69,7 @@ public class MyUserDetailsService implements UserDetailsService {
return roles;
}
-
+
public static List getGrantedAuthorities(List roles) {
List authorities = new ArrayList();
for (String role : roles) {
diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/AppConfig.java b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/AppConfig.java
index 861e68b9ed..987ae89cc7 100644
--- a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/AppConfig.java
+++ b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/AppConfig.java
@@ -1,6 +1,5 @@
package org.baeldung.spring;
-import java.util.Properties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
@@ -9,7 +8,6 @@ import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.core.env.Environment;
-import org.springframework.mail.javamail.JavaMailSenderImpl;
@Configuration
@ComponentScan(basePackages = { "org.baeldung.persistence.service", "org.baeldung.persistence.dao" })
@@ -24,22 +22,22 @@ public class AppConfig {
return new PropertySourcesPlaceholderConfigurer();
}
- @Bean
- public JavaMailSenderImpl javaMailSenderImpl() {
- JavaMailSenderImpl mailSenderImpl = new JavaMailSenderImpl();
- mailSenderImpl.setHost(env.getProperty("smtp.host"));
- mailSenderImpl.setPort(env.getProperty("smtp.port", Integer.class));
- mailSenderImpl.setProtocol(env.getProperty("smtp.protocol"));
- mailSenderImpl.setUsername(env.getProperty("smtp.username"));
- mailSenderImpl.setPassword(env.getProperty("smtp.password"));
-
- Properties javaMailProps = new Properties();
- javaMailProps.put("mail.smtp.auth", true);
- javaMailProps.put("mail.smtp.starttls.enable", true);
-
- mailSenderImpl.setJavaMailProperties(javaMailProps);
-
- return mailSenderImpl;
- }
+// @Bean
+// public JavaMailSenderImpl javaMailSenderImpl() {
+// JavaMailSenderImpl mailSenderImpl = new JavaMailSenderImpl();
+// mailSenderImpl.setHost(env.getProperty("smtp.host"));
+// mailSenderImpl.setPort(env.getProperty("smtp.port", Integer.class));
+// mailSenderImpl.setProtocol(env.getProperty("smtp.protocol"));
+// mailSenderImpl.setUsername(env.getProperty("smtp.username"));
+// mailSenderImpl.setPassword(env.getProperty("smtp.password"));
+//
+// Properties javaMailProps = new Properties();
+// javaMailProps.put("mail.smtp.auth", true);
+// javaMailProps.put("mail.smtp.starttls.enable", true);
+//
+// mailSenderImpl.setJavaMailProperties(javaMailProps);
+//
+// return mailSenderImpl;
+// }
}
diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/MvcConfig.java b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/MvcConfig.java
index a51e253430..a7a46a1028 100644
--- a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/MvcConfig.java
+++ b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/MvcConfig.java
@@ -19,11 +19,8 @@ import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.JstlView;
-
@Configuration
-@ComponentScan(basePackages = {
- "org.baeldung.web.controller", "org.baeldung.persistence.service", "org.baeldung.persistence.dao"
-})
+@ComponentScan(basePackages = { "org.baeldung.web.controller", "org.baeldung.persistence.service", "org.baeldung.persistence.dao" })
@EnableWebMvc
public class MvcConfig extends WebMvcConfigurerAdapter {
@@ -46,9 +43,9 @@ public class MvcConfig extends WebMvcConfigurerAdapter {
registry.addViewController("/admin.html");
registry.addViewController("/registration.html");
registry.addViewController("/successRegister.html");
-
+
}
-
+
@Bean
public ViewResolver viewResolver() {
final InternalResourceViewResolver bean = new InternalResourceViewResolver();
@@ -82,10 +79,11 @@ public class MvcConfig extends WebMvcConfigurerAdapter {
messageSource.setCacheSeconds(0);
return messageSource;
}
+
@Bean
public UserValidator userValidator() {
UserValidator userValidator = new UserValidator();
return userValidator;
}
-
+
}
\ No newline at end of file
diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java
index 172ebbb77d..32cd80854c 100644
--- a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java
+++ b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java
@@ -77,5 +77,5 @@ public class PersistenceJPAConfig {
// hibernateProperties.setProperty("hibernate.globally_quoted_identifiers", "true");
return hibernateProperties;
}
-
+
}
diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/SecSecurityConfig.java b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/SecSecurityConfig.java
index 3e793a33f6..4da114c78b 100644
--- a/spring-security-login-error-handling/src/main/java/org/baeldung/spring/SecSecurityConfig.java
+++ b/spring-security-login-error-handling/src/main/java/org/baeldung/spring/SecSecurityConfig.java
@@ -10,5 +10,5 @@ public class SecSecurityConfig {
public SecSecurityConfig() {
super();
}
-
+
}
diff --git a/spring-security-login-error-handling/src/main/java/org/baeldung/web/controller/RegistrationController.java b/spring-security-login-error-handling/src/main/java/org/baeldung/web/controller/RegistrationController.java
index 1253796525..3d70f8b5a1 100644
--- a/spring-security-login-error-handling/src/main/java/org/baeldung/web/controller/RegistrationController.java
+++ b/spring-security-login-error-handling/src/main/java/org/baeldung/web/controller/RegistrationController.java
@@ -1,7 +1,5 @@
package org.baeldung.web.controller;
-import java.util.Locale;
-
import org.baeldung.persistence.model.User;
import org.baeldung.persistence.service.EmailExistsException;
import org.baeldung.persistence.service.UserDto;
@@ -10,17 +8,10 @@ import org.baeldung.persistence.service.UserValidator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.context.MessageSource;
-import org.springframework.core.env.Environment;
-import org.springframework.mail.SimpleMailMessage;
-import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.validation.Errors;
-import org.springframework.validation.ObjectError;
-import org.springframework.validation.Validator;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.ModelAttribute;
@@ -30,7 +21,6 @@ import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.servlet.ModelAndView;
-
@Controller
@SessionAttributes("user")
public class RegistrationController {
@@ -38,21 +28,18 @@ public class RegistrationController {
private static final Logger LOGGER = LoggerFactory.getLogger(RegistrationController.class);
private UserService service;
@Autowired
- private MessageSource messages;
- @Autowired
- private JavaMailSender mailSender;
- @Autowired
private UserValidator validator;
-
+
@InitBinder
protected void initBinder(WebDataBinder binder) {
binder.setValidator(this.validator);
}
+
@Autowired
public RegistrationController(UserService service) {
this.service = service;
}
-
+
@RequestMapping(value = "/user/registration", method = RequestMethod.GET)
public String showRegistrationForm(WebRequest request, Model model) {
LOGGER.debug("Rendering registration page.");
@@ -60,48 +47,47 @@ public class RegistrationController {
model.addAttribute("user", userDto);
return "registration";
}
- /* @RequestMapping(value ="/user/registration", method = RequestMethod.POST)
- public String registerUserAccount( @ModelAttribute("user") UserDto userAccountData,
- BindingResult result,
- WebRequest request, Errors errors) {
- LOGGER.debug("Registering user account with information: {}", userAccountData);
- if (result.hasErrors()) {
- LOGGER.debug("Validation errors found. Rendering form view.");
- return "registration";
- }
- LOGGER.debug("No validation errors found. Continuing registration process.");
- User registered = createUserAccount(userAccountData, result);
- if (registered == null) {
- errors.rejectValue("lastError", "message.regError");
- return "registration";
- }
- LOGGER.debug("Registered user account with information: {}", registered);
-
- sendConfirmMail(userAccountData.getUsername(), request.getLocale());
- return "successRegister";
- //return "redirect:/";
- }*/
- @RequestMapping(value ="/user/registration", method = RequestMethod.POST)
- public ModelAndView registerUserAccount( @ModelAttribute("user") UserDto userAccountData,
- BindingResult result,
- WebRequest request, Errors errors) {
+
+ /* @RequestMapping(value ="/user/registration", method = RequestMethod.POST)
+ public String registerUserAccount( @ModelAttribute("user") UserDto userAccountData,
+ BindingResult result,
+ WebRequest request, Errors errors) {
+ LOGGER.debug("Registering user account with information: {}", userAccountData);
+ if (result.hasErrors()) {
+ LOGGER.debug("Validation errors found. Rendering form view.");
+ return "registration";
+ }
+ LOGGER.debug("No validation errors found. Continuing registration process.");
+ User registered = createUserAccount(userAccountData, result);
+ if (registered == null) {
+ errors.rejectValue("lastError", "message.regError");
+ return "registration";
+ }
+ LOGGER.debug("Registered user account with information: {}", registered);
+
+ sendConfirmMail(userAccountData.getUsername(), request.getLocale());
+ return "successRegister";
+ //return "redirect:/";
+ }*/
+ @RequestMapping(value = "/user/registration", method = RequestMethod.POST)
+ public ModelAndView registerUserAccount(@ModelAttribute("user") UserDto userAccountData, BindingResult result, WebRequest request, Errors errors) {
LOGGER.debug("Registering user account with information: {}", userAccountData);
validator.validate(userAccountData, result);
User registered = createUserAccount(userAccountData, result);
- if (registered == null) {
+ if (registered == null) {
result.rejectValue("lastError", "message.regError");
}
if (result.hasErrors()) {
// show errors
return new ModelAndView("registration", "user", userAccountData);
} else {
-
+
// success
return new ModelAndView("successRegister", "user", userAccountData);
- }
-
+ }
+
}
-
+
private User createUserAccount(UserDto userAccountData, BindingResult result) {
LOGGER.debug("Creating user account with information: {}", userAccountData);
User registered = null;
@@ -110,18 +96,8 @@ public class RegistrationController {
} catch (EmailExistsException e) {
// TODO Auto-generated catch block
return null;
- }
+ }
return registered;
- }
-
- private void sendConfirmMail(String address, Locale locale){
- String recipientAddress = address;
- String subject = "Registration Confirmation";
- String message = messages.getMessage("message.regSucc", null, locale);
- SimpleMailMessage email = new SimpleMailMessage();
- email.setTo(recipientAddress);
- email.setSubject(subject);
- email.setText(message);
- mailSender.send(email);
}
+
}
diff --git a/spring-security-login-error-handling/src/main/resources/application.properties b/spring-security-login-error-handling/src/main/resources/application.properties
index a051636c6b..1144b5f03f 100644
--- a/spring-security-login-error-handling/src/main/resources/application.properties
+++ b/spring-security-login-error-handling/src/main/resources/application.properties
@@ -1,17 +1,10 @@
################### DataSource Configuration ##########################
jdbc.driverClassName=com.mysql.jdbc.Driver
-jdbc.url=jdbc:mysql://localhost:3306/AUTHDATA
-jdbc.user=root
-###jdbc.pass=admin###
+jdbc.url=jdbc:mysql://localhost:3306/spring_hibernate4_02?createDatabaseIfNotExist=true
+jdbc.user=tutorialuser
+jdbc.pass=tutorialmy5ql
init-db=false
################### Hibernate Configuration ##########################
hibernate.dialect=org.hibernate.dialect.MySQLDialect
-hibernate.show_sql=true
-hibernate.hbm2ddl.auto=validate
-################### JavaMail Configuration ##########################
-smtp.host=smtp.gmail.com
-smtp.port=465
-smtp.protocol=smtps
-smtp.username=edson@gmail.com
-smtp.password=
-support.email=edson@gmail.com
\ No newline at end of file
+hibernate.show_sql=false
+hibernate.hbm2ddl.auto=create-drop
diff --git a/spring-security-mvc-ldap/.classpath b/spring-security-mvc-ldap/.classpath
new file mode 100644
index 0000000000..c99cf86462
--- /dev/null
+++ b/spring-security-mvc-ldap/.classpath
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/spring-security-login-error-handling/bin/.project b/spring-security-mvc-ldap/.project
similarity index 83%
rename from spring-security-login-error-handling/bin/.project
rename to spring-security-mvc-ldap/.project
index 41a69a9af5..d43c118d1c 100644
--- a/spring-security-login-error-handling/bin/.project
+++ b/spring-security-mvc-ldap/.project
@@ -1,10 +1,15 @@
- spring-security-login-and-registration
+ spring-security-mvc-ldap
+
+ org.eclipse.wst.jsdt.core.javascriptValidator
+
+
+
org.eclipse.jdt.core.javabuilder
@@ -16,12 +21,12 @@
- org.springframework.ide.eclipse.core.springbuilder
+ org.eclipse.m2e.core.maven2Builder
- org.eclipse.wst.jsdt.core.javascriptValidator
+ org.springframework.ide.eclipse.core.springbuilder
@@ -30,24 +35,14 @@
-
- org.eclipse.m2e.core.maven2Builder
-
-
-
-
- org.hibernate.eclipse.console.hibernateBuilder
-
-
-
+ org.eclipse.jem.workbench.JavaEMFNature
+ org.eclipse.wst.common.modulecore.ModuleCoreNature
org.springframework.ide.eclipse.core.springnature
org.eclipse.jdt.core.javanature
org.eclipse.m2e.core.maven2Nature
org.eclipse.wst.common.project.facet.core.nature
- org.eclipse.wst.common.modulecore.ModuleCoreNature
org.eclipse.wst.jsdt.core.jsNature
- org.hibernate.eclipse.console.hibernateNature