java-tutorials/spring-security-mvc-boot/src/main/java/com/baeldung/security/AuthenticationSuccessHandlerImpl.java
Ger Roza 5bc7d85eee [BAEL-3066] (Reverted and Redone) Spring Security: Exploring JDBC Authentication article (#7565)
* Revert "[BAEL-3066] Spring Security: Exploring JDBC Authentication (#7441)"

This reverts commit 5aecdeb0211c9dc44e3e5138d4a30bf837d19204.

* Redone Spring-Security-Exploring-JDBC-Authentication code, now witout using submodules
2019-08-20 06:42:47 +02:00

29 lines
912 B
Java

package com.baeldung.security;
import java.io.IOException;
import java.util.Date;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
import org.springframework.stereotype.Component;
import com.baeldung.data.repositories.UserRepository;
@Component
public class AuthenticationSuccessHandlerImpl implements AuthenticationSuccessHandler {
@Autowired
private UserRepository userRepository;
@Override
public void onAuthenticationSuccess(HttpServletRequest arg0, HttpServletResponse arg1, Authentication arg2) throws IOException, ServletException {
userRepository.updateLastLogin(new Date());
}
}