Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
50c4493
add README.txt
abakyr Jul 2, 2017
c507e2f
Add User register functionality
maximkosheev Jul 3, 2017
bc0fc74
add UserTest
abakyr Jul 4, 2017
6105ded
add dependencies to pom
abakyr Jul 4, 2017
b461f4c
Register user by REST
maximkosheev Jul 4, 2017
1a339c9
1. Add register form validation
maximkosheev Jul 5, 2017
262ff4b
add DAO layer unit test
abakyr Jul 6, 2017
b07cd44
1. Added Role Entity
maximkosheev Jul 6, 2017
3f7ef72
add UserServiceTest
abakyr Jul 7, 2017
bbdc40c
add UserControllerTest
abakyr Jul 8, 2017
b0a524a
add login page
abakyr Jul 8, 2017
64c65c3
add /status method in UserController, changes to SecurityConfig
abakyr Jul 10, 2017
f79c410
add update function to UserController
abakyr Jul 10, 2017
08131f2
Merge conflict fix
maximkosheev Jul 11, 2017
50c2d6a
add Test for entity Roles, add method to find entity to UserController
abakyr Jul 12, 2017
30c1dae
add classes folder
abakyr Jul 12, 2017
c713495
add updating /update.jsp
abakyr Jul 12, 2017
14bb0a0
add testing update method at UserControllerIntegrationTest
abakyr Jul 13, 2017
d3d1e6e
add UML representation of User services
abakyr Jul 14, 2017
c785845
add changed test for services & dao layers
abakyr Jul 18, 2017
0947665
Remove classes folder
maximkosheev Jul 20, 2017
d2f6845
add History entity
abakyr Jul 20, 2017
9ba22a1
Merge branch 'KirillMaxim' of https://github.com/khasang-incubator/ae…
abakyr Jul 20, 2017
e081397
Added log4j.properties
maximkosheev Jul 20, 2017
d52e79c
logging
maximkosheev Jul 20, 2017
da47326
logging
maximkosheev Jul 20, 2017
b10109c
add changed HistoryService implementation
abakyr Jul 20, 2017
89d776a
Merge branch 'KirillMaxim' of https://github.com/khasang-incubator/ae…
abakyr Jul 20, 2017
6bcae77
add changes to pom
abakyr Jul 20, 2017
fa72721
Testing history
maximkosheev Jul 22, 2017
679225c
add test for update method
abakyr Aug 27, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
*.iml
/target/
/out/
/KirillMaxim/
/classes/
/IgnoreMeFile.txt
2 changes: 2 additions & 0 deletions KirillMaxim/README.txt
Original file line number Diff line number Diff line change
@@ -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 = ?
93 changes: 93 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
<postgresql.version>9.4.1212.jre7</postgresql.version>
<hibernate.version>5.2.10.Final</hibernate.version>
<jackson.version>2.7.8</jackson.version>
<junit.version>4.12</junit.version>
<junit.param.version>1.0.4</junit.param.version>
<log4j.version>1.2.17</log4j.version>
<moickito.version>1.9.5</moickito.version>
<hamcrest.version>1.3</hamcrest.version>
<logback.version>1.1.7</logback.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -46,6 +52,12 @@
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
</dependency>

<!-- Spring Security -->
<dependency>
<groupId>org.springframework.security</groupId>
Expand All @@ -62,12 +74,19 @@
<artifactId>spring-security-web</artifactId>
<version>${spring.security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<version>${spring.security.version}</version>
</dependency>

<!-- Postgresql -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql.version}</version>
</dependency>

<!-- Hibernate -->
<dependency>
<groupId>org.hibernate</groupId>
Expand All @@ -94,17 +113,91 @@
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>

<!-- JSP -->
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>${jstl.version}</version>
</dependency>

<!-- JUnit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>

<!-- JUnit Param -->
<dependency>
<groupId>pl.pragmatists</groupId>
<artifactId>JUnitParams</artifactId>
<version>${junit.param.version}</version>
<scope>test</scope>
</dependency>

<!-- Other testing tools -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.11</version>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.3</version>
</dependency>

<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.10</version>
</dependency>

<!-- Mockito -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>${moickito.version}</version>
<scope>test</scope>
</dependency>

<!-- Hamcrest -->
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>${hamcrest.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path-assert</artifactId>
<version>2.2.0</version>
<scope>test</scope>
</dependency>

<!-- logging this 2 delete -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>

<!-- Logger -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
</dependencies>

<build>
Expand Down
23 changes: 17 additions & 6 deletions src/main/java/io/aera/config/AppConfig.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -58,9 +74,4 @@ public JdbcTemplate jdbcTemplate(){
jdbcTemplate.setDataSource(dataSource());
return jdbcTemplate;
}

@Bean
Dog dog(){
return new Dog(jdbcTemplate());
}
}
6 changes: 3 additions & 3 deletions src/main/java/io/aera/config/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}


}
6 changes: 6 additions & 0 deletions src/main/java/io/aera/config/application/WebConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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/");
}
}
23 changes: 14 additions & 9 deletions src/main/java/io/aera/controller/AppController.java
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -20,25 +21,29 @@ 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/")
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){
Expand Down
Loading