Hi!
I need to find a way to make a cast to Authentication when the user is guest.
because I need to put other objects like shopcart before login.
anyone know what to do?
my code
ERRORCode:public class CustomAnonymousAuthenticationFilter extends AnonymousAuthenticationFilter{ . . . protected Authentication createAuthentication(final HttpServletRequest request) { UsuarioGuest auth = (UsuarioGuest) super.createAuthentication(request); return auth; }
java.lang.ClassCastException: org.springframework.security.authentication.Anonym ousAuthenticationToken cannot be cast to cl.work.security.UsuarioGuest
UsuarioGuest Class
Code:public class UsuarioGuest extends AnonymousAuthenticationToken{ public UsuarioGuest(String key, Object principal, Collection<? extends GrantedAuthority> authorities) { super(key, principal, authorities); } private static final long serialVersionUID = 2322514539993169503L; List<ShoppingCartProductGuestDTO> listShoppCartProduct = new ArrayList(); public List<ShoppingCartProductGuestDTO> getListShoppCartProduct() { return listShoppCartProduct; } public void setListShoppCartProduct( List<ShoppingCartProductGuestDTO> listShoppCartProduct) { this.listShoppCartProduct = listShoppCartProduct; } }


Reply With Quote
