try { User user = serviceImpl.authenticate(username, password); if (user != null) return true; } catch (SecurityException e) { e.printStackTrace(); } return false;
User user = serviceImpl.findUser(username); return user == null ? false : user.hasRole(role);