diff --git a/.gitignore b/.gitignore index 7116873..620de9b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ *.iml /target/ /out/ +/KirillMaxim/ +/classes/ +/IgnoreMeFile.txt diff --git a/KirillMaxim/README.txt b/KirillMaxim/README.txt new file mode 100644 index 0000000..581cb45 --- /dev/null +++ b/KirillMaxim/README.txt @@ -0,0 +1,2 @@ +usersByQuery=SELECT login, password, true FROM users WHERE login = ? +rolesByQuery=SELECT u.login, r.role FROM users u join roles r on r.id = u.role_id WHERE u.login = ? \ No newline at end of file diff --git a/pom.xml b/pom.xml index 926f684..afcc873 100644 --- a/pom.xml +++ b/pom.xml @@ -17,6 +17,12 @@ 9.4.1212.jre7 5.2.10.Final 2.7.8 + 4.12 + 1.0.4 + 1.2.17 + 1.9.5 + 1.3 + 1.1.7 @@ -46,6 +52,12 @@ spring-orm ${spring.version} + + org.springframework + spring-test + ${spring.version} + + org.springframework.security @@ -62,12 +74,19 @@ spring-security-web ${spring.security.version} + + org.springframework.security + spring-security-test + ${spring.security.version} + + org.postgresql postgresql ${postgresql.version} + org.hibernate @@ -94,17 +113,91 @@ jackson-core ${jackson.version} + com.fasterxml.jackson.core jackson-databind ${jackson.version} + jstl jstl ${jstl.version} + + + + junit + junit + ${junit.version} + test + + + + + pl.pragmatists + JUnitParams + ${junit.param.version} + test + + + + + org.testng + testng + 6.11 + + + + org.apache.httpcomponents + httpclient + 4.5.3 + + + + commons-codec + commons-codec + 1.10 + + + + + org.mockito + mockito-all + ${moickito.version} + test + + + + + org.hamcrest + hamcrest-all + ${hamcrest.version} + test + + + + com.jayway.jsonpath + json-path-assert + 2.2.0 + test + + + + + ch.qos.logback + logback-classic + ${logback.version} + + + + + log4j + log4j + ${log4j.version} + diff --git a/src/main/java/io/aera/config/AppConfig.java b/src/main/java/io/aera/config/AppConfig.java index 96c8eab..66cfc53 100644 --- a/src/main/java/io/aera/config/AppConfig.java +++ b/src/main/java/io/aera/config/AppConfig.java @@ -1,10 +1,16 @@ package io.aera.config; +import io.aera.dao.BasicDao; +import io.aera.dao.HistoryDao; import io.aera.dao.StoryDao; +import io.aera.dao.UserDao; +import io.aera.dao.impl.HistoryDaoImpl; import io.aera.dao.impl.StoryDaoImpl; +import io.aera.dao.impl.UserDaoImpl; +import io.aera.entity.History; import io.aera.entity.Story; +import io.aera.entity.User; import io.aera.model.Cat; -import io.aera.model.Dog; import io.aera.model.impl.CatImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; @@ -42,6 +48,16 @@ StoryDao storyDao(){ return new StoryDaoImpl(Story.class); } + @Bean + UserDao userDao() { + return new UserDaoImpl(User.class); + } + + @Bean + HistoryDao historyDao() { + return new HistoryDaoImpl(History.class); + } + @Bean DriverManagerDataSource dataSource(){ DriverManagerDataSource dataSource = new DriverManagerDataSource(); @@ -58,9 +74,4 @@ public JdbcTemplate jdbcTemplate(){ jdbcTemplate.setDataSource(dataSource()); return jdbcTemplate; } - - @Bean - Dog dog(){ - return new Dog(jdbcTemplate()); - } } diff --git a/src/main/java/io/aera/config/SecurityConfig.java b/src/main/java/io/aera/config/SecurityConfig.java index a07c529..e888640 100644 --- a/src/main/java/io/aera/config/SecurityConfig.java +++ b/src/main/java/io/aera/config/SecurityConfig.java @@ -32,8 +32,8 @@ protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests() .antMatchers("/").permitAll() .antMatchers("/admin/**").access("hasRole('ADMIN')") - .and().csrf().disable().formLogin().defaultSuccessUrl("/", false); + .and().csrf().disable() + .formLogin().loginPage("/user/login").usernameParameter("login").passwordParameter("password") + .defaultSuccessUrl("/user/status"); } - - } diff --git a/src/main/java/io/aera/config/application/WebConfig.java b/src/main/java/io/aera/config/application/WebConfig.java index b33bb33..5b5a218 100644 --- a/src/main/java/io/aera/config/application/WebConfig.java +++ b/src/main/java/io/aera/config/application/WebConfig.java @@ -4,6 +4,7 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; import org.springframework.web.servlet.view.InternalResourceViewResolver; @@ -19,4 +20,9 @@ public InternalResourceViewResolver viewResolver(){ viewResolver.setContentType("text/html;charset=utf-8"); return viewResolver; } + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler("/css/**").addResourceLocations("/WEB-INF/views/css/"); + } } diff --git a/src/main/java/io/aera/controller/AppController.java b/src/main/java/io/aera/controller/AppController.java index 3bfea50..ce5e812 100644 --- a/src/main/java/io/aera/controller/AppController.java +++ b/src/main/java/io/aera/controller/AppController.java @@ -1,15 +1,16 @@ package io.aera.controller; import io.aera.model.Cat; -import io.aera.model.Dog; import io.aera.model.Message; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.servlet.ModelAndView; @Controller @@ -20,18 +21,12 @@ public class AppController { @Autowired Message message; @Autowired - private Dog dog; + JdbcTemplate jdbcTemplate; // localhost:8080/ @RequestMapping("/") public String hello(Model model){ - return "story"; - } - - @RequestMapping("/create") - public String createDogTable(Model model){ - model.addAttribute("status", dog.createDogTable()); - return "dog"; + return "index"; } @RequestMapping("/admin/page/") @@ -39,6 +34,16 @@ public String securePage(){ return "admin"; } + @RequestMapping(value = "/initialize/", produces = "application/json") + @ResponseBody + public boolean initialize() { + jdbcTemplate.execute("INSERT INTO roles(id, role) VALUES (1, 'ROLE_ADMIN')"); + jdbcTemplate.execute("INSERT INTO roles(id, role) VALUES (2, 'ROLE_USER')"); + jdbcTemplate.execute("INSERT INTO players(id, login, firstname, lastname, password, email, role_id) " + + "VALUES (0, 'admin', 'admin', 'admin', '" + new BCryptPasswordEncoder().encode("admin") + "', 'admin@aera.com', 1)"); + return true; + } + // localhost:8080/password/admin @RequestMapping(value = {"/password/{password}"}, method = RequestMethod.GET) public ModelAndView passwordEncode(@PathVariable("password") String password){ diff --git a/src/main/java/io/aera/controller/UserController.java b/src/main/java/io/aera/controller/UserController.java new file mode 100644 index 0000000..9e4314f --- /dev/null +++ b/src/main/java/io/aera/controller/UserController.java @@ -0,0 +1,162 @@ +package io.aera.controller; + +import io.aera.entity.History; +import io.aera.entity.User; +import io.aera.service.HistoryService; +import io.aera.service.UserService; +import org.apache.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.security.web.authentication.WebAuthenticationDetails; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.servlet.ModelAndView; + +import javax.servlet.http.HttpServletRequest; +import java.security.Principal; +import java.util.Date; + +/** + * Handles basic users' requests + */ +@Controller +@RequestMapping("/user") +public class UserController { + private static final Logger log = Logger.getLogger(UserController.class); + @Autowired + UserService userService; + + @Autowired + HistoryService historyService; + + /** + * Shows registration form + * + * @return ModelAndView + */ + @RequestMapping(value = "/register", method = RequestMethod.GET) + public ModelAndView showRegisterForm() { + ModelAndView modelAndView = new ModelAndView(); + modelAndView.setViewName("/user/register"); + return modelAndView; + } + + /** + * Registers new user + * + * @param user User database info + * @return user added to db + */ + @RequestMapping(value = "/register", method = RequestMethod.PUT, produces = "application/json;charset=utf-8") + @ResponseBody + public User registerUser(@RequestBody User user) throws Exception { + try { + log.debug("UserController.registerUser: New User Registering!"); + userService.register(user); + historyService.register(user.getLogin()); + return user; + } + catch (Exception e) { + log.debug("UserController.registerUser: User already exists!"); + throw new Exception("User already exists"); + } + } + + /** + * Allows to login into application. Redirects to 'user/status.jsp' + * + * @return modelAndView + */ + @RequestMapping(value = "/login", method = RequestMethod.GET) + public ModelAndView showLoginForm(){ + ModelAndView modelAndView = new ModelAndView(); + modelAndView.setViewName("/user/login"); + return modelAndView; + } + + /** + * Shows basic profile page + * + * @return modelAndView + */ + @RequestMapping(value = "/status", method = RequestMethod.GET) + public ModelAndView showProfileForm(HttpServletRequest request){ + Principal principal = request.getUserPrincipal(); + User user = userService.findByLogin(principal.getName()); + if (user == null) + log.debug("UserController.showProfileForm: User not found!"); + ModelAndView modelAndView = new ModelAndView(); + modelAndView.setViewName("/user/status"); + modelAndView.addObject("user", user); + historyService.profile(); + return modelAndView; + } + + /** + * Shows update form + * + * @return update form + */ + @RequestMapping(value = "/update", method = RequestMethod.GET) + public ModelAndView showUpdatePage(){ + ModelAndView modelAndView = new ModelAndView(); + modelAndView.setViewName("user/update"); + historyService.update(); + return modelAndView; + } + + /** + * Updates user's information + * + * @param user + * @return updated user + */ + @RequestMapping(value = "/update", method = RequestMethod.PUT, produces = "application/json;charset=utf-8") + @ResponseBody + public User updateUserForm(@RequestBody User user, HttpServletRequest request){ + Principal principal = request.getUserPrincipal(); + User currentUser = userService.findByLogin(principal.getName()); + updateUser(currentUser, user); + historyService.updateForm(); + log.debug("UserController.updateUserForm: " + SecurityContextHolder.getContext().getAuthentication().getName() + " Try to update user data!"); + return userService.update(currentUser); + } + + /** + * Private method to update user's information obtained through + * method @updateUserForm() method + * + * @param oldUser + * @param newUser + * @return updated user + */ + private User updateUser(User oldUser, User newUser) { + oldUser.setId(oldUser.getId()); + oldUser.setLogin(newUser.getLogin()); + oldUser.setFirstname(newUser.getFirstname()); + oldUser.setLastname(newUser.getLastname()); + oldUser.setPassword(new BCryptPasswordEncoder().encode(newUser.getPassword())); + oldUser.setEmail(newUser.getEmail()); + oldUser.setRoleId(oldUser.getRoleId()); + return oldUser; + } + + /** + * Returns "user/status.jsp" with user's information + * + * @param id + * @return user + */ + @RequestMapping(value = "/findById/{id}", method = RequestMethod.GET) + @ResponseBody + public User getUserById(@PathVariable(value = "id") String id){ + User user = userService.getById(Long.parseLong(id)); + ModelAndView modelAndView = new ModelAndView(); + modelAndView.setViewName("/user/status"); + modelAndView.addObject("user", user); + historyService.findById(); + return user; + } +} diff --git a/src/main/java/io/aera/dao/BasicDao.java b/src/main/java/io/aera/dao/BasicDao.java index 73012f1..53e8c01 100644 --- a/src/main/java/io/aera/dao/BasicDao.java +++ b/src/main/java/io/aera/dao/BasicDao.java @@ -1,6 +1,7 @@ package io.aera.dao; import io.aera.entity.Story; +import io.aera.entity.User; import org.hibernate.Session; import java.util.List; @@ -28,10 +29,34 @@ public interface BasicDao { * @param id - current id of entity * @return entity */ - T getById(long id); + T getEntityById(long id); /** * @return list from entity * */ List getList(); + + /*** + * Finds entity by its login + * + * @param login + * @return entity + */ + T findEntityByName(String login); + + /** + * Updates entity in the database + * + * @param entity + * @return updated entity + */ + T update(T entity); + + /** + * Removes user from database + * + * @param entity + * @return null + */ + T delete(T entity); } diff --git a/src/main/java/io/aera/dao/HistoryDao.java b/src/main/java/io/aera/dao/HistoryDao.java new file mode 100644 index 0000000..56d4795 --- /dev/null +++ b/src/main/java/io/aera/dao/HistoryDao.java @@ -0,0 +1,6 @@ +package io.aera.dao; + +import io.aera.entity.History; + +public interface HistoryDao extends BasicDao { +} diff --git a/src/main/java/io/aera/dao/UserDao.java b/src/main/java/io/aera/dao/UserDao.java new file mode 100644 index 0000000..deb871d --- /dev/null +++ b/src/main/java/io/aera/dao/UserDao.java @@ -0,0 +1,6 @@ +package io.aera.dao; + +import io.aera.entity.User; + +public interface UserDao extends BasicDao { +} diff --git a/src/main/java/io/aera/dao/impl/BasicDaoImpl.java b/src/main/java/io/aera/dao/impl/BasicDaoImpl.java index 43889d4..907e575 100644 --- a/src/main/java/io/aera/dao/impl/BasicDaoImpl.java +++ b/src/main/java/io/aera/dao/impl/BasicDaoImpl.java @@ -4,7 +4,6 @@ import org.hibernate.Session; import org.hibernate.SessionFactory; import org.springframework.beans.factory.annotation.Autowired; - import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.Root; @@ -43,7 +42,28 @@ public List getList() { } @Override - public T getById(long id) { + public T getEntityById(long id) { return getCurrentSession().get(entityClass, id); } + + @Override + public T findEntityByName(String login) { + CriteriaBuilder builder = sessionFactory.getCriteriaBuilder(); + CriteriaQuery criteria = builder.createQuery(entityClass); + Root root = criteria.from(entityClass); + criteria.select(root).where(builder.equal(root.get("login"), login)); + return sessionFactory.getCurrentSession().createQuery(criteria).uniqueResult(); + } + + @Override + public T update(T entity) { + getCurrentSession().update(entity); + return entity; + } + + @Override + public T delete(T entity) { + getCurrentSession().delete(entity); + return entity; + } } diff --git a/src/main/java/io/aera/dao/impl/HistoryDaoImpl.java b/src/main/java/io/aera/dao/impl/HistoryDaoImpl.java new file mode 100644 index 0000000..0a2b0c2 --- /dev/null +++ b/src/main/java/io/aera/dao/impl/HistoryDaoImpl.java @@ -0,0 +1,17 @@ +package io.aera.dao.impl; + +import io.aera.dao.HistoryDao; +import io.aera.entity.History; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Repository; + +@Repository +@Qualifier("historyDao") +public class HistoryDaoImpl extends BasicDaoImpl implements HistoryDao { + + public HistoryDaoImpl() { super(History.class); } + + public HistoryDaoImpl(Class entityClass) { + super(entityClass); + } +} diff --git a/src/main/java/io/aera/dao/impl/UserDaoImpl.java b/src/main/java/io/aera/dao/impl/UserDaoImpl.java new file mode 100644 index 0000000..c0504b4 --- /dev/null +++ b/src/main/java/io/aera/dao/impl/UserDaoImpl.java @@ -0,0 +1,29 @@ +package io.aera.dao.impl; + +import io.aera.dao.UserDao; +import io.aera.entity.Roles; +import io.aera.entity.User; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.stereotype.Repository; + +@Repository +@Qualifier("userDao") +public class UserDaoImpl extends BasicDaoImpl implements UserDao { + //@Autowired + //private PasswordEncoder passwordEncoder; + + public UserDaoImpl() { super(User.class); } + + public UserDaoImpl(Class entityClass) { + super(entityClass); + } + + @Override + public User create(User entity) { + entity.setRoleId(Roles.ROLE_USER); + //entity.setPassword(passwordEncoder.encode(entity.getPassword())); + entity.setPassword(new BCryptPasswordEncoder().encode(entity.getPassword())); + return super.create(entity); + } +} diff --git a/src/main/java/io/aera/entity/History.java b/src/main/java/io/aera/entity/History.java new file mode 100644 index 0000000..3fd5f28 --- /dev/null +++ b/src/main/java/io/aera/entity/History.java @@ -0,0 +1,82 @@ +package io.aera.entity; + +import javax.persistence.*; +import java.util.Date; + +@Entity +@Table(name="history") +public class History { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "history_id") + private long id; + private Date date; + private String description; + private String userLogin; + private String currentSession; + private String ipAddress; + + public History() { + this.date = new Date(); + this.description = ""; + this.userLogin = ""; + this.currentSession = ""; + this.ipAddress = ""; + } + + public History(Date date, String description, String userLogin, String currentSession, String ipAddress) { + this.date = date; + this.description = description; + this.userLogin = userLogin; + this.currentSession = currentSession; + this.ipAddress = ipAddress; + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public Date getDate() { + return date; + } + + public void setDate(Date date) { + this.date = date; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getUserLogin() { + return userLogin; + } + + public void setUserLogin(String userLogin) { + this.userLogin = userLogin; + } + + public String getCurrentSession() { + return currentSession; + } + + public void setCurrentSession(String currentSession) { + this.currentSession = currentSession; + } + + public String getIpAddress() { + return ipAddress; + } + + public void setIpAddress(String ipAddress) { + this.ipAddress = ipAddress; + } +} diff --git a/src/main/java/io/aera/entity/Roles.java b/src/main/java/io/aera/entity/Roles.java new file mode 100644 index 0000000..65e3b6f --- /dev/null +++ b/src/main/java/io/aera/entity/Roles.java @@ -0,0 +1,34 @@ +package io.aera.entity; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +@Entity +@Table(name = "roles") +public class Roles { + public static final int ROLE_ADMIN = 1; + public static final int ROLE_USER = 2; + + @Id + private int id; + @Column(unique = true) + private String role; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } +} diff --git a/src/main/java/io/aera/entity/User.java b/src/main/java/io/aera/entity/User.java new file mode 100644 index 0000000..4a2bdfe --- /dev/null +++ b/src/main/java/io/aera/entity/User.java @@ -0,0 +1,75 @@ +package io.aera.entity; + +import javax.persistence.*; + +@Entity +@Table(name = "players") +public class User { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private long id; + @Column(unique = true) + private String login; + private String firstname; + private String lastname; + private String password; + private String email; + @Column(name = "role_id") + private int roleId; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getLogin() { + return login; + } + + public void setLogin(String login) { + this.login = login; + } + + public String getFirstname() { + return firstname; + } + + public void setFirstname(String firstname) { + this.firstname = firstname; + } + + public String getLastname() { + return lastname; + } + + public void setLastname(String lastname) { + this.lastname = lastname; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public int getRoleId() { + return roleId; + } + + public void setRoleId(int roleId) { + this.roleId = roleId; + } +} diff --git a/src/main/java/io/aera/service/HistoryService.java b/src/main/java/io/aera/service/HistoryService.java new file mode 100644 index 0000000..1f3af5d --- /dev/null +++ b/src/main/java/io/aera/service/HistoryService.java @@ -0,0 +1,46 @@ +package io.aera.service; + +import io.aera.entity.History; + +/** + * The primary goal of the interface is to write + * a user's history to the database + */ +public interface HistoryService { + + /** + * Writes history about new users' registration to the database + * + * @param userLogin new user login + * @return history + */ + History register(String userLogin); + + /** + * Writes history to the database about showing profile page of the authenticated User + * + * @return history + */ + History profile(); + + /** + * Writes history to the database of sending request to update User's information + * + * @return history + */ + History update(); + + /** + * Writes history to the database about updating user's information + * + * @return history + */ + History updateForm(); + + /** + * Writes history to the database about searching and showing User's information by id + * + * @return history + */ + History findById(); +} diff --git a/src/main/java/io/aera/service/UserService.java b/src/main/java/io/aera/service/UserService.java new file mode 100644 index 0000000..3dd7fcd --- /dev/null +++ b/src/main/java/io/aera/service/UserService.java @@ -0,0 +1,54 @@ +package io.aera.service; + +import io.aera.entity.User; + +import java.util.List; + +/** + * Used for user functionality (register, profile, etc) + */ +public interface UserService { + /** + * Register new user + * @param user - new User + * @return registered user if success, null otherwise + */ + User register(User user); + + /** + * Returns user by id + * @param id + * @return id + */ + User getById(long id); + + /** + * Finds user by its login + * + * @param login + * @return user + */ + User findByLogin(String login); + + /** + * Updates current user + * + * @param user + * @return updated user + */ + User update(User user); + + /** + * Returns list of users + * + * @return list of users + */ + List getListofUsers(); + + /** + * Deletes story by id + * + * @param id + */ + User deleteStory(long id); +} diff --git a/src/main/java/io/aera/service/impl/HistoryServiceImpl.java b/src/main/java/io/aera/service/impl/HistoryServiceImpl.java new file mode 100644 index 0000000..9e6d78e --- /dev/null +++ b/src/main/java/io/aera/service/impl/HistoryServiceImpl.java @@ -0,0 +1,70 @@ +package io.aera.service.impl; + +import io.aera.dao.HistoryDao; +import io.aera.entity.History; +import io.aera.service.HistoryService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.security.web.authentication.WebAuthenticationDetails; +import org.springframework.stereotype.Service; +import org.springframework.web.context.request.RequestContextHolder; + +import java.util.Date; + +@Service +@Qualifier("historyService") +public class HistoryServiceImpl implements HistoryService { + @Autowired + HistoryDao historyDao; + + @Override + public History register(String userLogin){ + WebAuthenticationDetails details = (WebAuthenticationDetails) SecurityContextHolder.getContext().getAuthentication().getDetails(); + History history = new History(new Date(), "Registering new User!", + userLogin, + RequestContextHolder.currentRequestAttributes().getSessionId(), + details.getRemoteAddress()); + return historyDao.create(history); + } + + @Override + public History profile() { + WebAuthenticationDetails details = (WebAuthenticationDetails) SecurityContextHolder.getContext().getAuthentication().getDetails(); + History history = new History(new Date(), "User logged in Profile page!", + SecurityContextHolder.getContext().getAuthentication().getName(), + RequestContextHolder.currentRequestAttributes().getSessionId(), + details.getRemoteAddress()); + return historyDao.create(history); + } + + @Override + public History update() { + WebAuthenticationDetails details = (WebAuthenticationDetails) SecurityContextHolder.getContext().getAuthentication().getDetails(); + History history = new History(new Date(), "Sent request to update User!", + SecurityContextHolder.getContext().getAuthentication().getName(), + RequestContextHolder.currentRequestAttributes().getSessionId(), + details.getRemoteAddress()); + return historyDao.create(history); + } + + @Override + public History updateForm() { + WebAuthenticationDetails details = (WebAuthenticationDetails) SecurityContextHolder.getContext().getAuthentication().getDetails(); + History history = new History(new Date(), "Updating User's information Page!", + SecurityContextHolder.getContext().getAuthentication().getName(), + RequestContextHolder.currentRequestAttributes().getSessionId(), + details.getRemoteAddress()); + return historyDao.create(history); + } + + @Override + public History findById() { + WebAuthenticationDetails details = (WebAuthenticationDetails) SecurityContextHolder.getContext().getAuthentication().getDetails(); + History history = new History(new Date(), "Showing User's information!", + SecurityContextHolder.getContext().getAuthentication().getName(), + RequestContextHolder.currentRequestAttributes().getSessionId(), + details.getRemoteAddress()); + return historyDao.create(history); + } +} diff --git a/src/main/java/io/aera/service/impl/StoryServiceImpl.java b/src/main/java/io/aera/service/impl/StoryServiceImpl.java index 63e1196..06e13d7 100644 --- a/src/main/java/io/aera/service/impl/StoryServiceImpl.java +++ b/src/main/java/io/aera/service/impl/StoryServiceImpl.java @@ -4,11 +4,13 @@ import io.aera.entity.Story; import io.aera.service.StoryService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Service; import java.util.List; -@Service("storyService") +@Service +@Qualifier("userService") public class StoryServiceImpl implements StoryService { @Autowired private StoryDao storyDao; @@ -25,6 +27,6 @@ public List getStoryList() { @Override public Story getStoryById(long storyId) { - return storyDao.getById(storyId); + return storyDao.getEntityById(storyId); } } diff --git a/src/main/java/io/aera/service/impl/UserServiceImpl.java b/src/main/java/io/aera/service/impl/UserServiceImpl.java new file mode 100644 index 0000000..07b1f8d --- /dev/null +++ b/src/main/java/io/aera/service/impl/UserServiceImpl.java @@ -0,0 +1,47 @@ +package io.aera.service.impl; + +import io.aera.dao.UserDao; +import io.aera.entity.User; +import io.aera.service.UserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +@Qualifier("userService") +public class UserServiceImpl implements UserService { + @Autowired + private UserDao userDao; + + @Override + public User register(User user) { + return userDao.create(user); + } + + @Override + public User getById(long id) { + return userDao.getEntityById(id); + } + + @Override + public User findByLogin(String login) { + return userDao.findEntityByName(login); + } + + @Override + public User update(User user) { + return userDao.update(user); + } + + @Override + public List getListofUsers(){ + return userDao.getList(); + } + + @Override + public User deleteStory(long id) { + return userDao.delete(userDao.getEntityById(id)); + } +} diff --git a/src/main/resources/auth.properties b/src/main/resources/auth.properties index 581cb45..a4ae682 100644 --- a/src/main/resources/auth.properties +++ b/src/main/resources/auth.properties @@ -1,2 +1,2 @@ -usersByQuery=SELECT login, password, true FROM users WHERE login = ? -rolesByQuery=SELECT u.login, r.role FROM users u join roles r on r.id = u.role_id WHERE u.login = ? \ No newline at end of file +usersByQuery=SELECT login, password, true FROM players WHERE login = ? +rolesByQuery=SELECT u.login, r.role FROM players u join roles r on r.id = u.role_id WHERE u.login = ? \ No newline at end of file diff --git a/src/main/resources/img/UserServicesDaoImplementaion.jpg b/src/main/resources/img/UserServicesDaoImplementaion.jpg new file mode 100644 index 0000000..3893d6a Binary files /dev/null and b/src/main/resources/img/UserServicesDaoImplementaion.jpg differ diff --git a/src/main/resources/log4j.properties b/src/main/resources/log4j.properties new file mode 100644 index 0000000..203cd19 --- /dev/null +++ b/src/main/resources/log4j.properties @@ -0,0 +1,16 @@ +# Root logger option +log4j.rootLogger=DEBUG, stdout, file + +# Redirect log messages to console +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n + +# Redirect log messages to a log file, support file rolling. +log4j.appender.file=org.apache.log4j.RollingFileAppender +log4j.appender.file.File=c:/aera.log +log4j.appender.file.MaxFileSize=5MB +log4j.appender.file.MaxBackupIndex=10 +log4j.appender.file.layout=org.apache.log4j.PatternLayout +log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n \ No newline at end of file diff --git a/src/main/resources/sql/schema.sql b/src/main/resources/sql/schema.sql new file mode 100644 index 0000000..9b1c852 --- /dev/null +++ b/src/main/resources/sql/schema.sql @@ -0,0 +1,9 @@ +CREATE TABLE players +( id bigint NOT NULL PRIMARY KEY + , login varchar(255) NOT NULL + , firstname varchar(255) NOT NULL + , lastname varchar(255) NOT NULL + , password varchar(255) NOT NULL + , email varchar(255) NOT NULL + , role_id integer NOT NULL +); \ No newline at end of file diff --git a/src/test/java/io/aera/controller/UserControllerIntegrationTest.java b/src/test/java/io/aera/controller/UserControllerIntegrationTest.java new file mode 100644 index 0000000..5174fa6 --- /dev/null +++ b/src/test/java/io/aera/controller/UserControllerIntegrationTest.java @@ -0,0 +1,186 @@ +package io.aera.controller; + +import com.fasterxml.jackson.databind.ObjectMapper; +import io.aera.config.AppConfig; +import io.aera.config.SecurityConfig; +import io.aera.config.application.WebConfig; +import io.aera.entity.History; +import io.aera.entity.Roles; +import io.aera.entity.User; +import io.aera.service.UserService; +import org.apache.commons.codec.binary.Base64; +import org.hibernate.SessionFactory; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.MockitoAnnotations; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.*; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.security.test.context.support.WithUserDetails; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.web.WebAppConfiguration; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.context.WebApplicationContext; + +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Root; +import java.util.List; + +import static org.junit.Assert.*; +import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {WebConfig.class, AppConfig.class, SecurityConfig.class}) +@WebAppConfiguration +@Transactional +public class UserControllerIntegrationTest { + private final String ROOT = "http://localhost:8080/user"; + private final String REGISTER = "/register"; + private final String UPDATE = "/update"; + private final String FINDUSER = "/findById"; + private final String LOGIN = "/login"; + private MockMvc mockMvc; + + @Autowired + private UserService userService; + + @Autowired + WebApplicationContext context; + + @Autowired + SessionFactory sessionFactory; + + @Before + public void init(){ + MockitoAnnotations.initMocks(this); + mockMvc = MockMvcBuilders.webAppContextSetup(context).apply(springSecurity()).build(); + } + + @Test + public void testCreateUser(){ + User user = createUser(); + RestTemplate restTemplate = new RestTemplate(); + + ResponseEntity responseEntity = restTemplate.exchange( + ROOT + FINDUSER + "/{id}", + HttpMethod.GET, + null, + User.class, + user.getId()); + + User result = responseEntity.getBody(); + + List historyItems = findHistory(user.getLogin(), "Registering new User!"); + assertNotNull(result); + assertEquals(user.getLogin(), result.getLogin()); + assertTrue(historyItems.size() > 0); + } + + private List findHistory(String login, String descr) { + CriteriaBuilder builder = sessionFactory.getCriteriaBuilder(); + CriteriaQuery criteria = builder.createQuery(History.class); + Root root = criteria.from(History.class); + criteria.select(root).where(builder.equal(root.get("userLogin"), login), builder.like(root.get("description"), descr)); + return sessionFactory.getCurrentSession().createQuery(criteria).getResultList(); + } + + @Test + public void testLoginUser(){ + User oldUser = prefillUser(); + + HttpHeaders httpHeaders = createHeaders(oldUser.getLogin(), oldUser.getPassword()); + HttpEntity userHttpEntity = new HttpEntity<>(httpHeaders); + RestTemplate restTemplate = new RestTemplate(); + + ResponseEntity responseEntity = restTemplate.exchange( + ROOT + LOGIN, + HttpMethod.GET, + userHttpEntity, + String.class); + + String answer = responseEntity.getStatusCode().toString(); + + assertNotNull(answer); + assertEquals("200", answer); + } + + @Test + @WithUserDetails("sword") + public void testUpdateUser() throws Exception { + User oldUser = prefillUser(); + User user = updateUser(oldUser); + + mockMvc.perform(put(ROOT + UPDATE) + .contentType(MediaType.APPLICATION_JSON_UTF8) + .content(asJsonString(user))) + .andExpect(status().isOk()); + + User updatedUser = this.userService.findByLogin(user.getLogin()); + assertEquals(updatedUser.getFirstname(), "Kat"); + } + + private HttpHeaders createHeaders(String username, String password){ + return new HttpHeaders() {{ + String auth = username + ":" + password; + byte[] encodedAuth = Base64.encodeBase64(auth.getBytes()); + String authHeader = "Basic " + new String( encodedAuth ); + set( "Authorization", authHeader ); + }}; + } + + private User createUser(){ + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON_UTF8); + User user = prefillUser(); + HttpEntity httpEntity = new HttpEntity<>(user, headers); + RestTemplate restTemplate = new RestTemplate(); + User result = restTemplate.exchange( + ROOT + REGISTER, + HttpMethod.PUT, + httpEntity, + User.class).getBody(); + + assertNotNull(result); + assertEquals("sword", result.getLogin()); + return result; + } + + private User updateUser(User oldUser) { + oldUser.setId(oldUser.getId()); + oldUser.setLogin("sword"); + oldUser.setFirstname("Kat"); + oldUser.setLastname("Kat"); + oldUser.setPassword(new BCryptPasswordEncoder().encode("sword")); + oldUser.setEmail("Kat@yandex.ru"); + oldUser.setRoleId(Roles.ROLE_USER); + return oldUser; + } + + private User prefillUser() { + User user = new User(); + user.setLogin("sword"); + user.setFirstname("sword"); + user.setLastname("sword"); + user.setPassword(new BCryptPasswordEncoder().encode("sword")); + user.setEmail("sword@mail.com"); + user.setRoleId(Roles.ROLE_USER); + return user; + } + + public static String asJsonString(final Object obj) { + try { + final ObjectMapper mapper = new ObjectMapper(); + return mapper.writeValueAsString(obj); + } catch (Exception e) { + throw new RuntimeException(e); + } + } +} diff --git a/src/test/java/io/aera/dao/impl/HistoryDaoImplTest.java b/src/test/java/io/aera/dao/impl/HistoryDaoImplTest.java new file mode 100644 index 0000000..8014e61 --- /dev/null +++ b/src/test/java/io/aera/dao/impl/HistoryDaoImplTest.java @@ -0,0 +1,45 @@ +package io.aera.dao.impl; + + +import io.aera.config.AppConfig; +import io.aera.config.HibernateConfig; +import io.aera.config.application.WebConfig; +import io.aera.dao.HistoryDao; +import io.aera.entity.History; +import org.hibernate.SessionFactory; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.web.WebAppConfiguration; + +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Root; +import java.util.Date; +import java.util.List; + +import static org.junit.Assert.*; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {WebConfig.class, AppConfig.class}) +@WebAppConfiguration +public class HistoryDaoImplTest { + @Autowired + HistoryDao historyDao; + + @Test + public void testCreateEntity() { + History history = new History( + new Date(), + "Test description", + "anonymousUser", + "currentSessionId", + "localhost" + ); + historyDao.create(history); + assertNotNull(historyDao.getEntityById(history.getId())); + assertEquals("Test description", history.getDescription()); + } +} diff --git a/src/test/java/io/aera/dao/impl/UserDaoImplTest.java b/src/test/java/io/aera/dao/impl/UserDaoImplTest.java new file mode 100644 index 0000000..50dc986 --- /dev/null +++ b/src/test/java/io/aera/dao/impl/UserDaoImplTest.java @@ -0,0 +1,88 @@ +package io.aera.dao.impl; + +import io.aera.config.AppConfig; +import io.aera.config.application.WebConfig; +import io.aera.dao.UserDao; +import io.aera.entity.User; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.web.WebAppConfiguration; +import java.util.ArrayList; +import java.util.List; +import static org.junit.Assert.*; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {WebConfig.class, AppConfig.class}) +@WebAppConfiguration +public class UserDaoImplTest { + @Autowired + private UserDao userDao; + + @Test + public void testCreateEntity(){ + User user = userDao.create(createUser()); + long id = user.getId(); + assertNotNull(userDao.getEntityById(id)); + assertEquals("raketa", user.getLogin()); + userDao.delete(user); + } + + @Test + public void testGetAllUsers(){ + List list = new ArrayList<>(); + User user = userDao.create(createUser()); + list.add(user); + assertNotNull(userDao.getList()); + userDao.delete(user); + } + + @Test + public void testFindEntityByIdAndEntity() { + User user = userDao.create(createUser()); + long id = user.getId(); + assertNotNull(userDao.getEntityById(id)); + User result = userDao.findEntityByName(user.getLogin()); + assertEquals("raketa", result.getLogin()); + userDao.delete(user); + } + + @Test + public void testUpdateUser(){ + User user = userDao.create(createUser()); + long id = user.getId(); + User updateduser = updateUser(user); + userDao.update(updateduser); + assertNotNull(userDao.getEntityById(id)); + assertEquals("phill", updateduser.getLogin()); + userDao.delete(userDao.getEntityById(id)); + } + + @Test + public void testDeleteUser(){ + User user = userDao.create(createUser()); + long id = user.getId(); + assertNotNull(userDao.getEntityById(id)); + userDao.delete(user); + assertNull(userDao.getEntityById(id)); + } + + private User updateUser(User user) { + User newUser = user; + newUser.setLogin("phill"); + newUser.setFirstname("Phillip"); + return newUser; + } + + private User createUser(){ + User user = new User(); + user.setLogin("raketa"); + user.setFirstname("Ivan"); + user.setLastname("Ivanov"); + user.setPassword("raketa"); + user.setEmail("ivan@yandex.ru"); + return user; + } +} diff --git a/src/test/java/io/aera/entity/RolesTest.java b/src/test/java/io/aera/entity/RolesTest.java new file mode 100644 index 0000000..f02035a --- /dev/null +++ b/src/test/java/io/aera/entity/RolesTest.java @@ -0,0 +1,30 @@ +package io.aera.entity; + +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; +import org.junit.Test; +import org.junit.runner.RunWith; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +@RunWith(JUnitParamsRunner.class) +public class RolesTest { + private static final Object[] getRoles() { + return new Object[] { + new Object[] {1, "ROLE_ADMIN"}, + new Object[] {2, "ROLE_USER"} + }; + } + + @Test + @Parameters(method = "getRoles") + public void createNewRolessuccessfully(int id, String role){ + Roles roles = new Roles(); + roles.setId(id); + roles.setRole(role); + + assertNotNull(roles); + assertEquals(id, roles.getId()); + assertEquals(role, roles.getRole()); + } +} diff --git a/src/test/java/io/aera/entity/UserTest.java b/src/test/java/io/aera/entity/UserTest.java new file mode 100644 index 0000000..30a6aee --- /dev/null +++ b/src/test/java/io/aera/entity/UserTest.java @@ -0,0 +1,40 @@ +package io.aera.entity; + +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; +import org.junit.Test; +import org.junit.runner.RunWith; +import static org.junit.Assert.assertEquals; + +@RunWith(JUnitParamsRunner.class) +public class UserTest { + private static final Object[] getUser() { + return new Object[] { + new Object[] {1L,"pet","Petr","Smirnov","smirnov","petr@yandex.ru",1}, + new Object[] {2L,"krak","Ivan","Petrov","petrov","ivan@yandex.ru",1}, + new Object[] {3L,"fact","Fedor","Kolokov","kolokov","fedor@yandex.ru",1} + }; + } + + @Test + @Parameters(method = "getUser") + public void createNewUserSuccessfully(long id, String login, String firstname, + String lastname, String password, String email, int role){ + User user = new User(); + user.setId(id); + user.setLogin(login); + user.setFirstname(firstname); + user.setLastname(lastname); + user.setPassword(password); + user.setEmail(email); + user.setRoleId(role); + + assertEquals(id, user.getId()); + assertEquals(login, user.getLogin()); + assertEquals(firstname, user.getFirstname()); + assertEquals(lastname, user.getLastname()); + assertEquals(password, user.getPassword()); + assertEquals(email, user.getEmail()); + assertEquals(role, user.getRoleId()); + } +} diff --git a/src/test/java/io/aera/service/impl/UserServiceImplTest.java b/src/test/java/io/aera/service/impl/UserServiceImplTest.java new file mode 100644 index 0000000..a4d5343 --- /dev/null +++ b/src/test/java/io/aera/service/impl/UserServiceImplTest.java @@ -0,0 +1,75 @@ +package io.aera.service.impl; + +import io.aera.config.AppConfig; +import io.aera.config.application.WebConfig; +import io.aera.entity.User; +import io.aera.service.UserService; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.web.WebAppConfiguration; +import static org.junit.Assert.*; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {WebConfig.class, AppConfig.class}) +@WebAppConfiguration +public class UserServiceImplTest { + @Autowired + private UserService userService; + + @Test + public void testRegisterUser() { + User user = userService.register(createUser()); + assertNotNull(userService.getById(user.getId())); + User userForComparison = userService.getById(user.getId()); + assertEquals("raketa", userForComparison.getLogin()); + userService.deleteStory(user.getId()); + } + + @Test + public void testGetUserByIdNameOrList(){ + User user = userService.register(createUser()); + assertNotNull(userService.getById(user.getId())); + assertNotNull(userService.findByLogin(user.getLogin())); + assertNotNull(userService.getListofUsers()); + userService.deleteStory(user.getId()); + } + + @Test + public void testUpdateUser(){ + User user = userService.register(createUser()); + User updatedUser = updateUser(user); + userService.update(updatedUser); + assertNotNull(userService.getById(updatedUser.getId())); + User result = userService.getById(user.getId()); + assertEquals("phill", result.getLogin()); + userService.deleteStory(updatedUser.getId()); + } + + @Test + public void testDeleteUser(){ + User user = userService.register(createUser()); + assertNotNull(userService.getById(user.getId())); + userService.deleteStory(user.getId()); + assertNull(userService.getById(user.getId())); + } + + private User updateUser(User user) { + User newUser = user; + newUser.setLogin("phill"); + newUser.setFirstname("Phillip"); + return newUser; + } + + private User createUser(){ + User user = new User(); + user.setLogin("raketa"); + user.setFirstname("Ivan"); + user.setLastname("Ivanov"); + user.setPassword("raketa"); + user.setEmail("ivan@yandex.ru"); + return user; + } +} diff --git a/web/WEB-INF/views/css/user_register.css b/web/WEB-INF/views/css/user_register.css new file mode 100644 index 0000000..3eea669 --- /dev/null +++ b/web/WEB-INF/views/css/user_register.css @@ -0,0 +1,24 @@ +.wrap { + min-height: 100%; + height: auto; + margin: 0 auto -60px; + padding: 0 0 60px; +} + +.wrap > .container { + padding: 70px 15px 20px; +} + +.required label:after { + content: '*'; + color: red; +} + +.form-group > .help-block { + color: red; + display: none; +} + +.form-group.has-error > .help-block { + display: block; +} diff --git a/web/WEB-INF/views/index.jsp b/web/WEB-INF/views/index.jsp index dca7935..c60e8b0 100644 --- a/web/WEB-INF/views/index.jsp +++ b/web/WEB-INF/views/index.jsp @@ -1,9 +1,15 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ page contentType="text/html;charset=UTF-8" language="java" %> - Title + Aera project -${attr} + + +

Welcome to Aera!

+
+">Login | +">Register diff --git a/web/WEB-INF/views/user/login.jsp b/web/WEB-INF/views/user/login.jsp new file mode 100644 index 0000000..e5fa09f --- /dev/null +++ b/web/WEB-INF/views/user/login.jsp @@ -0,0 +1,32 @@ +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + Login + + + + + + + +
+
+
+
+
+ + +
+
+ +
+ + +
+
+ +
+
+
+ + diff --git a/web/WEB-INF/views/user/register.jsp b/web/WEB-INF/views/user/register.jsp new file mode 100644 index 0000000..233189f --- /dev/null +++ b/web/WEB-INF/views/user/register.jsp @@ -0,0 +1,174 @@ +<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + Register new user + + + + + + + + +
+
+
+
+ + +
+
+ +
+ + +
+
+ +
+ + +
+
+ +
+ + +
+
+ +
+ + +
+
+ +
+ + +
+
+ + +
+
+ + diff --git a/web/WEB-INF/views/user/status.jsp b/web/WEB-INF/views/user/status.jsp new file mode 100644 index 0000000..110f9d5 --- /dev/null +++ b/web/WEB-INF/views/user/status.jsp @@ -0,0 +1,16 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + Status + + + +

Welcome!

+

UserName: ${user.firstname}

+

UserLastName: ${user.lastname}

+

UserEmail: ${user.email}

+
+">Update + + diff --git a/web/WEB-INF/views/user/update.jsp b/web/WEB-INF/views/user/update.jsp new file mode 100644 index 0000000..7a604e6 --- /dev/null +++ b/web/WEB-INF/views/user/update.jsp @@ -0,0 +1,173 @@ +<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + Update Profile + + + + + + + + +
+
+
+
+ + +
+
+ +
+ + +
+
+ +
+ + +
+
+ +
+ + +
+
+ +
+ + +
+
+ +
+ + +
+
+ + +
+
+ + \ No newline at end of file