You don't need make mvn package every time, and don't need install.
You do mvn package one time. Then always mvn jetty:deploy. If you change some classes, you must package again. To run in hosted mode, mvn gwt:run. But is better run hosted mode inside eclipse.
1) src/main/resources/import.sql is used to populated the database. JPA annotation to generate.
public class LoginService implements ILoginService{
@Inject
ApplicationContext applicationContext;
private Collection<GrantedAuthority> getAuthorities() {
return getAuthorities(SecurityContextHolder.getContext()
.getAuthentication());
}
private Collection<GrantedAuthority> getAuthorities(Authentication auth) {
Collection<GrantedAuthority> roles = new HashSet<GrantedAuthority>();
if (auth == null)
throw new AuthenticationCredentialsNotFoundException(
"No Authentication");
Object obj = auth.getPrincipal();
if (obj instanceof UserDetails)
roles = ((UserDetails) obj).getAuthorities();
return roles;
}
public String getUserName() {
return getUserName(SecurityContextHolder.getContext()
.getAuthentication());
}
private String getUserName(Authentication auth) {
if (null == auth)
throw new AuthenticationCredentialsNotFoundException(
"No Authentication");
Object obj = auth.getPrincipal();
String username = "";
if (obj instanceof UserDetails)
username = ((UserDetails) obj).getUsername();
else
username = obj.toString();
return username;
}
public boolean hasRol(String rol) {
for (GrantedAuthority authority : getAuthorities()) {
if (authority.getAuthority().equals(rol))
return true;
}
return false;
}
public boolean isLogged() {
Authentication auth = SecurityContextHolder.getContext()
.getAuthentication();
if (auth == null)
return false;
return true;
}
public void logout() {
SecurityContextHolder.getContext().setAuthentication(null);
}
private HashSet<String> roles(Authentication authentication) {
HashSet<String> roles = new HashSet<String>();
Collection<GrantedAuthority> _roles = getAuthorities(authentication);
for (GrantedAuthority gr : _roles) {
roles.add(gr.getAuthority());
}
return roles;
}
}
Juan