Commit c4e83d0083519f1009e829d7d66c52600158de5f
Merge branch 'master' of archives.plil.fr:LeClubInfo/etunicorn-server
Showing
8 changed files
with
51 additions
and
37 deletions
Show diff stats
.idea/dataSources.local.xml
1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | <project version="4"> | 2 | <project version="4"> |
3 | <component name="dataSourceStorageLocal"> | 3 | <component name="dataSourceStorageLocal"> |
4 | - <data-source name="etunicorn.db" uuid="ebfeef5a-f196-4340-9424-14e4e8aaadbb"> | 4 | + <data-source name="etunicorn.db" uuid="7ff25d0f-17b0-48bb-a8e6-be9293e5e8dc"> |
5 | <database-info product="SQLite" version="3.8.11" jdbc-version="2.1" driver-name="SQLiteJDBC" driver-version="native" /> | 5 | <database-info product="SQLite" version="3.8.11" jdbc-version="2.1" driver-name="SQLiteJDBC" driver-version="native" /> |
6 | <case-sensitivity plain-identifiers="mixed" quoted-identifiers="mixed" /> | 6 | <case-sensitivity plain-identifiers="mixed" quoted-identifiers="mixed" /> |
7 | <secret-storage>master_key</secret-storage> | 7 | <secret-storage>master_key</secret-storage> |
.idea/dataSources.xml
1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | <project version="4"> | 2 | <project version="4"> |
3 | <component name="DataSourceManagerImpl" format="xml" multifile-model="true"> | 3 | <component name="DataSourceManagerImpl" format="xml" multifile-model="true"> |
4 | - <data-source source="LOCAL" name="etunicorn.db" uuid="ebfeef5a-f196-4340-9424-14e4e8aaadbb"> | 4 | + <data-source source="LOCAL" name="etunicorn.db" uuid="7ff25d0f-17b0-48bb-a8e6-be9293e5e8dc"> |
5 | <driver-ref>sqlite.xerial</driver-ref> | 5 | <driver-ref>sqlite.xerial</driver-ref> |
6 | <synchronize>true</synchronize> | 6 | <synchronize>true</synchronize> |
7 | <jdbc-driver>org.sqlite.JDBC</jdbc-driver> | 7 | <jdbc-driver>org.sqlite.JDBC</jdbc-driver> |
8 | <jdbc-url>jdbc:sqlite:$PROJECT_DIR$/etunicorn.db</jdbc-url> | 8 | <jdbc-url>jdbc:sqlite:$PROJECT_DIR$/etunicorn.db</jdbc-url> |
9 | + <driver-properties> | ||
10 | + <property name="enable_load_extension" value="true" /> | ||
11 | + </driver-properties> | ||
9 | </data-source> | 12 | </data-source> |
10 | </component> | 13 | </component> |
11 | </project> | 14 | </project> |
12 | \ No newline at end of file | 15 | \ No newline at end of file |
src/main/java/etunicorn/SecurityInterceptor.java
@@ -53,12 +53,14 @@ public class SecurityInterceptor extends HandlerInterceptorAdapter { | @@ -53,12 +53,14 @@ public class SecurityInterceptor extends HandlerInterceptorAdapter { | ||
53 | 53 | ||
54 | if (annotation != null) { | 54 | if (annotation != null) { |
55 | Permission requiredPermission = permissionRepository.findByNom(annotation.value()); | 55 | Permission requiredPermission = permissionRepository.findByNom(annotation.value()); |
56 | - if (requiredPermission == null) { | ||
57 | - response.setStatus(HttpStatus.NOT_IMPLEMENTED.value()); | ||
58 | - return false; | ||
59 | - } | ||
60 | 56 | ||
61 | if (annotation.authentifie()) { | 57 | if (annotation.authentifie()) { |
58 | + if (requiredPermission == null) { | ||
59 | + response.setStatus(HttpStatus.NOT_IMPLEMENTED.value()); | ||
60 | + // TODO utiliser base controller | ||
61 | + return false; | ||
62 | + } | ||
63 | + | ||
62 | BaseController baseController = new BaseController(); | 64 | BaseController baseController = new BaseController(); |
63 | baseController.setRequest(request); | 65 | baseController.setRequest(request); |
64 | if (session == null) { | 66 | if (session == null) { |
src/main/java/etunicorn/entity/Personne.java
1 | package etunicorn.entity; | 1 | package etunicorn.entity; |
2 | 2 | ||
3 | +import com.fasterxml.jackson.annotation.JsonFormat; | ||
4 | + | ||
3 | import javax.persistence.*; | 5 | import javax.persistence.*; |
4 | import java.util.Date; | 6 | import java.util.Date; |
5 | 7 | ||
@@ -50,6 +52,7 @@ public class Personne { | @@ -50,6 +52,7 @@ public class Personne { | ||
50 | this.carte = carte; | 52 | this.carte = carte; |
51 | } | 53 | } |
52 | 54 | ||
55 | + @JsonFormat(pattern="YYYY-MM-DD hh:mm:ss") | ||
53 | public Date getNaissance() { | 56 | public Date getNaissance() { |
54 | return naissance; | 57 | return naissance; |
55 | } | 58 | } |
src/main/java/etunicorn/entity/Session.java
1 | package etunicorn.entity; | 1 | package etunicorn.entity; |
2 | 2 | ||
3 | +import com.fasterxml.jackson.annotation.JsonFormat; | ||
4 | + | ||
3 | import javax.persistence.Entity; | 5 | import javax.persistence.Entity; |
4 | import javax.persistence.Id; | 6 | import javax.persistence.Id; |
5 | import javax.persistence.ManyToOne; | 7 | import javax.persistence.ManyToOne; |
@@ -58,6 +60,7 @@ public class Session { | @@ -58,6 +60,7 @@ public class Session { | ||
58 | this.token = token; | 60 | this.token = token; |
59 | } | 61 | } |
60 | 62 | ||
63 | + @JsonFormat(pattern="YYYY-MM-DD hh:mm:ss") | ||
61 | public Date getValidity() { | 64 | public Date getValidity() { |
62 | return validity; | 65 | return validity; |
63 | } | 66 | } |
src/main/java/etunicorn/generated/LoginController.java
1 | 1 | ||
2 | package etunicorn.generated; | 2 | package etunicorn.generated; |
3 | 3 | ||
4 | +import javax.validation.Valid; | ||
4 | import etunicorn.generated.model.UpdateLoginRequest; | 5 | import etunicorn.generated.model.UpdateLoginRequest; |
5 | import org.springframework.http.ResponseEntity; | 6 | import org.springframework.http.ResponseEntity; |
6 | import org.springframework.web.bind.annotation.RequestBody; | 7 | import org.springframework.web.bind.annotation.RequestBody; |
@@ -8,8 +9,6 @@ import org.springframework.web.bind.annotation.RequestMapping; | @@ -8,8 +9,6 @@ import org.springframework.web.bind.annotation.RequestMapping; | ||
8 | import org.springframework.web.bind.annotation.RequestMethod; | 9 | import org.springframework.web.bind.annotation.RequestMethod; |
9 | import org.springframework.web.bind.annotation.RestController; | 10 | import org.springframework.web.bind.annotation.RestController; |
10 | 11 | ||
11 | -import javax.validation.Valid; | ||
12 | - | ||
13 | 12 | ||
14 | /** | 13 | /** |
15 | * No description | 14 | * No description |
@@ -26,16 +25,16 @@ public interface LoginController { | @@ -26,16 +25,16 @@ public interface LoginController { | ||
26 | * | 25 | * |
27 | */ | 26 | */ |
28 | @RequestMapping(value = "", method = RequestMethod.POST) | 27 | @RequestMapping(value = "", method = RequestMethod.POST) |
29 | - ResponseEntity<?> updateLogin( | ||
30 | - @Valid | ||
31 | - @RequestBody | ||
32 | - UpdateLoginRequest updateLoginRequest); | 28 | + public ResponseEntity<?> updateLogin( |
29 | + @Valid | ||
30 | + @RequestBody | ||
31 | + UpdateLoginRequest updateLoginRequest); | ||
33 | 32 | ||
34 | /** | 33 | /** |
35 | * Se déconnecter | 34 | * Se déconnecter |
36 | * | 35 | * |
37 | */ | 36 | */ |
38 | @RequestMapping(value = "", method = RequestMethod.DELETE) | 37 | @RequestMapping(value = "", method = RequestMethod.DELETE) |
39 | - ResponseEntity<?> deleteLogin(); | 38 | + public ResponseEntity<?> deleteLogin(); |
40 | 39 | ||
41 | } | 40 | } |
src/main/java/etunicorn/generated/RoleController.java
@@ -25,55 +25,55 @@ public interface RoleController { | @@ -25,55 +25,55 @@ public interface RoleController { | ||
25 | * | 25 | * |
26 | */ | 26 | */ |
27 | @RequestMapping(value = "", method = RequestMethod.GET) | 27 | @RequestMapping(value = "", method = RequestMethod.GET) |
28 | - ResponseEntity<?> getRole(); | 28 | + public ResponseEntity<?> getRole(); |
29 | 29 | ||
30 | /** | 30 | /** |
31 | * Ajoute un nouveau rôle. Nécessite ROLE_ADMIN | 31 | * Ajoute un nouveau rôle. Nécessite ROLE_ADMIN |
32 | * | 32 | * |
33 | */ | 33 | */ |
34 | @RequestMapping(value = "", method = RequestMethod.POST) | 34 | @RequestMapping(value = "", method = RequestMethod.POST) |
35 | - ResponseEntity<?> updateRole( | ||
36 | - @javax.validation.Valid | ||
37 | - @org.springframework.web.bind.annotation.RequestBody | ||
38 | - UpdateRoleRequest updateRoleRequest); | 35 | + public ResponseEntity<?> updateRole( |
36 | + @javax.validation.Valid | ||
37 | + @org.springframework.web.bind.annotation.RequestBody | ||
38 | + UpdateRoleRequest updateRoleRequest); | ||
39 | 39 | ||
40 | /** | 40 | /** |
41 | * Supprime un rôle. Nécessite ROLE_ADMIN | 41 | * Supprime un rôle. Nécessite ROLE_ADMIN |
42 | * | 42 | * |
43 | */ | 43 | */ |
44 | @RequestMapping(value = "/{nomRole}", method = RequestMethod.DELETE) | 44 | @RequestMapping(value = "/{nomRole}", method = RequestMethod.DELETE) |
45 | - ResponseEntity<?> deleteRoleById( | ||
46 | - @PathVariable | ||
47 | - String nomRole); | 45 | + public ResponseEntity<?> deleteRoleById( |
46 | + @PathVariable | ||
47 | + String nomRole); | ||
48 | 48 | ||
49 | /** | 49 | /** |
50 | * Ajoute une permission à un rôle. Nécessite ROLE_ADMIN | 50 | * Ajoute une permission à un rôle. Nécessite ROLE_ADMIN |
51 | * | 51 | * |
52 | */ | 52 | */ |
53 | @RequestMapping(value = "/{nomRole}", method = RequestMethod.POST) | 53 | @RequestMapping(value = "/{nomRole}", method = RequestMethod.POST) |
54 | - ResponseEntity<?> updateRoleById( | ||
55 | - @PathVariable | ||
56 | - String nomRole, | ||
57 | - @javax.validation.Valid | ||
58 | - @org.springframework.web.bind.annotation.RequestBody | ||
59 | - UpdateRoleByIdRequest updateRoleByIdRequest); | 54 | + public ResponseEntity<?> updateRoleById( |
55 | + @PathVariable | ||
56 | + String nomRole, | ||
57 | + @javax.validation.Valid | ||
58 | + @org.springframework.web.bind.annotation.RequestBody | ||
59 | + UpdateRoleByIdRequest updateRoleByIdRequest); | ||
60 | 60 | ||
61 | /** | 61 | /** |
62 | * Enlève la permission du rôle. Nécessite ROLE_ADMIN | 62 | * Enlève la permission du rôle. Nécessite ROLE_ADMIN |
63 | * | 63 | * |
64 | */ | 64 | */ |
65 | @RequestMapping(value = "/{nomRole}/{nomPermission}", method = RequestMethod.DELETE) | 65 | @RequestMapping(value = "/{nomRole}/{nomPermission}", method = RequestMethod.DELETE) |
66 | - ResponseEntity<?> deleteRoleByNomPermission( | ||
67 | - @PathVariable | ||
68 | - String nomPermission, | ||
69 | - @PathVariable | ||
70 | - String nomRole); | 66 | + public ResponseEntity<?> deleteRoleByNomPermission( |
67 | + @PathVariable | ||
68 | + String nomPermission, | ||
69 | + @PathVariable | ||
70 | + String nomRole); | ||
71 | 71 | ||
72 | /** | 72 | /** |
73 | * Liste les permissions. Nécessite ROLE_ADMIN | 73 | * Liste les permissions. Nécessite ROLE_ADMIN |
74 | * | 74 | * |
75 | */ | 75 | */ |
76 | @RequestMapping(value = "/permission", method = RequestMethod.GET) | 76 | @RequestMapping(value = "/permission", method = RequestMethod.GET) |
77 | - ResponseEntity<?> getPermission(); | 77 | + public ResponseEntity<?> getPermission(); |
78 | 78 | ||
79 | } | 79 | } |
src/main/java/etunicorn/generated/model/UpdatePersonneRequest.java
1 | 1 | ||
2 | package etunicorn.generated.model; | 2 | package etunicorn.generated.model; |
3 | 3 | ||
4 | -import com.fasterxml.jackson.annotation.*; | 4 | +import java.util.HashMap; |
5 | +import java.util.Map; | ||
6 | +import com.fasterxml.jackson.annotation.JsonAnyGetter; | ||
7 | +import com.fasterxml.jackson.annotation.JsonAnySetter; | ||
8 | +import com.fasterxml.jackson.annotation.JsonIgnore; | ||
9 | +import com.fasterxml.jackson.annotation.JsonInclude; | ||
10 | +import com.fasterxml.jackson.annotation.JsonProperty; | ||
11 | +import com.fasterxml.jackson.annotation.JsonPropertyOrder; | ||
5 | import org.apache.commons.lang.builder.EqualsBuilder; | 12 | import org.apache.commons.lang.builder.EqualsBuilder; |
6 | import org.apache.commons.lang.builder.HashCodeBuilder; | 13 | import org.apache.commons.lang.builder.HashCodeBuilder; |
7 | import org.apache.commons.lang.builder.ToStringBuilder; | 14 | import org.apache.commons.lang.builder.ToStringBuilder; |
8 | 15 | ||
9 | -import java.util.HashMap; | ||
10 | -import java.util.Map; | ||
11 | - | ||
12 | @JsonInclude(JsonInclude.Include.NON_NULL) | 16 | @JsonInclude(JsonInclude.Include.NON_NULL) |
13 | @JsonPropertyOrder({ | 17 | @JsonPropertyOrder({ |
14 | "carte", | 18 | "carte", |