Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
7427144
Added unit test for Java Bean
DuffMck Feb 21, 2019
99704af
Aggiunto anche Code Climate
DuffMck Feb 21, 2019
1c034df
TravisCI deploy config
tetofonta Feb 21, 2019
a317d18
TravisCI deploy config updated only tags
tetofonta Feb 21, 2019
fcca4e9
Add jacoco type
DuffMck Feb 21, 2019
3d7b4a7
Add base path
DuffMck Feb 21, 2019
7f375c0
added debug options
DuffMck Feb 21, 2019
376b21c
Added slack
DuffMck Feb 21, 2019
261b919
- removed temp
DuffMck Feb 21, 2019
8a9bc6c
Moved some instructions
DuffMck Feb 21, 2019
2608420
removed install by apt
DuffMck Feb 21, 2019
208745a
non runna....
DuffMck Feb 21, 2019
df7923c
Try slack
DuffMck Feb 21, 2019
58fb62a
Slack not work.. removed
DuffMck Feb 21, 2019
867ba3f
copy xml
DuffMck Feb 21, 2019
88e7370
some other test
DuffMck Feb 21, 2019
b114a40
Base data inside DB
DuffMck Mar 7, 2019
d94cd24
rimossi vecchi fie
DuffMck Mar 7, 2019
00f95f5
Merged from sources (bbadc447804a28c674b5a177952548f54ed40cca - Dummy…
tetofonta Mar 7, 2019
376f5c6
Merge branch 'master' of https://github.com/MytiLab/academy-backend i…
tetofonta Mar 7, 2019
363be97
Merging from develop
tetofonta Mar 7, 2019
51b7071
Added app props
DuffMck Mar 7, 2019
6e70eac
Merge branch 'develop' of https://github.com/MytiLab/academy-backend …
tetofonta Mar 7, 2019
bbbe51e
Added app props
DuffMck Mar 7, 2019
50d2489
Merge branch 'develop' of https://github.com/MytiLab/academy-backend …
tetofonta Mar 7, 2019
ba5ddde
Getting started
tetofonta Mar 7, 2019
adeaa4b
Added dependencies for unavailable maven central problems
DuffMck Mar 7, 2019
0f1e8f4
changed dependencies
DuffMck Mar 7, 2019
de3324f
refactoring, partial api implementation
tetofonta Mar 8, 2019
a877044
Added UnitaLogistiche API
tetofonta Mar 8, 2019
43066a2
Corrected api returns
tetofonta Mar 9, 2019
d0acf76
Added Event Api
tetofonta Mar 9, 2019
15befbf
Aggiunto primo servizio
DuffMck Mar 11, 2019
2916076
Aggiunto JsonIgnore
DuffMck Mar 11, 2019
611d392
Added services tests
tetofonta Mar 13, 2019
b8bc1ff
Resolved deprecation warnings
tetofonta Mar 18, 2019
adef370
little smallish code
tetofonta Mar 21, 2019
d950755
Added basic JWT authentication
DuffMck Mar 21, 2019
437016b
Optimizations
tetofonta Mar 21, 2019
72c34a7
Merged from upstream, all tests are working, so strange
tetofonta Mar 21, 2019
2e2afd0
removed unused files and refacoring
tetofonta Mar 21, 2019
ed4de34
Moved jwt params to proprierties
vezzoo Mar 22, 2019
a2117bf
Some features
vezzoo Mar 25, 2019
0e31570
Some features
vezzoo Mar 25, 2019
09de5bd
Controllers tests
tetofonta Mar 25, 2019
6841d4f
Merging from develop
tetofonta Mar 25, 2019
20768b3
RELEASE 1.0
tetofonta Mar 25, 2019
d5e9034
Updated travis configs
tetofonta Mar 25, 2019
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 @@ -23,3 +23,6 @@
/nbdist/
/.nb-gradle/
/build/
!/src/test/resources/application.properties
!/src/main/resources/application.properties
!/mvn-repository-exported.zip
35 changes: 28 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
env:
global:
- CC_TEST_REPORTER_ID=19cd4efa77fdc8ca82e9308787980d32ec2282b88cd4d6f91d00528790b7fa09

- CC_TEST_REPORTER_ID=19cd4efa77fdc8ca82e9308787980d32ec2282b88cd4d6f91d00528790b7fa09
cache:
directories:
- $HOME/.m2

- "$HOME/.m2"
before_install:
- sudo apt-get install -y tree
before_script:
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64
> ./cc-test-reporter
- chmod +x ./cc-test-reporter
- "./cc-test-reporter before-build"
language: java
after_success:
- bash <(curl -s https://codecov.io/bash)
- bash <(curl -s https://codecov.io/bash)
- JACOCO_SOURCE_PATH=src/main/java
- cp target/jacoco-ut/jacoco.xml ./jacoco.xml
- "./cc-test-reporter format-coverage -t jacoco -d --exit-code $TRAVIS_TEST_RESULT"
- pwd
- tree -L 3
- "./cc-test-reporter format-coverage -t jacoco target/jacoco-ut/jacoco.xml"
- "./cc-test-reporter upload-coverage"
jdk: oraclejdk8


deploy:
provider: releases
api_key:
secure: Yw6wgyCZF0ypJzFtEF75g9iaMNKPduhZiwOjUUuhPBu+fTkQP1nukORGZCE4FPcEnBA3Hu8iN6V5KujPJWduId6mduWUDIfZJwVINmnjLmWtLSeY5rxcA61dzJ789I3l9gtxlmxu/LRlDfntTEW9MSOBvRRIoggE0Vv1MnUyYZZWSmDgwGcrjkTCAp/Cbk/Fg6/+4uD9GOYYX45vwvHFbtCSNgBriWDpxJ5EeBNvhwcP9mVpZ3Mn5JkFQ2Q0MbK6kV8cFYQe0qag6rABrVR181zCaAFejDoiaKHrV7Qr7CYCOCRT45g6Vh2fMnyt0Z4y1kPV2zu2X0GWf6ePn/LGQE0tU/+pJXVILly2yjdkbV8eMfkgHe/X19ruZpQTVQDD6fIKYqZkZo8z32Pz+s++FV0usYGWF6OOmrG+dK2pFLSuQtYZFYvPa+zoCKUuAw0uI9cH+er7SL6nz5wIv6lpofhKsmcYLAhDtqicoLYqlSazPpJ3JM1u0duRIdxBzCczodKNctpNEWHVzMCU2zaQtkjZi3AZBWRDq5Cq6nCOgN0w4O0U4Tys6npKbiLD+EYWIpd21LbB1wj8f2nDxrsW7cE2ViHRedwSkJCdYvvNTnZeabh3C6fAqyNxes5ZCTokxj8al784CQxDI06jw6Hj+i71MwFxZgekMD/1Oqr0RK0=
file: "$HOME/target/*.jar"
on:
repo: tetofonta/academy-backend
notifications:
slack:
rooms:
- capitanovvio:OzupfbOHX15vJW4vJE1TOIA9#general
40 changes: 33 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
Expand All @@ -8,31 +8,42 @@
<version>2.1.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>it.myti.accademy</groupId>
<groupId>it.myti.academy</groupId>
<artifactId>backend</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.0-RELEASE</version>
<name>backend</name>
<description>Backend project for MyTi accademy</description>

<properties>
<java.version>1.8</java.version>
</properties>

<repositories>
<repository>
<id>myti-local</id>
<url>http://localhost:8081/</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
</dependency>

<!-- TOOLS -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
Expand All @@ -43,12 +54,27 @@
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.0</version>
</dependency>

<!-- TEST -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/it/myti/academy/backend/BackendApplication.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package it.myti.academy.backend;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

Expand All @@ -8,6 +9,7 @@ public class BackendApplication {

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

}

}
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/it/myti/academy/backend/config/CryptConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package it.myti.academy.backend.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

/**
* Created by david at 2019-03-20
*/
@Configuration
public class CryptConfig {

@Bean
public BCryptPasswordEncoder bCryptPasswordEncoder() {
return new BCryptPasswordEncoder();
}


}
46 changes: 46 additions & 0 deletions src/main/java/it/myti/academy/backend/config/WebSecurity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package it.myti.academy.backend.config;

import it.myti.academy.backend.filter.JWTAuthenticationFilter;
import it.myti.academy.backend.filter.JWTAuthorizationFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.HttpMethod;
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.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;


/**
* Created by david at 2019-03-20
*/
@EnableWebSecurity
public class WebSecurity extends WebSecurityConfigurerAdapter{
private UserDetailsService userDetailsService;
private BCryptPasswordEncoder bCryptPasswordEncoder;

@Autowired
public WebSecurity(@Qualifier("userDetailsServiceImpl") UserDetailsService userDetailsService, BCryptPasswordEncoder bCryptPasswordEncoder) {
this.userDetailsService = userDetailsService;
this.bCryptPasswordEncoder = bCryptPasswordEncoder;
}

@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable().authorizeRequests()
.antMatchers("/h2-console/**").permitAll()
.antMatchers(HttpMethod.POST, "/utenti/sign-up", "/unitalogistiche/*").permitAll()
.anyRequest().authenticated()
.and()
.addFilter(new JWTAuthenticationFilter(authenticationManager()))
.addFilter(new JWTAuthorizationFilter(authenticationManager()));
http.headers().frameOptions().disable();
}

@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userDetailsService).passwordEncoder(bCryptPasswordEncoder);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package it.myti.academy.backend.controller;

import it.myti.academy.backend.model.Collo;
import it.myti.academy.backend.model.Utente;
import it.myti.academy.backend.repository.UtenteRepository;
import it.myti.academy.backend.service.ColloService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
* Created by david at 2019-03-07
*/
@RestController
@RequestMapping("/colli")
public class ColliController {

private final ColloService colloService;

private final UtenteRepository utenteRepository;

@Autowired
public ColliController(ColloService colloService, UtenteRepository utenteRepository) {
this.colloService = colloService;
this.utenteRepository = utenteRepository;
}

@GetMapping("/")
public List<Collo> getByUtente() {
List<Collo> returnValue = null;

Authentication auth = SecurityContextHolder.getContext().getAuthentication();
String username = auth.getName();
final Utente utente = utenteRepository.findByUsername(username);

if (utente != null)
returnValue = colloService.getSpedizioniAttiveByUtente(utente);

return returnValue;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package it.myti.academy.backend.controller;

import it.myti.academy.backend.model.Evento;
import it.myti.academy.backend.model.Utente;
import it.myti.academy.backend.repository.UtenteRepository;
import it.myti.academy.backend.service.EventoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/eventi")
public class EventiController {

private final UtenteRepository utenteRepository;
private final EventoService eventi;
@Autowired
public EventiController(UtenteRepository utenteRepository, EventoService eventi) {
this.utenteRepository = utenteRepository;
this.eventi = eventi;
}

@GetMapping("/")
public List<Evento> getByUtente(@RequestParam Map<String, String> params) {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
String username = auth.getName();
final Utente utente = utenteRepository.findByUsername(username);
if (utente != null) {
Long spedizione = null;
Long ul = null;
try {
spedizione = params.get("idSpedizione") != null ? Long.parseLong(params.get("idSpedizione")) : null;
ul = params.get("idUnitaLogistica") != null ? Long.parseLong(params.get("idUnitaLogistica")) : null;
} catch (NumberFormatException e) {
spedizione = null;
ul = null;
}
return eventi.getEventiByUtente(utente, spedizione, ul);
}
return null;
}

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package it.myti.academy.backend.controller;

import it.myti.academy.backend.model.UnitaLogistica;
import it.myti.academy.backend.model.Utente;
import it.myti.academy.backend.model.resp.UnitaLogisticaDettaglio;
import it.myti.academy.backend.repository.UtenteRepository;
import it.myti.academy.backend.service.UnitaLogisticaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/unitalogistiche")
public class UnitaLogisticheController {

private final UtenteRepository utenteRepository;
private final UnitaLogisticaService uls;

@Autowired
public UnitaLogisticheController(UtenteRepository utenteRepository, UnitaLogisticaService uls) {
this.utenteRepository = utenteRepository;
this.uls = uls;
}

@GetMapping("/")
public List<UnitaLogistica> getByUtente() {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
String username = auth.getName();
final Utente utente = utenteRepository.findByUsername(username);

if (utente != null)
return uls.getUnitaLogisticheInViaggioByUtente(utente);
return null;
}

@GetMapping("/{id}")
public UnitaLogisticaDettaglio getById(@PathVariable("id") long id) {
return uls.getUnitaLogisticaDetail(id);
}

}
Loading