JCart Iteration-3 : Manage Categories and Products

In this iteration we will start working on the key requirement of our JCart administration application, ie managing categories and products. We will create various categories like Birds, Flowers, Vehicles etc. While creating products we will assign it to one of the category. Managing Categories and Products also looks similar to Manage Roles and Users. But there are few new things we will learn like FileUploading etc. Create Spring Data JPA Repositories for Category and Product public interface CategoryRepository extends JpaRepository<Category, Integer> { Category getByName(String name); } public interface ProductRepository extends JpaRepository<Product, Integer> { Product findByName(String name); Product findBySku(String sku); @Query("select p from Product p where p.

Continue reading »

JCart: Manage Users

In our previous post JCart: Manage Roles we have seen how to list all roles, create new roles and update them. Implementation of Manage Users also follows the same approach and very similar to the Implementation of Manage Roles. So I am not posting details of the implementation here again. Instead you can simply refer the code on JCart github repository https://github.com/sivaprasadreddy/jcart. If you have any questions regarding the implementation of Manage Users please post a comment.

Continue reading »

JCart: Manage Roles

In our previous post Manage Privileges – List all privileges we have implemented the functionality to show list of permissions. In this post we will implement Role management such as listing all Roles, creating new Role, editing Role permissions etc. Basically a Role is nothing a but group of Permissions assigned so that giving access to a set of action to user will become easy by assigning Roles. In this post we are going to see lot of code snippets, so I would suggest to clone the repo https://github.

Continue reading »

JCart: Manage Privileges

This is the simplest usecase of entire JCart admin application :-). We need to show list of permissions configured in our system. In our system each permission is more like access to a particular screen. For example, If a user has MANAGE_CATEGORIES permission then only he can access “Categories” screen. So these set of permission are something like implemented features set, hence we don’t need any provision to add/update/delete permissions dynamically.

Continue reading »

JCart : Iteration-2

Now we have completed Iteration-1 tasks. Iteration-1 includes so many tasks to establish the foundation like configuring Spring Security, Thymeleaf settings, UI layout setup etc. I hope from now on we can put more focus on actual tasks implementation rather than infrastructure setup. Though majority of the infrastructure setup is in place now, we will implement Role Based Access Control (RBAC) security using User-Role-Permission model before jumping on to Category/Product management.

Continue reading »

Setting up Jenkins/SonarQube

In this post we will setup SonarQube and Jenkins to perform code quality check and continuous integration. Install and configure SonarQube There are many code quality checking tools like PMD, Firebug but SonarQube brings them all under one roof and gives better view of code quality. Let us install and configure SonarQube for our JCart application. Download SonarQube from http://www.sonarqube.org/downloads/. Extract it run sonarqube-5.2/bin/windows-x86-64/StartSonar.bat. By default SonarQube uses in-memory H2 database to store all the metrics.

Continue reading »

JCart: Configuring HTTPS SSL/TLS

So far our JCart application is running on Tomcat default port 8080 using HTTP protocol. In this article we will configure to use HTTPS by using Self Signed Certificate. For real projects you would have to buy certificate from a Trusted Authority. I would like to run ShoppingCart site on https://host:8443 and if anyone tries to access it from http://host:8080 it should redirect to https://host:8443. Similarly I would like to run Administration site on https://host:9443 and if anyone tries to access it from http://host:9090 it should redirect to https://host:9443.

Continue reading »

JCart: Admin Reset Password

Once the Admin User clicked on Password Reset Link that we sent via Email, we will validate the Token and if is valid then we will show a form to enter New Password, otherwise shows an error. @Controller public class UserAuthController extends JCartAdminBaseController { ... @RequestMapping(value="/resetPwd", method=RequestMethod.GET) public String resetPwd(HttpServletRequest request, Model model, RedirectAttributes redirectAttributes) { String email = request.getParameter("email"); String token = request.getParameter("token"); boolean valid = securityService.verifyPasswordResetToken(email, token); if(valid){ model.

Continue reading »

JCart: Admin Forgot Password

We will provide a link to Forgot Password in Login page and create jcart-admin/src/main/resources/templates/public/forgotPwd.html template as follows: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" layout:decorator="layout/guestLayout"> <head> <title>Forgot Password</title> </head> <body > <div layout:fragment="content"> <form action="forgotPwd" th:action="@{/forgotPwd}" method="post"> <input type="email" class="form-control" name="email" placeholder="Email"/> <button type="submit" class="btn btn-primary btn-block btn-flat" th:text="#{label.submit}">Submit</button> </form> </div> </body> </html> When Admin user enters the email address and submit we will generate a token, store it in our DB and generates a Reset Password Link and send it to their email.

Continue reading »

JCart: Email Service SetUp

We are going to implement Admin User Forgot Password functionality where we need to send the Password Reset link to User email address. So let us look at how to configure Email server and send emails. Spring provides support for sending Emails using JavaMailSender. SpringBoot makes it even easier by providing a starter for emailing support. As we need Emailing feature in both Admin and ShoppingCart modules, we will implement the emailing functionality in jcart-core module.

Continue reading »