Example of validating communication

We could have opted for Jdbc Token Repository Impl [this post demonstrates the Remember Me with Jdbc Token Repository Impl], but since we are using Hibernate in our application, why not create a custom implementation using Hibernate instead of using JDBC?

Temporal Type; @Entity @Table(name="PERSISTENT_LOGINS") public class Persistent Login implements Serializable package com.websystique.springmvc.security; import

Driver = jdbc:mysql://localhost:3306/websystique jdbc.username = myuser jdbc.password = mypassword hibernate.dialect = org.hibernate.dialect.

Hibernate Transaction Manager; import org.hibernate4. Local Session Factory Bean; import org.springframework.transaction.annotation. Enable Transaction Management; @Configuration @Enable Transaction Management @Component Scan() @Property Source(value = ) public class Hibernate Configuration jdbc.driver Class Name = com. Jstl View; import com.websystique.springmvc.converter. Role To User Profile Converter; @Configuration @Enable Web Mvc @Component Scan(base Packages = "com.websystique.springmvc") public class App Config extends Web Mvc Configurer Adapter package com.websystique.springmvc.converter; import org.slf4j. Logger Factory; import org.springframework.beans.factory.annotation.

Session Factory; import org.springframework.beans.factory.annotation. Autowired; public abstract class Abstract Dao package com.websystique.springmvc.dao; import

Granted Authority; import org.springframework.authority. Simple Granted Authority; import org.springframework.userdetails. User Details; import org.springframework.userdetails. User Details Service; import org.springframework.userdetails. Username Not Found Exception; import org.springframework.stereotype. Service; import org.springframework.transaction.annotation. Transactional; import com.websystique.springmvc.model. Abstract Security Web Application Initializer; public class Security Web Application Initializer extends Abstract Security Web Application Initializer package com.websystique.springmvc.configuration; import Not Empty; @Entity @Table(name="APP_USER") public class User implements Serializable package com.websystique.springmvc.model; import Table; @Entity @Table(name="USER_PROFILE") public class User Profile implements Serializable package com.websystique.springmvc.dao; import package com.websystique.springmvc.security; import org.springframework.beans.factory.annotation. Autowired; import org.springframework.beans.factory.annotation. Qualifier; import org.springframework.context.annotation. Bean; import org.springframework.context.annotation. Configuration; import org.springframework.security.authentication. Authentication Trust Resolver; import org.springframework.security.authentication. Authentication Trust Resolver Impl; import org.springframework.security. Dao Authentication Provider; import org.springframework.security.config.annotation.authentication.builders. Authentication Manager Builder; import org.springframework.security.config.builders. Http Security; import org.springframework.security.config.configuration. Enable Web Security; import org.springframework.security.config.configuration. Web Security Configurer Adapter; import org.springframework.userdetails. User Details Service; import org.springframework.security.crypto.bcrypt. BCrypt Password Encoder; import org.springframework.security.crypto.password. Password Encoder; import org.springframework.authentication.rememberme. Persistent Token Based Remember Me Services; import org.springframework.authentication.rememberme. Persistent Token Repository; @Configuration @Enable Web Security public class Security Configuration extends Web Security Configurer Adapter .