tCustomer(customer) We use the RandomStringUtils class from Apache Commons Lang library, so make sure you add the following dependency to your project: Īnd HashGeneratoris a utility class. String hashedValidator = HashGenerator.generateSHA256(rawValidator) String rawValidator = RandomStringUtils.randomAlphanumeric(64) String selector = RandomStringUtils.randomAlphanumeric(12) Public class CustomerAuthToken implements java.io.Serializable Here’s the code to create a new token: // copyright CustomerAuthToken newToken = new CustomerAuthToken() Query = "SELECT c FROM CustomerAuthToken c WHERE c.selector = :selector") copyright import = "CustomerAuthToken.findBySelector", Create Database Table and Java Domain Model ClassAs per the solution we discussed above, we need to create an authentication table that looks like this: Here, customer is an existing table and customer_auth is the additional table added to implement the remember me function.Suppose that we use Hibernate/JPA, so create a new domain model class CustomerAuthToken to map with the customer_auth table. Note that in the following code, we use the table customer instead of user.Ģ. In case an authentication filter is used, we need to update the workflow as described in the following diagram: Next, let’s go through the coding steps to implement the Remember Me feature for your website.
0 Comments
Leave a Reply. |