Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
38ae58d
creation des champs, getters et setters de tout les obj du domain
xxStevensxx Sep 28, 2021
f8cdb7c
Merge pull request #1 from xxStevensxx/impl_obj_domain
xxStevensxx Sep 28, 2021
5b0e213
Implementation des methodes de tout les controllers
xxStevensxx Sep 28, 2021
2f34755
Merge pull request #2 from xxStevensxx/impl_controller
xxStevensxx Sep 28, 2021
72b8be4
Creation du package security de la classe SecurityConfig pour l'authe…
xxStevensxx Sep 28, 2021
bf31221
Merge pull request #3 from xxStevensxx/springSecurityConfig
xxStevensxx Sep 28, 2021
9f5d9a9
Maj properties
xxStevensxx Sep 28, 2021
26ce9f7
Merge pull request #4 from xxStevensxx/maj_properties
xxStevensxx Sep 28, 2021
2357255
ajout de l'annotation spring @Repository
xxStevensxx Sep 28, 2021
85089d6
Merge pull request #5 from xxStevensxx/repository
xxStevensxx Sep 28, 2021
4b137f8
Ajout de @ComponentScan(basePackages = {com.nnk.springboot.repositori…
xxStevensxx Sep 28, 2021
ca1ecb0
Merge pull request #6 from xxStevensxx/app_config
xxStevensxx Sep 28, 2021
27b2749
Ajout des dependances swagger dans le pom.Xml ajout de l'annotation @…
xxStevensxx Sep 28, 2021
574fe31
Merge pull request #7 from xxStevensxx/swagger_config
xxStevensxx Sep 28, 2021
739da1a
Ajout du findbyUsername dans le user repo, creation du package servic…
xxStevensxx Sep 29, 2021
57070c8
Merge pull request #8 from xxStevensxx/services
xxStevensxx Sep 29, 2021
0e21e75
Ajout du pattern pour le password
xxStevensxx Sep 29, 2021
bba6c53
Merge pull request #9 from xxStevensxx/add_pattern_security
xxStevensxx Sep 29, 2021
fe174e3
MAJ des templates pour l'affichage des objets dans la vue
xxStevensxx Sep 29, 2021
bbb60e9
Merge pull request #10 from xxStevensxx/maj_templates
xxStevensxx Sep 29, 2021
ffdaf21
Maj de Spring config
xxStevensxx Sep 29, 2021
ff9aeb4
Merge pull request #11 from xxStevensxx/springSecurityConfig
xxStevensxx Sep 29, 2021
756f332
Refactoriasation de la classe springfox et maj de securityconfig
xxStevensxx Sep 29, 2021
4d61632
Merge pull request #12 from xxStevensxx/springSecurityConfig
xxStevensxx Sep 29, 2021
b300516
MAJ userdetails sur les grantedAuth
xxStevensxx Sep 29, 2021
39ac9e5
Merge pull request #13 from xxStevensxx/maj_services
xxStevensxx Sep 29, 2021
3330c88
Ajout des dependance Thymleaf
xxStevensxx Oct 2, 2021
c5a24ae
Merge pull request #14 from xxStevensxx/install_thymleaf
xxStevensxx Oct 2, 2021
b31c4ed
Ajout des dep pour log4j Instanciation du logger dans le main
xxStevensxx Oct 2, 2021
1af31a8
Merge pull request #15 from xxStevensxx/log4j
xxStevensxx Oct 2, 2021
85e93cb
Correction de la logique de MAJ sur le bid Controller et fix des coqu…
xxStevensxx Oct 2, 2021
a6073af
Merge pull request #16 from xxStevensxx/fix_controller_algo
xxStevensxx Oct 2, 2021
b1b7f7d
Ajout des log pouir chaques requete effectuées sur tout les controllers
xxStevensxx Oct 2, 2021
4967ca3
Merge pull request #17 from xxStevensxx/log4j
xxStevensxx Oct 2, 2021
4894ec8
Ajout des contraintes requises pour toute les objets domain
xxStevensxx Oct 3, 2021
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
44 changes: 42 additions & 2 deletions Poseiden-skeleton/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<java.version>11</java.version>
</properties>

<dependencies>
Expand All @@ -31,18 +31,49 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-jpa -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<!-- <exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions> -->
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring5</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
Expand All @@ -52,6 +83,16 @@
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
Expand All @@ -61,7 +102,6 @@
<artifactId>h2</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
package com.nnk.springboot;


import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;

import springfox.documentation.swagger2.annotations.EnableSwagger2;

@SpringBootApplication
@EnableSwagger2
@ComponentScan(basePackages = {"com.nnk.springboot.repositories"})
@SpringBootApplication(exclude={DataSourceAutoConfiguration.class, SecurityAutoConfiguration.class})
public class Application {


public final static Logger LOG = LogManager.getLogger(Application.class.getName());

public static void main(String[] args) {
SpringApplication.run(Application.class, args);


LOG.info("This is Info Log");


}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.nnk.springboot.config;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {

@Autowired
private DataSource dataSource;

@Autowired
public void configAuthentication(AuthenticationManagerBuilder auth) throws Exception {

auth.jdbcAuthentication()
.dataSource(dataSource)
.passwordEncoder(passwordEncoder());
}


@Override
protected void configure(HttpSecurity http) throws Exception {

http.authorizeRequests()
.antMatchers("/bidList/**", "/curvePoint/**", "/rating/**", "/ruleName/**", "/trade/**").hasAnyAuthority("USER")
.antMatchers("/user/**").permitAll()
.and()
.formLogin()
.loginPage("/login")
.defaultSuccessUrl("/bidList/list")
.and()
.logout()
.logoutUrl("/app-logout")
.logoutSuccessUrl("/")
.permitAll();

}


@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.nnk.springboot.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

@Configuration
public class SwaggerConfig {

@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("controllers"))
.paths(PathSelectors.any())
.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package com.nnk.springboot.controllers;

import com.nnk.springboot.Application;
import com.nnk.springboot.domain.BidList;
import com.nnk.springboot.repositories.BidListRepository;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
Expand All @@ -9,17 +13,23 @@
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.time.LocalDateTime;

import javax.validation.Valid;


@Controller
public class BidListController {
// TODO: Inject Bid service

@Autowired
BidListRepository bidListRepository;

@RequestMapping("/bidList/list")
public String home(Model model)
{
// TODO: call service find all bids to show to the view
model.addAttribute("bidList", bidListRepository.findAll());
return "bidList/list";
}

Expand All @@ -31,25 +41,46 @@ public String addBidForm(BidList bid) {
@PostMapping("/bidList/validate")
public String validate(@Valid BidList bid, BindingResult result, Model model) {
// TODO: check data valid and save to db, after saving return bid list
if (!result.hasErrors()) {
bidListRepository.save(bid);
Application.LOG.info("bid id: " + bid.getBidListId() + " Was save at: " + LocalDateTime.now());
model.addAttribute("bidList", bidListRepository.findAll());
return "redirect:/bidList/list";
}
return "bidList/add";
}

@GetMapping("/bidList/update/{id}")
public String showUpdateForm(@PathVariable("id") Integer id, Model model) {
// TODO: get Bid by Id and to model then show to the form
BidList bid = bidListRepository.findById(id).orElseThrow(() -> new IllegalArgumentException("Invalid bid Id:" + id));
Application.LOG.info("bid id: " + bid.getBidListId() + " Was show in form at: " + LocalDateTime.now());
model.addAttribute("bid", bid);
return "bidList/update";
}

@PostMapping("/bidList/update/{id}")
public String updateBid(@PathVariable("id") Integer id, @Valid BidList bidList,
BindingResult result, Model model) {
// TODO: check required fields, if valid call service to update Bid and return list Bid
return "redirect:/bidList/list";
if (result.hasErrors()) {
return"bidList/update";
}

bidList.setBidListId(id);
bidListRepository.save(bidList);
Application.LOG.info("bid id: " + bidList.getBidListId() + " Was update at: " + LocalDateTime.now());
model.addAttribute("bidList", bidListRepository.findAll());
return "redirect:/bidList/list";
}

@GetMapping("/bidList/delete/{id}")
public String deleteBid(@PathVariable("id") Integer id, Model model) {
// TODO: Find Bid by Id and delete the bid, return to Bid list
return "redirect:/bidList/list";
BidList bid = bidListRepository.findById(id).orElseThrow(() -> new IllegalArgumentException("Invalid bid Id:" + id));
bidListRepository.delete(bid);
Application.LOG.info("bid id: " + bid.getBidListId() + " Was delete at: " + LocalDateTime.now());
model.addAttribute("bid", bidListRepository.findAll());
return "redirect:/bidList/list";
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package com.nnk.springboot.controllers;

import com.nnk.springboot.Application;
import com.nnk.springboot.domain.CurvePoint;
import com.nnk.springboot.repositories.CurvePointRepository;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
Expand All @@ -9,17 +13,22 @@
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.time.LocalDateTime;

import javax.validation.Valid;

@Controller
public class CurveController {
// TODO: Inject Curve Point service
@Autowired
CurvePointRepository curveRepository;

@RequestMapping("/curvePoint/list")
public String home(Model model)
{
// TODO: find all Curve Point, add to model
return "curvePoint/list";
model.addAttribute("curves", curveRepository.findAll());
return "curvePoint/list";
}

@GetMapping("/curvePoint/add")
Expand All @@ -30,25 +39,47 @@ public String addBidForm(CurvePoint bid) {
@PostMapping("/curvePoint/validate")
public String validate(@Valid CurvePoint curvePoint, BindingResult result, Model model) {
// TODO: check data valid and save to db, after saving return Curve list
if (!result.hasErrors()) {
curveRepository.save(curvePoint);
Application.LOG.info("curvePoint id: " + curvePoint.getCurveId() + " Was save at: " + LocalDateTime.now());
model.addAttribute("curves", curveRepository.findAll());
return "redirect:/curvePoint/list";
}
return "curvePoint/add";
}

@GetMapping("/curvePoint/update/{id}")
public String showUpdateForm(@PathVariable("id") Integer id, Model model) {
// TODO: get CurvePoint by Id and to model then show to the form
CurvePoint curve = curveRepository.findById(id).orElseThrow(() -> new IllegalArgumentException("Invalid curvePoint Id:" + id));
Application.LOG.info("curvePoint id: " + curve.getCurveId() + " Was show in form at: " + LocalDateTime.now());
model.addAttribute("curve", curve);
return "curvePoint/update";
}

@PostMapping("/curvePoint/update/{id}")
public String updateBid(@PathVariable("id") Integer id, @Valid CurvePoint curvePoint,
BindingResult result, Model model) {
// TODO: check required fields, if valid call service to update Curve and return Curve list
return "redirect:/curvePoint/list";
if (result.hasErrors()) {
return "curvePoint/update";

}

curvePoint.setId(id);
curveRepository.save(curvePoint);
Application.LOG.info("curvePoint id: " + curvePoint.getCurveId() + " Was update at: " + LocalDateTime.now());
model.addAttribute("curves", curveRepository.findAll());
return "redirect:/curvePoint/list";
}

@GetMapping("/curvePoint/delete/{id}")
public String deleteBid(@PathVariable("id") Integer id, Model model) {
// TODO: Find Curve by Id and delete the Curve, return to Curve list
return "redirect:/curvePoint/list";
CurvePoint curve = curveRepository.findById(id).orElseThrow(() -> new IllegalArgumentException("Invalid curvePoint Id:" + id));
curveRepository.delete(curve);
Application.LOG.info("curvePoint id: " + curve.getCurveId() + " Was delete at: " + LocalDateTime.now());
model.addAttribute("curves", curveRepository.findAll());
return "redirect:/curvePoint/list";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class LoginController {
public ModelAndView login() {
ModelAndView mav = new ModelAndView();
mav.setViewName("login");
System.err.println("okay");
return mav;
}

Expand Down
Loading