Ola eu tenho o seguinte codigo para controlar o acesso ao meu sistema:
@Override
public Authentication authenticate(Authentication a) throws AuthenticationException {
if (!a.getName().isEmpty() && !a.getCredentials().toString().isEmpty()) {
usuario = usuarioDao.login(a.getName(), a.getCredentials().toString());
if (usuario != null) {
if ("Ativo".equals(usuario.getSituacao())) {
return new UsernamePasswordAuthenticationToken(a.getName(), a.getCredentials(), permissao(usuario.getPermissaoList()));
} else {
mensagem = "Ops! Seu usuário bloqueado ou inativo!";
throw new BadCredentialsException(mensagem);
}
} else {
mensagem = "Ops! Suas informações são inválidas!";
throw new BadCredentialsException(mensagem);
}
} else {
mensagem = "Ops! Faltou informar usuário ou senha!";
throw new BadCredentialsException(mensagem);
}
}
teria como eu pegar esse usuario e registrar ele como um HttpServletRequest ou algo semelhante que eu possa utilizar nas paginas em meu projeto por exemplo exibindo o nome do usuario logado.