@@ -0,0 +1,1848 @@
+package bg.car_wash.utils.user;%0A%0Aimport bg.car_wash.models.viewModels.user.UserSessionViewModel;%0A%0Aimport javax.servlet.http.Cookie;%0Aimport java.security.MessageDigest;%0Aimport java.util.LinkedList;%0Aimport java.util.List;%0A%0Apublic class UserCreateCookie %7B%0A%0A%09private List%3CCookie%3E cookies;%0A%0A%09private UserSessionViewModel userSessionViewModel;%0A%0A%09public UserCreateCookie(UserSessionViewModel userSessionViewModel) %7B%0A%09%09this.cookies = new LinkedList%3C%3E();%0A%09%09this.userSessionViewModel = userSessionViewModel;%0A%09%09this.initCookies();%0A%09%7D%0A%0A%09private void initCookies() %7B%0A%09%09Cookie name = new Cookie(%22user%22, this.userSessionViewModel.getFullName());%0A%09%09name.setMaxAge(3600);%0A%09%09Cookie email = new Cookie(%22email%22, this.userSessionViewModel.getEmail());%0A%09%09email.setMaxAge(3600);%0A%09%09Cookie userType = new Cookie(%22user-type%22, this.userSessionViewModel.getUserType().toString());%0A%09%09userType.setMaxAge(3600);%0A%09%09userType.setPath(%22/%22);%0A%0A%09%09String hash = sha256(this.userSessionViewModel.getFullName().trim() + this.userSessionViewModel.getUserType().toString().trim());%0A%0A%09%09Cookie user_session_id = new Cookie(%22USER_SESSION_ID%22, hash);%0A%09%09user_session_id.setMaxAge(3600);%0A%09%09user_session_id.setPath(%22/%22);%0A%0A%09%09this.cookies.add(name);%0A%09%09this.cookies.add(email);%0A%09%09this.cookies.add(userType);%0A%09%09this.cookies.add(user_session_id);%0A%09%7D%0A%0A%09private String sha256(String base) %7B%0A%09%09try%7B%0A%09%09%09MessageDigest digest = MessageDigest.getInstance(%22SHA-256%22);%0A%09%09%09byte%5B%5D hash = digest.digest(base.getBytes(%22UTF-8%22));%0A%09%09%09StringBuffer hexString = new StringBuffer();%0A%0A%09%09%09for (int i = 0; i %3C hash.length; i++) %7B%0A%09%09%09%09String hex = Integer.toHexString(0xff & hash%5Bi%5D);%0A%09%09%09%09if(hex.length() == 1) hexString.append('0');%0A%09%09%09%09hexString.append(hex);%0A%09%09%09%7D%0A%0A%09%09%09return hexString.toString();%0A%09%09%7D catch(Exception ex)%7B%0A%09%09%09throw new RuntimeException(ex);%0A%09%09%7D%0A%09%7D%0A%0A%09public List%3CCookie%3E getCookies() %7B%0A%09%09return cookies;%0A%09%7D%0A%7D%0A

create file for creating cookies