/**
* Initialise de compte administrateur si non present en base.
* @return
*/
public User initAdminUser() {
User user = em.find(User.class, USERNAME_ADMIN);
if (user == null || user.getPassword() == null ||
user.getPassword().isEmpty()) {
HashSet<String> auth = new HashSet<String>();
auth.add("ROLE_SUPERADMIN");
auth.add("ROLE_ADMIN");
user = new User();
user.setUsername(USERNAME_ADMIN);
user.setEnabled(true);
user.setPassword(USERNAME_ADMIN + USERNAME_ADMIN);
user.setAuthorities(auth);
UserDetailsAdapter.encodPassword(user);
user.setEmail("test@test.fr");
em.merge(user);
}
return user;
}